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 @@
...
@@ -4,14 +4,12 @@
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# title
# title
#==============================================================================
#==============================================================================
require_relative
'card'
class
Deck
class
Deck
attr_accessor
:main
attr_accessor
:main
attr_accessor
:side
attr_accessor
:side
attr_accessor
:extra
attr_accessor
:extra
attr_accessor
:temp
attr_accessor
:temp
#DeckPath = '/media/44CACC1DCACC0D5C/game/yu-gi-oh/deck'
DeckPath
=
'E:/game/yu-gi-oh/deck'
def
initialize
(
main
,
side
=
[],
extra
=
[],
temp
=
[])
def
initialize
(
main
,
side
=
[],
extra
=
[],
temp
=
[])
@main
=
main
@main
=
main
@side
=
side
@side
=
side
...
@@ -24,7 +22,7 @@ class Deck
...
@@ -24,7 +22,7 @@ class Deck
extra
=
[]
extra
=
[]
temp
=
[]
temp
=
[]
now
=
main
now
=
main
open
(
File
.
expand_path
(
name
,
DeckPath
)
)
do
|
file
|
open
(
name
)
do
|
file
|
file
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
file
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
while
line
=
file
.
readline
.
chomp!
while
line
=
file
.
readline
.
chomp!
case
line
case
line
...
...
lib/scene_title.rb
View file @
8b973851
...
@@ -37,6 +37,7 @@ class Scene_Title < Scene
...
@@ -37,6 +37,7 @@ class Scene_Title < Scene
when
2
when
2
require_relative
'widget_msgbox'
require_relative
'widget_msgbox'
require_relative
'scene_login'
require_relative
'scene_login'
require_relative
'deck'
load
'lib/ygocore/game.rb'
#TODO:不规范啊不规范
load
'lib/ygocore/game.rb'
#TODO:不规范啊不规范
Ygocore
.
deck_edit
Ygocore
.
deck_edit
when
3
when
3
...
...
lib/window_lobbybuttons.rb
View file @
8b973851
require_relative
'window_host'
require_relative
'window_host'
class
Window_LobbyButtons
<
Window_List
class
Window_LobbyButtons
<
Window_List
def
initialize
(
x
,
y
)
def
initialize
(
x
,
y
)
@items
=
[
"常见问题"
,
"卡组编辑"
,
"建立房间"
]
@items
=
[
"常见问题"
,
"卡组编辑"
,
"建立房间"
]
@button
=
Surface
.
load
(
"graphics/lobby/button.png"
)
@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
)
@font
=
TTF
.
open
(
"fonts/wqy-microhei.ttc"
,
15
)
refresh
refresh
end
end
def
draw_item
(
index
,
status
=
0
)
def
draw_item
(
index
,
status
=
0
)
x
,
y
=
item_rect
(
index
)
x
,
y
=
item_rect
(
index
)
Surface
.
blit
(
@button
,
status
*
@button
.
w
/
3
,
0
,
@button
.
w
/
3
,
@button
.
h
,
@contents
,
x
,
y
)
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
])
draw_stroked_text
(
@items
[
index
],
x
+
8
,
y
+
3
,
2
,
@font
,
[
0xdf
,
0xf1
,
0xff
],
[
0x27
,
0x43
,
0x59
])
end
end
def
item_rect
(
index
)
def
item_rect
(
index
)
[
index
*
@button
.
w
/
3
+
(
index
)
*
4
,
0
,
@button
.
w
/
3
,
@height
]
[
index
*
@button
.
w
/
3
+
(
index
)
*
4
,
0
,
@button
.
w
/
3
,
@height
]
end
end
def
mousemoved
(
x
,
y
)
def
mousemoved
(
x
,
y
)
if
(
x
-
@x
)
%
(
@button
.
w
/
3
+
4
)
>=
@button
.
w
/
3
if
(
x
-
@x
)
%
(
@button
.
w
/
3
+
4
)
>=
@button
.
w
/
3
self
.
index
=
nil
self
.
index
=
nil
else
else
self
.
index
=
(
x
-
@x
)
/
(
@button
.
w
/
3
+
4
)
self
.
index
=
(
x
-
@x
)
/
(
@button
.
w
/
3
+
4
)
end
end
end
end
def
lostfocus
(
active_window
=
nil
)
def
lostfocus
(
active_window
=
nil
)
self
.
index
=
nil
self
.
index
=
nil
end
end
def
clicked
def
clicked
case
@index
case
@index
when
0
#常见问题
when
0
#常见问题
require_relative
'dialog'
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"
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
#卡组编辑
when
1
#卡组编辑
require_relative
'deck'
$game
.
class
.
deck_edit
$game
.
class
.
deck_edit
when
2
#建立房间
when
2
#建立房间
@host_window
=
Window_Host
.
new
(
300
,
200
)
@host_window
=
Window_Host
.
new
(
300
,
200
)
end
end
end
end
def
update
def
update
@host_window
.
update
if
@host_window
and
!
@host_window
.
destroyed?
@host_window
.
update
if
@host_window
and
!
@host_window
.
destroyed?
end
end
...
...
lib/ygocore/game.rb
View file @
8b973851
...
@@ -7,6 +7,7 @@ class Ygocore < Game
...
@@ -7,6 +7,7 @@ class Ygocore < Game
attr_reader
:username
attr_reader
:username
attr_accessor
:password
attr_accessor
:password
@@config
=
YAML
.
load_file
(
"lib/ygocore/server.yml"
)
@@config
=
YAML
.
load_file
(
"lib/ygocore/server.yml"
)
def
initialize
def
initialize
super
super
load
'lib/ygocore/event.rb'
load
'lib/ygocore/event.rb'
...
@@ -15,14 +16,17 @@ class Ygocore < Game
...
@@ -15,14 +16,17 @@ class Ygocore < Game
load
'lib/ygocore/scene_lobby.rb'
load
'lib/ygocore/scene_lobby.rb'
require
'json'
require
'json'
end
end
def
refresh_interval
def
refresh_interval
60
60
end
end
def
login
(
username
,
password
)
def
login
(
username
,
password
)
@username
=
username
@username
=
username
@password
=
password
@password
=
password
connect
connect
end
end
def
connect
def
connect
@recv
=
Thread
.
new
do
@recv
=
Thread
.
new
do
EventMachine
::
run
{
EventMachine
::
run
{
...
@@ -30,6 +34,7 @@ class Ygocore < Game
...
@@ -30,6 +34,7 @@ class Ygocore < Game
}
}
end
end
end
end
def
chat
(
chatmessage
)
def
chat
(
chatmessage
)
case
chatmessage
.
channel
case
chatmessage
.
channel
when
:lobby
when
:lobby
...
@@ -39,6 +44,7 @@ class Ygocore < Game
...
@@ -39,6 +44,7 @@ class Ygocore < Game
end
end
end
end
def
host
(
room_name
,
room_config
)
def
host
(
room_name
,
room_config
)
room
=
Room
.
new
(
0
,
room_name
)
room
=
Room
.
new
(
0
,
room_name
)
room
.
pvp
=
room_config
[
:pvp
]
room
.
pvp
=
room_config
[
:pvp
]
...
@@ -47,50 +53,62 @@ class Ygocore < Game
...
@@ -47,50 +53,62 @@ class Ygocore < Game
room
.
password
=
room_config
[
:password
]
room
.
password
=
room_config
[
:password
]
room
.
ot
=
room_config
[
:ot
]
room
.
ot
=
room_config
[
:ot
]
room
.
lp
=
room_config
[
:lp
]
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
=>
"确定"
)
Widget_Msgbox
.
new
(
"建立房间"
,
"房间名已存在"
,
:ok
=>
"确定"
)
else
else
Game_Event
.
push
Game_Event
::
Join
.
new
(
room
)
Game_Event
.
push
Game_Event
::
Join
.
new
(
room
)
end
end
end
end
def
watch
(
room
)
def
watch
(
room
)
Widget_Msgbox
.
new
(
"加入房间"
,
"游戏已经开始"
,
:ok
=>
"确定"
)
Widget_Msgbox
.
new
(
"加入房间"
,
"游戏已经开始"
,
:ok
=>
"确定"
)
end
end
def
join
(
room
)
def
join
(
room
)
Game_Event
.
push
Game_Event
::
Join
.
new
(
room
)
Game_Event
.
push
Game_Event
::
Join
.
new
(
room
)
end
end
def
refresh
def
refresh
send
(
:refresh
)
send
(
:refresh
)
end
end
def
send
(
header
,
data
=
nil
)
def
send
(
header
,
data
=
nil
)
$log
.
info
(
'发送消息'
)
{
{
header:
header
,
data:
data
}}
$log
.
info
(
'发送消息'
)
{
{
header:
header
,
data:
data
}
}
Client
::
MycardChannel
.
push
header:
header
,
data:
data
Client
::
MycardChannel
.
push
header:
header
,
data:
data
end
end
def
exit
def
exit
@recv
.
exit
if
@recv
@recv
.
exit
if
@recv
@recv
=
nil
@recv
=
nil
end
end
def
ygocore_path
def
ygocore_path
"ygocore/ygopro_vs.exe"
"ygocore/ygopro_vs.exe"
end
end
def
self
.
register
def
self
.
register
Dialog
.
web
@@config
[
'register'
]
Dialog
.
web
@@config
[
'register'
]
end
end
def
server
def
server
@@config
[
'server'
]
@@config
[
'server'
]
end
end
def
port
def
port
@@config
[
'port'
]
@@config
[
'port'
]
end
end
def
server
=
(
server
)
def
server
=
(
server
)
@@config
[
'server'
]
=
server
@@config
[
'server'
]
=
server
end
end
def
port
=
(
port
)
def
port
=
(
port
)
@@config
[
'port'
]
=
port
@@config
[
'port'
]
=
port
end
end
def
self
.
run_ygocore
(
option
,
image_downloading
=
false
)
def
self
.
run_ygocore
(
option
,
image_downloading
=
false
)
if
!
image_downloading
and
!
Update
.
images
.
empty?
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
end
path
=
'ygocore/ygopro_vs.exe'
path
=
'ygocore/ygopro_vs.exe'
Widget_Msgbox
.
new
(
"ygocore"
,
"正在启动ygocore"
)
rescue
nil
Widget_Msgbox
.
new
(
"ygocore"
,
"正在启动ygocore"
)
rescue
nil
...
@@ -100,7 +118,12 @@ class Ygocore < Game
...
@@ -100,7 +118,12 @@ class Ygocore < Game
when
Room
when
Room
room
=
option
room
=
option
room_name
=
if
room
.
ot
!=
0
or
room
.
lp
!=
8000
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
}
"
room_name
=
"
#{
room
.
ot
}#{
mode
}
FFF
#{
room
.
lp
}
,5,1,
#{
room
.
name
}
"
elsif
room
.
tag?
elsif
room
.
tag?
"T#"
+
room
.
name
"T#"
+
room
.
name
...
@@ -120,8 +143,8 @@ class Ygocore < Game
...
@@ -120,8 +143,8 @@ class Ygocore < Game
begin
begin
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
line
.
force_encoding
"UTF-8"
line
.
force_encoding
"UTF-8"
next
if
line
[
0
,
1
]
==
'#'
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
system_conf
[
field
]
=
contents
system_conf
[
field
]
=
contents
end
end
rescue
rescue
...
@@ -133,7 +156,7 @@ class Ygocore < Game
...
@@ -133,7 +156,7 @@ class Ygocore < Game
system_conf
[
'lastip'
]
=
$game
.
server
system_conf
[
'lastip'
]
=
$game
.
server
system_conf
[
'lastport'
]
=
$game
.
port
.
to_s
system_conf
[
'lastport'
]
=
$game
.
port
.
to_s
system_conf
[
'roompass'
]
=
room_name
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'
args
=
'-j'
when
:replay
when
:replay
args
=
'-r'
args
=
'-r'
...
@@ -144,8 +167,8 @@ class Ygocore < Game
...
@@ -144,8 +167,8 @@ class Ygocore < Game
begin
begin
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
line
.
force_encoding
"UTF-8"
line
.
force_encoding
"UTF-8"
next
if
line
[
0
,
1
]
==
'#'
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
system_conf
[
field
]
=
contents
system_conf
[
field
]
=
contents
end
end
rescue
rescue
...
@@ -154,7 +177,7 @@ class Ygocore < Game
...
@@ -154,7 +177,7 @@ class Ygocore < Game
system_conf
[
'numfont'
]
=
'c:/windows/fonts/arialbd.ttf'
system_conf
[
'numfont'
]
=
'c:/windows/fonts/arialbd.ttf'
end
end
system_conf
[
'lastdeck'
]
=
option
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'
args
=
'-d'
end
end
IO
.
popen
(
"ygopro_vs.exe
#{
args
}
"
)
IO
.
popen
(
"ygopro_vs.exe
#{
args
}
"
)
...
@@ -162,31 +185,47 @@ class Ygocore < Game
...
@@ -162,31 +185,47 @@ class Ygocore < Game
end
end
Widget_Msgbox
.
destroy
rescue
nil
Widget_Msgbox
.
destroy
rescue
nil
end
end
def
self
.
deck_edit
def
self
.
deck_edit
Widget_Msgbox
.
new
(
"编辑卡组"
,
"
\"
导入
\"
导入已有卡组,
\"
编辑
\"
启动ygocore"
,
:import
=>
"导入"
,
:edit
=>
"编辑"
)
do
|
button
|
Widget_Msgbox
.
new
(
"编辑卡组"
,
"
\"
导入
\"
导入已有卡组,
\"
编辑
\"
启动ygocore"
,
:import
=>
"导入"
,
:edit
=>
"编辑"
)
do
|
button
|
case
button
case
button
when
:import
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")
file
=
Dialog
.
get_open_file
(
"导入卡组"
,
"所有支持的卡组 (*.txt;*.deck;*.ydk)"
=>
"*.ydk;*.txt;*.deck"
,
"OcgSoft卡组 (*.txt;*.deck)"
=>
"*.txt;*.deck"
,
"ygocore卡组 (*.ydk)"
=>
"*.yd
k"
)
if
!
file
.
empty?
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"
)
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
dest
.
write
src
.
read
end
end
Widget_Msgbox
.
new
(
"导入卡组"
,
"导入卡组完成"
,
:ok
=>
"确定"
)
end
end
rescue
Widget_Msgbox
.
new
(
"导入卡组"
,
"导入卡组失败"
,
:ok
=>
"确定"
)
end
rescue
Widget_Msgbox
.
new
(
"导入卡组"
,
"导入卡组失败"
,
:ok
=>
"确定"
)
Ygocore
.
run_ygocore
(
File
.
basename
(
file
,
extname
))
end
end
when
:edit
when
:edit
Ygocore
.
run_ygocore
(
:deck
)
Ygocore
.
run_ygocore
(
:deck
)
end
end
end
end
end
end
def
self
.
replay
(
file
,
skip_image_downloading
=
false
)
def
self
.
replay
(
file
,
skip_image_downloading
=
false
)
require
'fileutils'
require
'fileutils'
FileUtils
.
mv
Dir
.
glob
(
'ygocore/replay/*.yrp'
),
'replay/'
FileUtils
.
mv
Dir
.
glob
(
'ygocore/replay/*.yrp'
),
'replay/'
FileUtils
.
copy_file
(
file
,
"ygocore/replay/
#{
File
.
basename
(
file
)
}
"
)
FileUtils
.
copy_file
(
file
,
"ygocore/replay/
#{
File
.
basename
(
file
)
}
"
)
run_ygocore
(
:replay
,
skip_image_downloading
)
run_ygocore
(
:replay
,
skip_image_downloading
)
end
end
private
private
def
self
.
get_announcements
def
self
.
get_announcements
...
@@ -198,28 +237,32 @@ class Ygocore < Game
...
@@ -198,28 +237,32 @@ class Ygocore < Game
open
(
@@config
[
'api'
])
do
|
file
|
open
(
@@config
[
'api'
])
do
|
file
|
file
.
set_encoding
"GBK"
file
.
set_encoding
"GBK"
announcements
=
[]
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
)
announcements
<<
Announcement
.
new
(
title
,
@@config
[
'index'
],
nil
)
end
end
$config
[
'ygocore'
][
'announcements'
].
replace
announcements
$config
[
'ygocore'
][
'announcements'
].
replace
announcements
save_config
save_config
end
end
rescue
Exception
=>
exception
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
end
end
end
module
Client
module
Client
MycardChannel
=
EM
::
Channel
.
new
MycardChannel
=
EM
::
Channel
.
new
include
EM
::
P
::
ObjectProtocol
include
EM
::
P
::
ObjectProtocol
def
post_init
def
post_init
send_object
header: :login
,
data:
{
name:
$game
.
username
,
password:
$game
.
password
}
send_object
header: :login
,
data:
{
name:
$game
.
username
,
password:
$game
.
password
}
MycardChannel
.
subscribe
{
|
msg
|
send_object
(
msg
)
}
MycardChannel
.
subscribe
{
|
msg
|
send_object
(
msg
)
}
end
end
def
receive_object
obj
def
receive_object
obj
$log
.
info
(
'收到消息'
)
{
obj
.
inspect
}
$log
.
info
(
'收到消息'
)
{
obj
.
inspect
}
Game_Event
.
push
Game_Event
.
parse
obj
[
:header
],
obj
[
:data
]
Game_Event
.
push
Game_Event
.
parse
obj
[
:header
],
obj
[
:data
]
end
end
def
unbind
def
unbind
Game_Event
.
push
Game_Event
::
Error
.
new
(
'ygocore'
,
'网络连接中断'
,
true
)
Game_Event
.
push
Game_Event
::
Error
.
new
(
'ygocore'
,
'网络连接中断'
,
true
)
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