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
8b973851
Commit
8b973851
authored
Jun 05, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OS数据库更新至0530, OS卡组导入ygocore
parent
4f13bad6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
178 additions
and
129 deletions
+178
-129
data/data.sqlite
data/data.sqlite
+0
-0
lib/deck.rb
lib/deck.rb
+2
-4
lib/scene_title.rb
lib/scene_title.rb
+1
-0
lib/window_lobbybuttons.rb
lib/window_lobbybuttons.rb
+49
-42
lib/ygocore/game.rb
lib/ygocore/game.rb
+126
-83
No files found.
data/data.sqlite
View file @
8b973851
No preview for this file type
lib/deck.rb
View file @
8b973851
...
...
@@ -4,14 +4,12 @@
#------------------------------------------------------------------------------
# title
#==============================================================================
require_relative
'card'
class
Deck
attr_accessor
:main
attr_accessor
:side
attr_accessor
:extra
attr_accessor
:temp
#DeckPath = '/media/44CACC1DCACC0D5C/game/yu-gi-oh/deck'
DeckPath
=
'E:/game/yu-gi-oh/deck'
def
initialize
(
main
,
side
=
[],
extra
=
[],
temp
=
[])
@main
=
main
@side
=
side
...
...
@@ -24,7 +22,7 @@ class Deck
extra
=
[]
temp
=
[]
now
=
main
open
(
File
.
expand_path
(
name
,
DeckPath
)
)
do
|
file
|
open
(
name
)
do
|
file
|
file
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
while
line
=
file
.
readline
.
chomp!
case
line
...
...
lib/scene_title.rb
View file @
8b973851
...
...
@@ -37,6 +37,7 @@ class Scene_Title < Scene
when
2
require_relative
'widget_msgbox'
require_relative
'scene_login'
require_relative
'deck'
load
'lib/ygocore/game.rb'
#TODO:不规范啊不规范
Ygocore
.
deck_edit
when
3
...
...
lib/window_lobbybuttons.rb
View file @
8b973851
require_relative
'window_host'
class
Window_LobbyButtons
<
Window_List
def
initialize
(
x
,
y
)
@items
=
[
"常见问题"
,
"卡组编辑"
,
"建立房间"
]
def
initialize
(
x
,
y
)
@items
=
[
"常见问题"
,
"卡组编辑"
,
"建立房间"
]
@button
=
Surface
.
load
(
"graphics/lobby/button.png"
)
super
(
x
,
y
,
@items
.
size
*
@button
.
w
/
3
+
@items
.
size
*
4
,
30
)
super
(
x
,
y
,
@items
.
size
*
@button
.
w
/
3
+
@items
.
size
*
4
,
30
)
@font
=
TTF
.
open
(
"fonts/wqy-microhei.ttc"
,
15
)
refresh
end
def
draw_item
(
index
,
status
=
0
)
x
,
y
=
item_rect
(
index
)
Surface
.
blit
(
@button
,
status
*
@button
.
w
/
3
,
0
,
@button
.
w
/
3
,
@button
.
h
,
@contents
,
x
,
y
)
draw_stroked_text
(
@items
[
index
],
x
+
8
,
y
+
3
,
2
,
@font
,[
0xdf
,
0xf1
,
0xff
],
[
0x27
,
0x43
,
0x59
])
x
,
y
=
item_rect
(
index
)
Surface
.
blit
(
@button
,
status
*
@button
.
w
/
3
,
0
,
@button
.
w
/
3
,
@button
.
h
,
@contents
,
x
,
y
)
draw_stroked_text
(
@items
[
index
],
x
+
8
,
y
+
3
,
2
,
@font
,
[
0xdf
,
0xf1
,
0xff
],
[
0x27
,
0x43
,
0x59
])
end
def
item_rect
(
index
)
[
index
*
@button
.
w
/
3
+
(
index
)
*
4
,
0
,
@button
.
w
/
3
,
@height
]
end
def
mousemoved
(
x
,
y
)
def
mousemoved
(
x
,
y
)
if
(
x
-
@x
)
%
(
@button
.
w
/
3
+
4
)
>=
@button
.
w
/
3
self
.
index
=
nil
else
self
.
index
=
(
x
-
@x
)
/
(
@button
.
w
/
3
+
4
)
end
end
def
lostfocus
(
active_window
=
nil
)
self
.
index
=
nil
end
def
clicked
case
@index
when
0
#常见问题
require_relative
'dialog'
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
#卡组编辑
require_relative
'deck'
$game
.
class
.
deck_edit
when
2
#建立房间
@host_window
=
Window_Host
.
new
(
300
,
200
)
@host_window
=
Window_Host
.
new
(
300
,
200
)
end
end
def
update
@host_window
.
update
if
@host_window
and
!
@host_window
.
destroyed?
end
...
...
lib/ygocore/game.rb
View file @
8b973851
...
...
@@ -7,6 +7,7 @@ class Ygocore < Game
attr_reader
:username
attr_accessor
:password
@@config
=
YAML
.
load_file
(
"lib/ygocore/server.yml"
)
def
initialize
super
load
'lib/ygocore/event.rb'
...
...
@@ -15,14 +16,17 @@ class Ygocore < Game
load
'lib/ygocore/scene_lobby.rb'
require
'json'
end
def
refresh_interval
60
end
def
login
(
username
,
password
)
@username
=
username
@password
=
password
connect
end
def
connect
@recv
=
Thread
.
new
do
EventMachine
::
run
{
...
...
@@ -30,6 +34,7 @@ class Ygocore < Game
}
end
end
def
chat
(
chatmessage
)
case
chatmessage
.
channel
when
:lobby
...
...
@@ -39,6 +44,7 @@ class Ygocore < Game
end
end
def
host
(
room_name
,
room_config
)
room
=
Room
.
new
(
0
,
room_name
)
room
.
pvp
=
room_config
[
:pvp
]
...
...
@@ -47,50 +53,62 @@ class Ygocore < Game
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
}
if
$game
.
rooms
.
any?
{
|
game_room
|
game_room
.
name
==
room_name
}
Widget_Msgbox
.
new
(
"建立房间"
,
"房间名已存在"
,
:ok
=>
"确定"
)
else
Game_Event
.
push
Game_Event
::
Join
.
new
(
room
)
end
end
def
watch
(
room
)
Widget_Msgbox
.
new
(
"加入房间"
,
"游戏已经开始"
,
:ok
=>
"确定"
)
end
def
join
(
room
)
Game_Event
.
push
Game_Event
::
Join
.
new
(
room
)
end
def
refresh
send
(
:refresh
)
end
def
send
(
header
,
data
=
nil
)
$log
.
info
(
'发送消息'
)
{
{
header:
header
,
data:
data
}}
$log
.
info
(
'发送消息'
)
{
{
header:
header
,
data:
data
}
}
Client
::
MycardChannel
.
push
header:
header
,
data:
data
end
def
exit
@recv
.
exit
if
@recv
@recv
=
nil
end
def
ygocore_path
"ygocore/ygopro_vs.exe"
end
def
self
.
register
Dialog
.
web
@@config
[
'register'
]
end
def
server
@@config
[
'server'
]
end
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
)
}
return
Widget_Msgbox
.
new
(
"加入房间"
,
"卡图正在下载中,可能显示不出部分卡图"
,
:ok
=>
"确定"
)
{
run_ygocore
(
option
,
true
)
}
end
path
=
'ygocore/ygopro_vs.exe'
Widget_Msgbox
.
new
(
"ygocore"
,
"正在启动ygocore"
)
rescue
nil
...
...
@@ -100,7 +118,12 @@ class Ygocore < Game
when
Room
room
=
option
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
mode
=
case
when
room
.
match?
then
1
;
when
room
.
tag?
then
2
else
0
end
room_name
=
"
#{
room
.
ot
}#{
mode
}
FFF
#{
room
.
lp
}
,5,1,
#{
room
.
name
}
"
elsif
room
.
tag?
"T#"
+
room
.
name
...
...
@@ -120,8 +143,8 @@ class Ygocore < Game
begin
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
line
.
force_encoding
"UTF-8"
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
system_conf
[
field
]
=
contents
end
rescue
...
...
@@ -133,7 +156,7 @@ class Ygocore < Game
system_conf
[
'lastip'
]
=
$game
.
server
system_conf
[
'lastport'
]
=
$game
.
port
.
to_s
system_conf
[
'roompass'
]
=
room_name
open
(
'system.conf'
,
'w'
)
{
|
file
|
file
.
write
system_conf
.
collect
{
|
key
,
value
|
"
#{
key
}
=
#{
value
}
"
}.
join
(
"
\n
"
)
}
open
(
'system.conf'
,
'w'
)
{
|
file
|
file
.
write
system_conf
.
collect
{
|
key
,
value
|
"
#{
key
}
=
#{
value
}
"
}.
join
(
"
\n
"
)
}
args
=
'-j'
when
:replay
args
=
'-r'
...
...
@@ -144,8 +167,8 @@ class Ygocore < Game
begin
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
line
.
force_encoding
"UTF-8"
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
system_conf
[
field
]
=
contents
end
rescue
...
...
@@ -154,7 +177,7 @@ class Ygocore < Game
system_conf
[
'numfont'
]
=
'c:/windows/fonts/arialbd.ttf'
end
system_conf
[
'lastdeck'
]
=
option
open
(
'system.conf'
,
'w'
)
{
|
file
|
file
.
write
system_conf
.
collect
{
|
key
,
value
|
"
#{
key
}
=
#{
value
}
"
}.
join
(
"
\n
"
)
}
open
(
'system.conf'
,
'w'
)
{
|
file
|
file
.
write
system_conf
.
collect
{
|
key
,
value
|
"
#{
key
}
=
#{
value
}
"
}.
join
(
"
\n
"
)
}
args
=
'-d'
end
IO
.
popen
(
"ygopro_vs.exe
#{
args
}
"
)
...
...
@@ -162,31 +185,47 @@ class Ygocore < Game
end
Widget_Msgbox
.
destroy
rescue
nil
end
def
self
.
deck_edit
Widget_Msgbox
.
new
(
"编辑卡组"
,
"
\"
导入
\"
导入已有卡组,
\"
编辑
\"
启动ygocore"
,
:import
=>
"导入"
,
:edit
=>
"编辑"
)
do
|
button
|
case
button
when
:import
file
=
Dialog
.
get_open_file
(
"导入卡组"
,
"ygocore卡组 (*.ydk)"
=>
"*.ydk"
)
#"所有支持的卡组 (*.txt;*.deck;*.ydk)"=>"*.ydk;*.txt;*.deck","ygocore卡组 (*.ydk)"=>"*.ydk", "NBX/iDuel/狐查卡组 (*.txt)" => "*.txt", "图形组卡器卡组 (*.deck)"=>"*.dec
k")
when
:import
file
=
Dialog
.
get_open_file
(
"导入卡组"
,
"所有支持的卡组 (*.txt;*.deck;*.ydk)"
=>
"*.ydk;*.txt;*.deck"
,
"OcgSoft卡组 (*.txt;*.deck)"
=>
"*.txt;*.deck"
,
"ygocore卡组 (*.ydk)"
=>
"*.yd
k"
)
if
!
file
.
empty?
open
(
file
)
do
|
src
|
#fix for stdlib File.extname
file
=~
/(\.deck|\.txt|\.yrp)$/i
extname
=
$1
Dir
.
mkdir
"ygocore/deck"
unless
File
.
directory?
(
"ygocore/deck"
)
open
(
"ygocore/deck/
#{
File
.
basename
(
file
)
}
"
,
'w'
)
do
|
dest
|
open
(
"ygocore/deck/
#{
File
.
basename
(
file
,
extname
)
+
".ydk"
}
"
,
'w'
)
do
|
dest
|
if
file
=~
/(\.deck|\.txt)$/
deck
=
Deck
.
load
(
file
)
dest
.
puts
(
"#main"
)
deck
.
main
.
each
{
|
card
|
dest
.
puts
card
.
number
}
dest
.
puts
(
"#extra"
)
deck
.
extra
.
each
{
|
card
|
dest
.
puts
card
.
number
}
dest
.
pust
(
"!side"
)
deck
.
side
.
each
{
|
card
|
dest
.
puts
card
.
number
}
else
open
(
file
)
do
|
src
|
dest
.
write
src
.
read
end
Widget_Msgbox
.
new
(
"导入卡组"
,
"导入卡组完成"
,
:ok
=>
"确定"
)
end
end
rescue
Widget_Msgbox
.
new
(
"导入卡组"
,
"导入卡组失败"
,
:ok
=>
"确定"
)
Ygocore
.
run_ygocore
(
File
.
basename
(
file
,
extname
))
end
when
:edit
Ygocore
.
run_ygocore
(
:deck
)
end
end
end
def
self
.
replay
(
file
,
skip_image_downloading
=
false
)
require
'fileutils'
FileUtils
.
mv
Dir
.
glob
(
'ygocore/replay/*.yrp'
),
'replay/'
FileUtils
.
copy_file
(
file
,
"ygocore/replay/
#{
File
.
basename
(
file
)
}
"
)
run_ygocore
(
:replay
,
skip_image_downloading
)
end
private
def
self
.
get_announcements
...
...
@@ -198,28 +237,32 @@ class Ygocore < Game
open
(
@@config
[
'api'
])
do
|
file
|
file
.
set_encoding
"GBK"
announcements
=
[]
file
.
read
.
encode
(
"UTF-8"
).
scan
(
/<div style="color:red" >公告:(.*?)<\/div>/
).
each
do
|
title
,
others
|
file
.
read
.
encode
(
"UTF-8"
).
scan
(
/<div style="color:red" >公告:(.*?)<\/div>/
).
each
do
|
title
,
others
|
announcements
<<
Announcement
.
new
(
title
,
@@config
[
'index'
],
nil
)
end
$config
[
'ygocore'
][
'announcements'
].
replace
announcements
save_config
end
rescue
Exception
=>
exception
$log
.
error
(
'公告读取失败'
)
{[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
encode
(
"UTF-8"
)}.
join
(
"
\n
"
)
}
$log
.
error
(
'公告读取失败'
)
{
[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
encode
(
"UTF-8"
)
}.
join
(
"
\n
"
)
}
end
end
end
module
Client
MycardChannel
=
EM
::
Channel
.
new
include
EM
::
P
::
ObjectProtocol
def
post_init
send_object
header: :login
,
data:
{
name:
$game
.
username
,
password:
$game
.
password
}
MycardChannel
.
subscribe
{
|
msg
|
send_object
(
msg
)
}
MycardChannel
.
subscribe
{
|
msg
|
send_object
(
msg
)
}
end
def
receive_object
obj
$log
.
info
(
'收到消息'
)
{
obj
.
inspect
}
$log
.
info
(
'收到消息'
)
{
obj
.
inspect
}
Game_Event
.
push
Game_Event
.
parse
obj
[
:header
],
obj
[
:data
]
end
def
unbind
Game_Event
.
push
Game_Event
::
Error
.
new
(
'ygocore'
,
'网络连接中断'
,
true
)
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