Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaoye
mycard
Commits
f4622cef
Commit
f4622cef
authored
Aug 20, 2013
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync
parent
b3b52e18
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
135 additions
and
3 deletions
+135
-3
lib/deck.rb
lib/deck.rb
+53
-0
lib/deck_sync.rb
lib/deck_sync.rb
+75
-0
lib/scene_lobby.rb
lib/scene_lobby.rb
+2
-0
lib/update.rb
lib/update.rb
+3
-2
lib/window_deck.rb
lib/window_deck.rb
+2
-1
No files found.
lib/deck.rb
View file @
f4622cef
...
...
@@ -10,6 +10,7 @@ class Deck
attr_accessor
:side
attr_accessor
:extra
attr_accessor
:temp
Key
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="
def
initialize
(
main
,
side
=
[],
extra
=
[],
temp
=
[])
@main
=
main
@side
=
side
...
...
@@ -40,5 +41,57 @@ class Deck
end
self
.
new
(
main
,
side
,
extra
,
temp
)
end
def
self
.
ygopro_deck_to_url_param
(
file
)
card_usages
=
[]
side
=
false
last_id
=
nil
count
=
0
IO
.
readlines
(
file
).
each
do
|
line
|
if
line
[
0
]
==
'#'
next
elsif
line
[
0
,
5
]
==
'!side'
card_usages
.
push
({
card_id:
last_id
,
side:
side
,
count:
count
})
if
last_id
side
=
true
last_id
=
nil
else
card_id
=
line
.
to_i
if
card_id
.
zero?
next
else
if
card_id
==
last_id
count
+=
1
else
card_usages
.
push
({
card_id:
last_id
,
side:
side
,
count:
count
})
if
last_id
last_id
=
card_id
count
=
1
end
end
end
end
card_usages
.
push
({
card_id:
last_id
,
side:
side
,
count:
count
})
if
last_id
result
=
""
card_usages
.
each
do
|
card_usage
|
c
=
(
card_usage
[
:side
]
?
1
:
0
)
<<
29
|
card_usage
[
:count
]
<<
27
|
card_usage
[
:card_id
]
4
.
downto
(
0
)
do
|
i
|
result
<<
Key
[(
c
>>
i
*
6
)
&
0x3F
]
end
end
require
'uri'
"name=
#{
URI
.
escape
(
File
.
basename
(
file
,
".ydk"
),
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
))
}
&cards=
#{
result
}
"
end
#def self.decode(str)
# card_usages = []
# (0...str.length).step(5) do |i|
# decoded = 0
# str[i, 5].each do |char|
# decoded = (decoded << 6) + Key.index(char)
# side = decoded >> 29
# count = decoded >> 27 & 0x3
# card_id = decoded & 0x07FFFFFF
# card_usages.push(card_id: card_id, side: side, count: count)
# end
# end
#end
end
lib/deck_sync.rb
0 → 100644
View file @
f4622cef
module
Deck_Sync
require_relative
'deck'
class
<<
self
def
start
Update
.
status
=
'正在同步卡组'
require
'open-uri'
require
'uri'
require
'net/http'
require
'json'
require
'date'
Thread
.
new
{
just_updated
=
[]
$log
.
info
(
'下载卡组'
){
"https://my-card.in/decks/?user=
#{
URI
.
escape
$game
.
user
.
id
.
bare
.
to_s
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
"
}
open
(
"https://my-card.in/decks/?user=
#{
URI
.
escape
$game
.
user
.
id
.
bare
.
to_s
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
"
)
{
|
list
|
JSON
.
parse
(
list
.
read
).
each
{
|
deck
|
file
=
File
.
join
(
File
.
dirname
(
Ygocore
.
ygocore_path
),
'deck'
,
"
#{
deck
[
'name'
]
}
.ydk"
)
if
(
!
File
.
file?
(
file
)
||
DateTime
.
parse
(
deck
[
'updated_at'
]).
to_time
>
File
.
mtime
(
file
))
open
(
file
,
'w'
)
{
|
f
|
main
=
[]
side
=
[]
deck
[
'cards'
].
each
{
|
card_usage
|
card_usage
[
'count'
].
times
{
(
card_usage
[
'side'
]
?
side
:
main
).
push
card_usage
[
'card_id'
]
}
}
f
.
puts
"#mycard deck sync
#{
deck
[
'user'
]
}
"
f
.
puts
"#main"
f
.
puts
main
.
join
(
"
\n
"
)
f
.
puts
"!side"
f
.
puts
side
.
join
(
"
\n
"
)
}
File
.
utime
(
Time
.
now
,
DateTime
.
parse
(
deck
[
'updated_at'
]).
to_time
,
file
)
end
if
DateTime
.
parse
(
deck
[
'updated_at'
]).
to_time
>=
File
.
mtime
(
file
)
just_updated
.
push
file
end
}
}
rescue
$log
.
error
(
'卡组下载'
)
{
[
$!
.
inspect
,
*
$!
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
Thread
.
new
{
watch
}
unless
@watching
@watching
=
true
Dir
.
glob
(
File
.
join
(
File
.
dirname
(
Ygocore
.
ygocore_path
),
'deck'
,
'*.ydk'
))
{
|
deck
|
next
if
just_updated
.
include?
deck
update
(
deck
)
}
Update
.
status
=
nil
}
end
def
watch
require
'fssm'
FSSM
.
monitor
(
File
.
join
(
File
.
dirname
(
Ygocore
.
ygocore_path
),
'deck'
),
'*.ydk'
)
do
update
{
|
base
,
relative
|
Deck_Sync
.
update
File
.
join
base
,
relative
}
delete
{
|
base
,
relative
|
Deck_Sync
.
delete
File
.
join
base
,
relative
}
create
{
|
base
,
relative
|
Deck_Sync
.
update
File
.
join
base
,
relative
}
end
end
def
update
(
deck
)
Update
.
status
=
"正在同步卡组:
#{
File
.
basename
(
deck
,
".ydk"
)
}
"
path
=
"/decks/?
#{
Deck
.
ygopro_deck_to_url_param
(
deck
)
}
&user=
#{
URI
.
escape
$game
.
user
.
id
.
bare
.
to_s
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
&updated_at=
#{
URI
.
escape
File
.
mtime
(
deck
).
to_datetime
.
iso8601
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
"
$log
.
info
(
"卡组上传"
)
{
path
}
req
=
Net
::
HTTP
::
Put
.
new
path
response
=
Net
::
HTTP
.
start
(
'my-card.in'
,
443
,
use_ssl:
true
)
{
|
http
|
http
.
request
(
req
)
}
Update
.
status
=
nil
end
def
delete
(
deck
)
Update
.
status
=
"正在同步卡组:
#{
File
.
basename
(
deck
,
".ydk"
)
}
"
path
=
"/decks/?name=
#{
URI
.
escape
File
.
basename
(
deck
,
".ydk"
),
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
&user=
#{
URI
.
escape
$game
.
user
.
id
.
bare
.
to_s
,
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
)
}
"
$log
.
info
(
"卡组删除"
)
{
path
}
req
=
Net
::
HTTP
::
Delete
.
new
path
response
=
Net
::
HTTP
.
start
(
'my-card.in'
,
443
,
use_ssl:
true
)
{
|
http
|
http
.
request
(
req
)
}
Update
.
status
=
nil
end
end
end
lib/scene_lobby.rb
View file @
f4622cef
...
...
@@ -15,6 +15,7 @@ class Scene_Lobby < Scene
require_relative
'window_lobbybuttons'
require_relative
'chatmessage'
require_relative
'scene_duel'
require_relative
'deck_sync'
attr_reader
:chat_window
def
start
...
...
@@ -29,6 +30,7 @@ class Scene_Lobby < Scene
@active_window
=
@roomlist
@chat_window
=
Window_Chat
.
new
(
313
,
$config
[
'screen'
][
'height'
]
-
225
,
698
,
212
)
@count
=
0
Deck_Sync
.
start
super
end
...
...
lib/update.rb
View file @
f4622cef
...
...
@@ -2,10 +2,11 @@
require
"fileutils"
require_relative
'card'
module
Update
Version
=
'1.
1.7
'
Version
=
'1.
2.0
'
URL
=
"https://my-card.in/mycard/update.json?version=
#{
Version
}
"
class
<<
self
attr_reader
:thumbnails
,
:images
,
:status
attr_reader
:thumbnails
,
:images
attr_accessor
:status
def
start
Dir
.
glob
(
"mycard-update-*-*.zip"
)
do
|
file
|
...
...
lib/window_deck.rb
View file @
f4622cef
...
...
@@ -165,7 +165,8 @@ class Window_Deck < Window_Scrollable
result
<<
key
[(
c
>>
i
*
6
)
&
0x3F
]
end
end
Dialog
.
web
"https://my-card.in/decks/new
#{
'.pdf'
if
index
[
1
]
==
:buy
}
?name=
#{
File
.
basename
(
@items
[
index
[
0
]],
".ydk"
)
}
&cards=
#{
result
}#{
'#share'
if
index
[
1
]
==
:share
}
"
require
'uri'
Dialog
.
web
"https://my-card.in/decks/new
#{
'.pdf'
if
index
[
1
]
==
:buy
}
?name=
#{
URI
.
escape
(
File
.
basename
(
@items
[
index
[
0
]],
".ydk"
),
Regexp
.
new
(
"[^
#{
URI
::
PATTERN
::
UNRESERVED
}
]"
))
}
&cards=
#{
result
}#{
'#share'
if
index
[
1
]
==
:share
}
"
when
:delete
require_relative
'widget_msgbox'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment