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
syntax_j
mycard
Commits
5f588e30
Commit
5f588e30
authored
May 26, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0.6.3 LP
0.6.4 快速启动(浏览器接口)
parent
88c8c5e4
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
120 additions
and
68 deletions
+120
-68
Rakefile
Rakefile
+1
-1
lib/dialog.rb
lib/dialog.rb
+3
-0
lib/main.rb
lib/main.rb
+66
-50
lib/quickstart.rb
lib/quickstart.rb
+15
-0
lib/scene_login.rb
lib/scene_login.rb
+0
-1
lib/update.rb
lib/update.rb
+1
-1
lib/window_host.rb
lib/window_host.rb
+11
-3
lib/window_lobbybuttons.rb
lib/window_lobbybuttons.rb
+1
-1
lib/ygocore/event.rb
lib/ygocore/event.rb
+1
-0
lib/ygocore/game.rb
lib/ygocore/game.rb
+14
-10
lib/ygocore/room.rb
lib/ygocore/room.rb
+7
-1
No files found.
Rakefile
View file @
5f588e30
...
...
@@ -24,7 +24,7 @@ end
spec
=
Gem
::
Specification
.
new
do
|
s
|
s
.
name
=
'mycard'
s
.
version
=
'0.6.
2
'
s
.
version
=
'0.6.
4
'
s
.
extra_rdoc_files
=
[
'README.txt'
,
'LICENSE.txt'
]
s
.
summary
=
'a card game'
s
.
description
=
s
.
summary
...
...
lib/dialog.rb
View file @
5f588e30
...
...
@@ -50,4 +50,7 @@ module Dialog
def
web
(
url
)
Shell
.
ShellExecute
url
end
def
uac
(
command
,
*
args
)
Shell
.
ShellExecute
File
.
expand_path
(
command
),
args
.
join
(
' '
),
Dir
.
pwd
,
"runas"
end
end
\ No newline at end of file
lib/main.rb
View file @
5f588e30
#!/usr/bin/env ruby
begin
#定义全局方法
def
load_config
(
file
=
"config.yml"
)
...
...
@@ -14,6 +13,16 @@ begin
def
save_config
(
file
=
"config.yml"
)
File
.
open
(
file
,
"w"
){
|
file
|
YAML
.
dump
(
$config
,
file
)}
end
def
register_url_protocol
if
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
require
'win32/registry'
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
unless
(
reg
[
'URL Protocol'
]
==
path
rescue
false
)}
Win32
::
Registry
::
HKEY_CLASSES_ROOT
.
create
(
'mycard\shell\open\command'
){
|
reg
|
reg
[
nil
]
=
command
unless
(
reg
[
nil
]
==
command
rescue
false
)}
end
end
Thread
.
abort_on_exception
=
true
require_relative
'announcement'
#读取配置文件
...
...
@@ -32,9 +41,15 @@ begin
log_level
.
replace
$1
when
/--profile=(.*)/
profile
=
$1
when
/mycard:.*/
require_relative
'quickstart'
$scene
=
false
when
/register_web_protocol/
register_url_protocol
$scene
=
false
end
end
unless
$scene
==
false
#初始化SDL
require
'sdl'
include
SDL
...
...
@@ -84,11 +99,12 @@ begin
Update
.
start
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"
){
"初始化成功"
}
end
rescue
Exception
=>
exception
open
(
'error-程序出错请到论坛反馈.txt'
,
'w'
){
|
f
|
f
.
write
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)}
exit
(
1
)
$scene
=
false
end
#主循环
...
...
@@ -106,5 +122,5 @@ ensure
Profiler__
::
print_profile
(
profile
)
profile
.
close
end
$log
.
close
$log
.
close
rescue
nil
end
\ No newline at end of file
lib/quickstart.rb
0 → 100644
View file @
5f588e30
require
'json'
require_relative
'game'
require_relative
'user'
require_relative
'room'
require_relative
'ygocore/game'
$game
=
Ygocore
.
new
args
=
JSON
.
parse
ARGV
.
first
[
7
,
ARGV
.
first
.
size
-
7
].
unpack
(
'm'
).
first
$game
.
user
=
User
.
new
(
args
[
"username"
].
to_sym
,
args
[
"username"
])
$game
.
password
=
args
[
"password"
]
$game
.
server
=
args
[
'server_ip'
]
$game
.
port
=
args
[
'server_port'
]
Ygocore
.
run_ygocore
Room
.
new
(
0
,
args
[
'room_name'
]),
true
\ No newline at end of file
lib/scene_login.rb
View file @
5f588e30
...
...
@@ -13,7 +13,6 @@ class Scene_Login < Scene
def
start
WM
::
set_caption
(
"MyCard v
#{
Update
::
Version
}
"
,
"MyCard"
)
@background
=
Surface
.
load
(
"graphics/login/background.png"
).
display_format
$config
[
'game'
]
=
'iDuel'
if
$config
[
'game'
]
==
'局域网'
#临时修补点击过一次局域网之后无限进入局域网的问题
@gameselect_window
=
Window_GameSelect
.
new
(
117
,
269
)
super
end
...
...
lib/update.rb
View file @
5f588e30
...
...
@@ -2,7 +2,7 @@ require 'open-uri'
require
"fileutils"
require_relative
'card'
module
Update
Version
=
'0.6.
2
'
Version
=
'0.6.
4
'
URL
=
"http://card.touhou.cc/mycard/update.json?version=
#{
Version
}
"
class
<<
self
attr_reader
:thumbnails
,
:images
,
:status
...
...
lib/window_host.rb
View file @
5f588e30
...
...
@@ -11,8 +11,9 @@ class Window_Host < Window
@color
=
[
0x04
,
0x47
,
0x7c
]
@roomname_inputbox
=
Widget_InputBox
.
new
(
@x
+
96
,
@y
+
41
,
165
,
WLH
)
@password_inputbox
=
Widget_InputBox
.
new
(
@x
+
96
,
@y
+
41
+
WLH
,
165
,
WLH
)
@lp_inputbox
=
Widget_InputBox
.
new
(
@x
+
96
,
@y
+
41
+
WLH
*
6
+
4
,
64
,
WLH
)
@pvp
=
Widget_Checkbox
.
new
(
self
,
33
+
@x
,
@y
+
41
+
WLH
*
2
,
120
,
24
,
false
,
"竞技场"
)
{
|
checked
|
(
@ocg
.
checked
=
true
;
@tcg
.
checked
=
@tag
.
checked
=
false
)
if
checked
}
@pvp
=
Widget_Checkbox
.
new
(
self
,
33
+
@x
,
@y
+
41
+
WLH
*
2
,
120
,
24
,
false
,
"竞技场"
)
{
|
checked
|
(
@ocg
.
checked
=
true
;
@tcg
.
checked
=
@tag
.
checked
=
false
;
@lp_inputbox
.
value
=
"8000"
)
if
checked
}
@pvp
.
background
=
@background
.
copy_rect
(
33
,
70
,
120
,
24
)
@match
=
Widget_Checkbox
.
new
(
self
,
120
+
@x
,
@y
+
41
+
WLH
*
2
,
120
,
24
,
true
,
"三回决斗"
){
|
checked
|
@tag
.
checked
=
false
if
checked
}
@match
.
background
=
@background
.
copy_rect
(
120
,
70
,
120
,
24
)
...
...
@@ -24,6 +25,7 @@ class Window_Host < Window
@tcg
.
background
=
@background
.
copy_rect
(
120
,
70
,
120
,
24
)
@roomname_inputbox
.
value
=
rand
(
1000
).
to_s
@lp_inputbox
.
value
=
8000
.
to_s
@password_inputbox
.
refresh
@pvp
.
refresh
@match
.
refresh
...
...
@@ -34,11 +36,12 @@ class Window_Host < Window
end
def
refresh
clear
@font
.
draw_blended_utf8
(
@contents
,
"
新房间"
,
(
@width
-
@font
.
text_size
(
"新
房间"
)[
0
])
/
2
,
2
,
*
@title_color
)
@font
.
draw_blended_utf8
(
@contents
,
"
建立房间"
,
(
@width
-
@font
.
text_size
(
"建立
房间"
)[
0
])
/
2
,
2
,
*
@title_color
)
@font
.
draw_blended_utf8
(
@contents
,
"房间名"
,
33
,
43
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
"房间密码"
,
33
,
43
+
WLH
,
*
@color
)
@contents
.
fill_rect
(
4
,
43
+
WLH
*
3
,
@contents
.
w
-
8
,
2
,
0xAA0A7AC5
)
@font
.
draw_blended_utf8
(
@contents
,
"自定义模式"
,
20
,
43
+
WLH
*
3
+
4
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
"初始LP"
,
33
,
44
+
WLH
*
6
+
4
,
*
@color
)
@items
.
each_key
do
|
index
|
draw_item
(
index
,
self
.
index
==
index
?
1
:
0
)
end
...
...
@@ -82,10 +85,12 @@ class Window_Host < Window
Widget_Msgbox
.
new
(
"建立房间"
,
"请输入房间名"
,
ok:
"确定"
)
elsif
!
name_check
Widget_Msgbox
.
new
(
"建立房间"
,
"房间名/房间密码超过长度上限"
,
ok:
"确定"
)
elsif
@lp_inputbox
.
value
.
to_i
>=
99999
Widget_Msgbox
.
new
(
"建立房间"
,
"初始LP超过上限"
,
ok:
"确定"
)
else
Widget_Msgbox
.
new
(
"建立房间"
,
"正在建立房间"
)
destroy
$game
.
host
(
@roomname_inputbox
.
value
,
password:
@password_inputbox
.
value
,
pvp:
@pvp
.
checked?
,
match:
@match
.
checked?
,
tag:
@tag
.
checked?
,
ot:
@tcg
.
checked?
?
@ocg
.
checked?
?
2
:
1
:
0
)
$game
.
host
(
@roomname_inputbox
.
value
,
password:
@password_inputbox
.
value
,
pvp:
@pvp
.
checked?
,
match:
@match
.
checked?
,
tag:
@tag
.
checked?
,
ot:
@tcg
.
checked?
?
@ocg
.
checked?
?
2
:
1
:
0
,
lp:
@lp_inputbox
.
value
.
to_i
)
end
when
:cancel
destroy
...
...
@@ -94,6 +99,7 @@ class Window_Host < Window
def
destroy
@roomname_inputbox
.
destroy
@password_inputbox
.
destroy
@lp_inputbox
.
destroy
@pvp
.
destroy
@match
.
destroy
@tag
.
destroy
...
...
@@ -104,6 +110,7 @@ class Window_Host < Window
def
update
@roomname_inputbox
.
update
@password_inputbox
.
update
@lp_inputbox
.
update
end
def
name_check
name
=
@roomname_inputbox
.
value
...
...
@@ -124,6 +131,7 @@ class Window_Host < Window
max
=
20
max
-=
1
if
name
.
ascii_only?
end
max
-=
@lp_inputbox
.
value
.
size
-
4
if
!
@password_inputbox
.
value
.
empty?
max
-=
1
max
-=
@password_inputbox
.
value
.
encode
(
"GBK"
).
bytesize
...
...
lib/window_lobbybuttons.rb
View file @
5f588e30
...
...
@@ -29,7 +29,7 @@ class Window_LobbyButtons < Window_List
case
@index
when
0
#常见问题
require_relative
'dialog'
Dialog
.
web
"http://card.touhou.cc/login?user[name]=
#{
CGI
.
escape
$game
.
username
}
&user[password]=
#{
CGI
.
escape
$game
.
password
}
&continue=/topics/1453"
Dialog
.
web
"http://card.touhou.cc/login?user[name]=
#{
CGI
.
escape
$game
.
user
.
name
}
&user[password]=
#{
CGI
.
escape
$game
.
password
}
&continue=/topics/1453"
when
1
#卡组编辑
$game
.
class
.
deck_edit
when
2
#建立房间
...
...
lib/ygocore/event.rb
View file @
5f588e30
...
...
@@ -48,6 +48,7 @@ class Game_Event
result
.
tag
=
room
[
:tag
]
result
.
ot
=
room
[
:ot
]
result
.
status
=
room
[
:status
]
result
.
lp
=
room
[
:lp
]
result
end
def
self
.
parse_user
(
user
)
...
...
lib/ygocore/game.rb
View file @
5f588e30
...
...
@@ -2,9 +2,10 @@
load
'lib/ygocore/window_login.rb'
require
'eventmachine'
require
'open-uri'
require
'yaml'
class
Ygocore
<
Game
attr_reader
:username
attr_
reade
r
:password
attr_
accesso
r
:password
@@config
=
YAML
.
load_file
(
"lib/ygocore/server.yml"
)
def
initialize
super
...
...
@@ -45,6 +46,7 @@ class Ygocore < Game
room
.
tag
=
room_config
[
:tag
]
room
.
password
=
room_config
[
:password
]
room
.
ot
=
room_config
[
:ot
]
room
.
lp
=
room_config
[
:lp
]
if
$game
.
rooms
.
any?
{
|
game_room
|
game_room
.
name
==
room_name
}
Widget_Msgbox
.
new
(
"建立房间"
,
"房间名已存在"
,
:ok
=>
"确定"
)
else
...
...
@@ -80,21 +82,26 @@ class Ygocore < Game
def
port
@@config
[
'port'
]
end
def
server
=
(
server
)
@@config
[
'server'
]
=
server
end
def
port
=
(
port
)
@@config
[
'port'
]
=
port
end
def
self
.
run_ygocore
(
option
,
image_downloading
=
false
)
if
!
image_downloading
and
!
Update
.
images
.
empty?
return
Widget_Msgbox
.
new
(
"加入房间"
,
"卡图正在下载中,可能显示不出部分卡图"
,
:ok
=>
"确定"
){
run_ygocore
(
option
,
true
)}
end
path
=
'ygocore/ygopro_vs.exe'
Widget_Msgbox
.
new
(
"ygocore"
,
"正在启动ygocore"
)
Widget_Msgbox
.
new
(
"ygocore"
,
"正在启动ygocore"
)
rescue
nil
#写入配置文件并运行ygocore
Dir
.
chdir
(
File
.
dirname
(
path
))
do
$log
.
info
(
'当前目录'
){
Dir
.
pwd
.
encode
(
"UTF-8"
)}
case
option
when
Room
room
=
option
room_name
=
if
room
.
ot
!=
0
room_name
=
if
room
.
ot
!=
0
or
room
.
lp
!=
8000
mode
=
case
when
room
.
match?
then
1
;
when
room
.
tag?
then
2
else
0
end
room_name
=
"
#{
room
.
ot
}#{
mode
}
FFF
8000
,5,1,
#{
room
.
name
}
"
room_name
=
"
#{
room
.
ot
}#{
mode
}
FFF
#{
room
.
lp
}
,5,1,
#{
room
.
name
}
"
elsif
room
.
tag?
"T#"
+
room
.
name
elsif
room
.
pvp?
and
room
.
match?
...
...
@@ -121,8 +128,6 @@ class Ygocore < Game
system_conf
[
'antialias'
]
=
2
system_conf
[
'textfont'
]
=
'c:/windows/fonts/simsun.ttc 14'
system_conf
[
'numfont'
]
=
'c:/windows/fonts/arialbd.ttf'
$log
.
error
(
'找不到system.conf'
)
$log
.
info
(
Dir
.
foreach
(
'.'
).
to_a
.
inspect
)
end
system_conf
[
'nickname'
]
=
"
#{
$game
.
user
.
name
}#{
"$"
unless
$game
.
password
.
nil?
or
$game
.
password
.
empty?
}#{
$game
.
password
}
"
system_conf
[
'lastip'
]
=
$game
.
server
...
...
@@ -135,11 +140,10 @@ class Ygocore < Game
when
:deck
args
=
'-d'
end
$log
.
info
(
'ygocore参数'
)
{
args
}
IO
.
popen
(
"ygopro_vs.exe
#{
args
}
"
)
WM
.
iconify
WM
.
iconify
rescue
nil
end
Widget_Msgbox
.
destroy
Widget_Msgbox
.
destroy
rescue
nil
end
def
self
.
deck_edit
Widget_Msgbox
.
new
(
"编辑卡组"
,
"
\"
导入
\"
导入已有卡组,
\"
编辑
\"
启动ygocore"
,
:import
=>
"导入"
,
:edit
=>
"编辑"
)
do
|
button
|
...
...
lib/ygocore/room.rb
View file @
5f588e30
...
...
@@ -3,11 +3,14 @@ class Room
attr_accessor
:match
attr_accessor
:tag
attr_accessor
:ot
attr_accessor
:lp
attr_accessor
:status
alias
pvp?
pvp
alias
match?
match
alias
tag?
tag
def
lp
@lp
||=
8000
end
def
ot
@ot
||=
0
end
...
...
@@ -29,6 +32,9 @@ class Room
elsif
ot
==
2
result
[
"[O/T混]"
]
=
[
255
,
0
,
0
]
end
if
lp
!=
8000
result
[
"[LP:
#{
lp
}
]"
]
=
[
255
,
0
,
0
]
end
result
end
end
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