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
194e405d
Commit
194e405d
authored
Jun 07, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0.7.0
parent
bf1cafa6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
58 deletions
+89
-58
lib/card.rb
lib/card.rb
+8
-9
lib/main.rb
lib/main.rb
+32
-24
lib/quickstart.rb
lib/quickstart.rb
+46
-25
lib/window_deck.rb
lib/window_deck.rb
+3
-0
No files found.
lib/card.rb
View file @
194e405d
...
...
@@ -15,11 +15,10 @@ class Card
else
''
#其他操作系统卡图存放位置标准尚未制定。
end
CardBack
=
Surface
.
load
(
"graphics/field/card.jpg"
).
display_format
CardBack_Small
=
Surface
.
load
(
"graphics/field/card_small.gif"
).
display_format
CardBack
=
Surface
.
load
(
"graphics/field/card.jpg"
).
display_format
rescue
nil
CardBack_Small
=
Surface
.
load
(
"graphics/field/card_small.gif"
).
display_format
rescue
nil
class
<<
self
def
find
(
id
,
order_by
=
nil
)
$log
.
debug
(
'查找卡片'
){
id
.
inspect
}
case
id
when
Integer
@all
[
id
]
||
old_new
(
@db
.
get_first_row
(
"select * from `yu-gi-oh` where id =
#{
id
}
"
))
...
...
@@ -64,7 +63,7 @@ class Card
stats
=
records
.
GetRows
.
first
stats
.
unshift
nil
records
.
close
records
=
WIN32OLE
.
new
(
'ADODB.Recordset'
)
records
.
open
(
"YGODATA"
,
conn
)
records
.
MoveNext
#跳过首行那个空白卡
...
...
@@ -154,7 +153,7 @@ class Card
@mediums
=
hash
[
'mediums'
].
split
(
"
\t
"
).
collect
{
|
medium
|
medium
.
to_sym
}
@tokens
=
hash
[
'tokens'
].
to_i
@token
=
hash
[
'token'
]
Card
.
cache
[
@id
]
=
self
end
def
create_image
...
...
@@ -178,16 +177,16 @@ class Card
@id
==
1
end
def
monster?
[:
融合怪兽
,
:
同调怪兽
,
:
超量怪兽
,
:
通常怪兽
,
:
效果怪兽
,
:
调整怪兽
,
:
仪式怪兽
].
include?
card_type
[:
融合怪兽
,
:
同调怪兽
,
:
超量怪兽
,
:
通常怪兽
,
:
效果怪兽
,
:
调整怪兽
,
:
仪式怪兽
].
include?
card_type
end
def
trap?
[:
通常陷阱
,
:
反击陷阱
,
:
永续陷阱
].
include?
card_type
[:
通常陷阱
,
:
反击陷阱
,
:
永续陷阱
].
include?
card_type
end
def
spell?
[:
通常魔法
,
:
速攻魔法
,
:
装备魔法
,
:
场地魔法
,
:
仪式魔法
,
:
永续魔法
].
include?
card_type
[:
通常魔法
,
:
速攻魔法
,
:
装备魔法
,
:
场地魔法
,
:
仪式魔法
,
:
永续魔法
].
include?
card_type
end
def
extra?
[:
融合怪兽
,
:
同调怪兽
,
:
超量怪兽
].
include?
card_type
[:
融合怪兽
,
:
同调怪兽
,
:
超量怪兽
].
include?
card_type
end
def
token?
@token
...
...
lib/main.rb
View file @
194e405d
...
...
@@ -10,8 +10,9 @@ begin
$config
[
'screen'
][
'width'
]
||=
1024
$config
[
'screen'
][
'height'
]
||=
768
end
def
save_config
(
file
=
"config.yml"
)
File
.
open
(
file
,
"w"
){
|
file
|
YAML
.
dump
(
$config
,
file
)
}
File
.
open
(
file
,
"w"
)
{
|
file
|
YAML
.
dump
(
$config
,
file
)
}
end
def
register_url_protocol
if
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
...
...
@@ -19,34 +20,41 @@ begin
pwd
=
Dir
.
pwd
.
gsub
(
'/'
,
'\\'
)
path
=
'"'
+
pwd
+
'\ruby\bin\rubyw.exe" -C"'
+
pwd
+
'" -KU lib/main.rb'
command
=
path
+
' "%1"'
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard'
){
|
reg
|
reg
[
'URL Protocol'
]
=
path
.
ljust
path
.
bytesize
unless
(
reg
[
'URL Protocol'
]
==
path
rescue
false
)}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard\shell\open\command'
){
|
reg
|
reg
[
nil
]
=
command
.
ljust
command
.
bytesize
unless
(
reg
[
nil
]
==
command
rescue
false
)}
icon
=
'"'
+
pwd
+
'\mycard.exe", 0'
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard'
)
{
|
reg
|
reg
[
'URL Protocol'
]
=
path
.
ljust
path
.
bytesize
unless
(
reg
[
'URL Protocol'
]
==
path
rescue
false
)
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard\shell\open\command'
)
{
|
reg
|
reg
[
nil
]
=
command
.
ljust
command
.
bytesize
unless
(
reg
[
nil
]
==
command
rescue
false
)
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard\DefaultIcon'
)
{
|
reg
|
reg
[
nil
]
=
icon
.
ljust
icon
.
bytesize
unless
(
reg
[
nil
]
==
icon
rescue
false
)
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'.ydk'
)
{
|
reg
|
reg
[
nil
]
=
'mycard'
unless
(
reg
[
nil
]
==
'mycard'
rescue
false
)
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'.yrp'
)
{
|
reg
|
reg
[
nil
]
=
'mycard'
unless
(
reg
[
nil
]
==
'mycard'
rescue
false
)
}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'.deck'
)
{
|
reg
|
reg
[
nil
]
=
'mycard'
unless
(
reg
[
nil
]
==
'mycard'
rescue
false
)
}
end
end
Thread
.
abort_on_exception
=
true
require_relative
'announcement'
#读取配置文件
load_config
save_config
#读取命令行参数
log
=
"log.log"
log_level
=
"INFO"
profile
=
nil
ARGV
.
each
do
|
arg
|
case
arg
.
dup
.
force_encoding
(
"UTF-8"
)
when
/--log=(.*)/
log
.
replace
$1
when
/--log-level=(.*)/
log_level
.
replace
$1
when
/--profile=(.*)/
profile
=
$1
when
/mycard:.*/
require_relative
'quickstart'
$scene
=
false
when
/register_web_protocol/
register_url_protocol
$scene
=
false
arg
=
arg
.
dup
.
force_encoding
(
"UTF-8"
)
arg
.
force_encoding
(
"GBK"
)
unless
arg
.
valid_encoding?
case
arg
when
/--log=(.*)/
log
.
replace
$1
when
/--log-level=(.*)/
log_level
.
replace
$1
when
/--profile=(.*)/
profile
=
$1
when
/^mycard:.*|\.ydk$|\.yrp$|\.deck$/
require_relative
'quickstart'
$scene
=
false
when
/register_web_protocol/
register_url_protocol
$scene
=
false
end
end
unless
$scene
==
false
...
...
@@ -61,7 +69,7 @@ begin
WM
::
set_caption
(
"MyCard"
,
"MyCard"
)
WM
::
icon
=
Surface
.
load
(
"graphics/system/icon.gif"
)
$screen
=
Screen
.
open
(
$config
[
'screen'
][
'width'
],
$config
[
'screen'
][
'height'
],
0
,
HWSURFACE
|
(
$config
[
'screen'
][
'fullscreen'
]
?
FULLSCREEN
:
0
))
Mixer
.
open
(
Mixer
::
DEFAULT_FREQUENCY
,
Mixer
::
DEFAULT_FORMAT
,
Mixer
::
DEFAULT_CHANNELS
,
1024
)
Mixer
.
open
(
Mixer
::
DEFAULT_FREQUENCY
,
Mixer
::
DEFAULT_FORMAT
,
Mixer
::
DEFAULT_CHANNELS
,
1024
)
Mixer
.
set_volume_music
(
60
)
TTF
.
init
Thread
.
abort_on_exception
=
true
...
...
@@ -82,8 +90,8 @@ begin
end
require
'profiler'
RubyVM
::
InstructionSequence
.
compile_option
=
{
:trace_instruction
=>
true
,
:specialized_instruction
=>
false
:trace_instruction
=>
true
,
:specialized_instruction
=>
false
}
Profiler__
::
start_profile
end
...
...
@@ -99,10 +107,10 @@ begin
WM
::
set_caption
(
"MyCard v
#{
Update
::
Version
}
"
,
"MyCard"
)
require_relative
'dialog'
register_url_protocol
rescue
Dialog
.
uac
(
"ruby/bin/rubyw.exe"
,
"-KU lib/main.rb register_web_protocol"
)
$log
.
info
(
"main"
)
{
"初始化成功"
}
$log
.
info
(
"main"
)
{
"初始化成功"
}
end
rescue
Exception
=>
exception
open
(
'error-程序出错请到论坛反馈.txt'
,
'w'
)
{
|
f
|
f
.
write
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
}
open
(
'error-程序出错请到论坛反馈.txt'
,
'w'
)
{
|
f
|
f
.
write
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
}
$scene
=
false
end
...
...
@@ -110,8 +118,8 @@ end
begin
$scene
.
main
while
$scene
rescue
Exception
=>
exception
exception
.
backtrace
.
each
{
|
backtrace
|
break
if
backtrace
=~
/^(.*)\.rb:\d+:in `.*'"$/
}
#由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log
.
fatal
(
$1
)
{[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)}.
join
(
"
\n
"
)
}
exception
.
backtrace
.
each
{
|
backtrace
|
break
if
backtrace
=~
/^(.*)\.rb:\d+:in `.*'"$/
}
#由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log
.
fatal
(
$1
)
{
[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
$game
.
exit
if
$game
require_relative
'scene_error'
$scene
=
Scene_Error
.
new
...
...
lib/quickstart.rb
View file @
194e405d
...
...
@@ -4,31 +4,52 @@ require_relative 'room'
require_relative
'ygocore/game'
$game
=
Ygocore
.
new
uri
=
URI
.
unescape
URI
.
unescape
ARGV
.
first
[
9
,
ARGV
.
first
.
size
-
9
]
case
uri
when
/^(.*\.yrp)$/
require
'open-uri'
open
(
"http://"
+
URI
.
escape
(
$1
),
'rb'
)
{
|
src
|
if
ARGV
.
first
[
0
,
9
]
==
'mycard://'
file
=
URI
.
unescape
URI
.
unescape
ARGV
.
first
[
9
,
ARGV
.
first
.
size
-
9
]
uri
=
"http://"
+
URI
.
escape
(
file
)
else
file
=
ARGV
.
first
.
dup
.
force_encoding
(
"UTF-8"
)
file
.
force_encoding
(
"GBK"
)
unless
file
.
valid_encoding?
file
.
encode!
(
"UTF-8"
)
uri
=
file
end
case
file
when
/^(.*\.yrp)$/i
require
'open-uri'
#fix File.basename
$1
=~
/(.*)(?:\\|\/)(.*?\.yrp)/
src
=
open
(
uri
,
'rb'
)
{
|
src
|
src
.
read
}
Dir
.
mkdir
(
"replay"
)
unless
File
.
directory?
(
"replay"
)
open
(
'replay/'
+
File
.
basename
(
$1
),
'wb'
){
|
dest
|
dest
.
write
src
.
read
}
}
Ygocore
.
replay
(
'replay/'
+
File
.
basename
(
$1
),
true
)
when
/^(.*\.ydk)$/
require
'open-uri'
open
(
"http://"
+
URI
.
escape
(
$1
),
'rb'
)
{
|
src
|
open
(
'replay/'
+
$2
,
'wb'
)
{
|
dest
|
dest
.
write
src
}
Ygocore
.
replay
(
'replay/'
+
$2
,
true
)
when
/^(.*\.ydk)$/i
require
'open-uri'
#fix File.basename
$1
=~
/(.*)(?:\\|\/)(.*?)\.ydk/
src
=
open
(
uri
,
'rb'
)
{
|
src
|
src
.
read
}
Dir
.
mkdir
(
'ygocore/deck'
)
unless
File
.
directory?
(
"ygocore/deck"
)
open
(
'ygocore/deck/'
+
File
.
basename
(
$1
),
'wb'
){
|
dest
|
dest
.
write
src
.
read
}
}
Ygocore
.
run_ygocore
(
File
.
basename
(
$1
,
'.ydk'
),
true
)
when
/^(?:(.*)\:(.*)\@)?(.*)\:(\d+)\/(.*)$/
require
'uri'
$game
.
user
=
User
.
new
(
$1
.
to_sym
,
$1
)
if
$1
$game
.
password
=
$2
if
$2
$game
.
server
=
$3
$game
.
port
=
$4
.
to_i
Ygocore
.
run_ygocore
Room
.
new
(
0
,
$5
),
true
open
(
'ygocore/deck/'
+
$2
+
'.ydk'
,
'wb'
)
{
|
dest
|
dest
.
write
src
}
Ygocore
.
run_ygocore
(
$2
,
true
)
when
/^(.*)(\.txt|\.deck)$/i
require_relative
'deck'
d
=
$1
deck
=
Deck
.
load
(
$&
)
Dir
.
mkdir
(
'ygocore/deck'
)
unless
File
.
directory?
(
"ygocore/deck"
)
d
=~
/^(.*)(?:\\|\/)(.*?)$/
open
(
'ygocore/deck/'
+
$2
+
'.ydk'
,
'w'
)
do
|
dest
|
dest
.
puts
(
"#main"
)
deck
.
main
.
each
{
|
card
|
dest
.
puts
card
.
number
}
dest
.
puts
(
"#extra"
)
deck
.
extra
.
each
{
|
card
|
dest
.
puts
card
.
number
}
dest
.
puts
(
"!side"
)
deck
.
side
.
each
{
|
card
|
dest
.
puts
card
.
number
}
end
Ygocore
.
run_ygocore
(
$2
,
true
)
when
/^(?:(.*)\:(.*)\@)?(.*)\:(\d+)\/(.*)$/
require
'uri'
$game
.
user
=
User
.
new
(
$1
.
to_sym
,
$1
)
if
$1
$game
.
password
=
$2
if
$2
$game
.
server
=
$3
$game
.
port
=
$4
.
to_i
Ygocore
.
run_ygocore
Room
.
new
(
0
,
$5
),
true
end
\ No newline at end of file
lib/window_deck.rb
View file @
194e405d
...
...
@@ -3,6 +3,7 @@ class Window_Deck < Window
def
initialize
@items
=
Dir
.
glob
(
"ygocore/deck/*.ydk"
)[
0
,
10
]
p
@items
@background
=
Surface
.
load
(
@items
.
size
>
4
?
'graphics/lobby/host.png'
:
'graphics/system/msgbox.png'
).
display_format
super
((
1024
-
@background
.
w
)
/
2
,
230
,
@background
.
w
,
@background
.
h
,
300
)
...
...
@@ -61,6 +62,8 @@ class Window_Deck < Window
i
=
(
x
-
@x
-
(
@width
-
@items_buttons
.
size
*
@items_button
.
w
/
3
))
/
(
@items_button
.
w
/
3
)
if
i
>=
0
new_index
=
[
line
,
@items_buttons
.
keys
[
i
]]
else
new_index
=
[
line
,
:edit
]
end
else
@buttons_pos
.
each_key
do
|
index
|
...
...
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