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
76e54522
Commit
76e54522
authored
Mar 13, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入各种验证
parent
23740294
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
185 additions
and
148 deletions
+185
-148
lib/scene_lobby.rb
lib/scene_lobby.rb
+10
-8
lib/scene_login.rb
lib/scene_login.rb
+1
-0
lib/window_host.rb
lib/window_host.rb
+3
-2
lib/window_roomlist.rb
lib/window_roomlist.rb
+0
-2
lib/ygocore/event.rb
lib/ygocore/event.rb
+6
-0
lib/ygocore/game.rb
lib/ygocore/game.rb
+47
-132
lib/ygocore/scene_lobby.rb
lib/ygocore/scene_lobby.rb
+114
-0
lib/ygocore/server.yml
lib/ygocore/server.yml
+4
-4
No files found.
lib/scene_lobby.rb
View file @
76e54522
...
@@ -48,14 +48,14 @@ class Scene_Lobby < Scene
...
@@ -48,14 +48,14 @@ class Scene_Lobby < Scene
#@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间")
#@joinroom_msgbox = Widget_Msgbox.new("加入房间", "正在加入房间")
#$game.join 'localhost'
#$game.join 'localhost'
when
Key
::
F5
when
Key
::
F5
# if @roomlist.items and room = @roomlist.items.find{|room|room.player1 == $game.user or room.player2 == $game.user}
# if @roomlist.items and room = @roomlist.items.find{|room|room.player1 == $game.user or room.player2 == $game.user}
# $game.qroom room
# $game.qroom room
# end
# end
$game
.
refresh
$game
.
refresh
when
Key
::
F12
when
Key
::
F12
# if @roomlist.items and room = @roomlist.items.find{|room|room.player1 == $game.user or room.player2 == $game.user}
# if @roomlist.items and room = @roomlist.items.find{|room|room.player1 == $game.user or room.player2 == $game.user}
# $game.qroom room
# $game.qroom room
# end
# end
$game
.
exit
$game
.
exit
$scene
=
Scene_Login
.
new
$scene
=
Scene_Login
.
new
end
end
...
@@ -71,7 +71,7 @@ class Scene_Lobby < Scene
...
@@ -71,7 +71,7 @@ class Scene_Lobby < Scene
when
Game_Event
::
AllRooms
when
Game_Event
::
AllRooms
@roomlist
.
items
=
$game
.
rooms
@roomlist
.
items
=
$game
.
rooms
when
Game_Event
::
Join
when
Game_Event
::
Join
$scene
=
Scene_Duel
.
new
(
event
.
room
,
Deck
.
load
(
"老I FTK2.txt"
)
)
join
(
event
.
room
)
when
Game_Event
::
Watch
when
Game_Event
::
Watch
require_relative
'scene_watch'
require_relative
'scene_watch'
$scene
=
Scene_Watch
.
new
(
event
.
room
)
$scene
=
Scene_Watch
.
new
(
event
.
room
)
...
@@ -81,7 +81,9 @@ class Scene_Lobby < Scene
...
@@ -81,7 +81,9 @@ class Scene_Lobby < Scene
super
super
end
end
end
end
def
join
(
room
)
$scene
=
Scene_Duel
.
new
(
room
)
end
def
update
def
update
if
@count
>=
600
if
@count
>=
600
$game
.
refresh
$game
.
refresh
...
...
lib/scene_login.rb
View file @
76e54522
...
@@ -8,6 +8,7 @@ require_relative 'window_gameselect'
...
@@ -8,6 +8,7 @@ require_relative 'window_gameselect'
require_relative
'window_announcements'
require_relative
'window_announcements'
require_relative
'window_login'
require_relative
'window_login'
require_relative
'scene_replay'
require_relative
'scene_replay'
require_relative
'scene_lobby'
BGM
=
"title.ogg"
BGM
=
"title.ogg"
class
Scene_Login
<
Scene
class
Scene_Login
<
Scene
def
start
def
start
...
...
lib/window_host.rb
View file @
76e54522
...
@@ -3,10 +3,10 @@ class Window_Host < Window
...
@@ -3,10 +3,10 @@ class Window_Host < Window
attr_reader
:index
attr_reader
:index
def
initialize
(
x
,
y
)
def
initialize
(
x
,
y
)
super
(
x
,
y
,
300
,
150
,
300
)
super
(
x
,
y
,
300
,
150
,
300
)
@items
=
{
:ok
=>
[
116
,
114
,
100
,
20
]}
@button
=
Surface
.
load
(
"graphics/system/button.png"
)
@items
=
{
:ok
=>
[
116
,
114
,
@button
.
w
/
3
,
@button
.
h
]}
@buttons
=
{
:ok
=>
"确定"
}
@buttons
=
{
:ok
=>
"确定"
}
@background
=
Surface
.
load
(
'graphics/system/msgbox.png'
).
display_format
@background
=
Surface
.
load
(
'graphics/system/msgbox.png'
).
display_format
@button
=
Surface
.
load
(
"graphics/system/button.png"
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@title_color
=
[
0xFF
,
0xFF
,
0xFF
]
@title_color
=
[
0xFF
,
0xFF
,
0xFF
]
@color
=
[
0x04
,
0x47
,
0x7c
]
@color
=
[
0x04
,
0x47
,
0x7c
]
...
@@ -62,6 +62,7 @@ class Window_Host < Window
...
@@ -62,6 +62,7 @@ class Window_Host < Window
case
self
.
index
case
self
.
index
when
:ok
when
:ok
return
if
@roomname_inputbox
.
value
.
empty?
return
if
@roomname_inputbox
.
value
.
empty?
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"建立房间"
,
"正在建立房间"
)
$game
.
host
(
@roomname_inputbox
.
value
,
:pvp
=>
@pvp
.
checked?
,
:match
=>
@match
.
checked?
)
$game
.
host
(
@roomname_inputbox
.
value
,
:pvp
=>
@pvp
.
checked?
,
:match
=>
@match
.
checked?
)
@roomname_inputbox
.
destroy
@roomname_inputbox
.
destroy
@pvp
.
destroy
@pvp
.
destroy
...
...
lib/window_roomlist.rb
View file @
76e54522
...
@@ -42,7 +42,6 @@ class Window_RoomList < Window_Scrollable
...
@@ -42,7 +42,6 @@ class Window_RoomList < Window_Scrollable
self
.
index
=
(
y
-
@y
)
/
WLH
+
@scroll
self
.
index
=
(
y
-
@y
)
/
WLH
+
@scroll
end
end
def
clicked
def
clicked
return
if
@last_clicked
and
Time
.
now
-
@last_clicked
<
3
#ygocore 加入房间时可能弹Tk窗询问主程序位置 防止重复点击
return
unless
@index
and
room
=
@items
[
@index
]
return
unless
@index
and
room
=
@items
[
@index
]
if
room
.
full?
if
room
.
full?
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"加入房间"
,
"正在加入观战"
)
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"加入房间"
,
"正在加入观战"
)
...
@@ -51,6 +50,5 @@ class Window_RoomList < Window_Scrollable
...
@@ -51,6 +50,5 @@ class Window_RoomList < Window_Scrollable
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"加入房间"
,
"正在加入房间"
)
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"加入房间"
,
"正在加入房间"
)
$game
.
join
room
$game
.
join
room
end
end
@last_clicked
=
Time
.
now
end
end
end
end
\ No newline at end of file
lib/ygocore/event.rb
View file @
76e54522
...
@@ -37,4 +37,10 @@ class Game_Event
...
@@ -37,4 +37,10 @@ class Game_Event
self
.
new
@users
self
.
new
@users
end
end
end
end
class
Join
<
Game_Event
def
initialize
(
room
)
@room
=
room
$game
.
room
=
@room
end
end
end
end
\ No newline at end of file
lib/ygocore/game.rb
View file @
76e54522
...
@@ -8,161 +8,68 @@ class Ygocore < Game
...
@@ -8,161 +8,68 @@ class Ygocore < Game
Server
=
config
[
'server'
]
Server
=
config
[
'server'
]
API_Url
=
config
[
'api'
]
API_Url
=
config
[
'api'
]
Index_Url
=
config
[
'index'
]
Index_Url
=
config
[
'index'
]
attr_reader
:password
WM_LBUTTONDOWN
=
0x201
WM_LBUTTONUP
=
0x202
#WM_KEYDOWN = 0x0100
#WM_KEYUP = 0x0100
VK_CONTROL
=
0x11
VK_A
=
0x41
VK_V
=
0x56
VK_TAB
=
0x09
VK_RETURN
=
0x0D
KEYEVENTF_KEYUP
=
0x02
CF_TEXT
=
1
;
GMEM_DDESHARE
=
0x2000
;
def
initialize
def
initialize
super
super
load
File
.
expand_path
(
'event.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'event.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'user.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'user.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'room.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'room.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'scene_lobby.rb'
,
File
.
dirname
(
__FILE__
))
end
end
def
login
(
username
,
password
)
def
login
(
username
,
password
)
if
username
.
empty?
if
username
.
empty?
return
Widget_Msgbox
.
new
(
"登陆"
,
"请输入用户名"
,
:ok
=>
"确定"
)
return
Widget_Msgbox
.
new
(
"登陆"
,
"请输入用户名"
,
:ok
=>
"确定"
)
end
end
if
password
.
empty?
if
password
.
empty?
return
Widget_Msgbox
.
new
(
"登陆"
,
"请输入密码"
,
:ok
=>
"确定"
)
Widget_Msgbox
.
new
(
"登陆"
,
"无密码登陆,不能建房,不能加入竞技场"
,
:ok
=>
"确定"
){
Game_Event
.
push
Game_Event
::
Login
.
new
(
User
.
new
(
username
.
to_sym
,
username
))}
end
else
require
'cgi'
require
'cgi'
open
(
"
#{
API_Url
}
?userregist=CHANGEPASS&username=
#{
CGI
.
escape
username
}
&password=
#{
CGI
.
escape
password
}
&oldpass=
#{
CGI
.
escape
password
}
"
)
do
|
file
|
open
(
"
#{
API_Url
}
?userregist=CHANGEPASS&username=
#{
CGI
.
escape
username
}
&password=
#{
CGI
.
escape
password
}
&oldpass=
#{
CGI
.
escape
password
}
"
)
do
|
file
|
file
.
set_encoding
"GBK"
file
.
set_encoding
"GBK"
result
=
file
.
read
.
encode
(
"UTF-8"
)
result
=
file
.
read
.
encode
(
"UTF-8"
)
$log
.
debug
(
'用户登陆传回消息'
){
result
}
$log
.
debug
(
'用户登陆传回消息'
){
result
}
if
result
==
"修改成功"
if
result
==
"修改成功"
connect
connect
@password
=
password
@password
=
password
Game_Event
.
push
Game_Event
::
Login
.
new
(
User
.
new
(
username
.
to_sym
,
username
))
Game_Event
.
push
Game_Event
::
Login
.
new
(
User
.
new
(
username
.
to_sym
,
username
))
else
else
Game_Event
.
push
Game_Event
::
Error
.
new
(
"登陆"
,
"用户名或密码错误"
)
Game_Event
.
push
Game_Event
::
Error
.
new
(
"登陆"
,
"用户名或密码错误"
)
end
end
end
end
end
end
end
def
host
(
room_name
,
room_config
)
def
host
(
room_name
,
room_config
)
if
$game
.
password
.
nil?
or
$game
.
password
.
empty?
return
Widget_Msgbox
.
new
(
"建立房间"
,
"必须有账号才能建立房间"
,
:ok
=>
"确定"
)
end
room
=
Room
.
new
(
0
,
room_name
)
room
=
Room
.
new
(
0
,
room_name
)
room
.
pvp
=
room_config
[
:pvp
]
room
.
pvp
=
room_config
[
:pvp
]
room
.
match
=
room_config
[
:match
]
room
.
match
=
room_config
[
:match
]
join
room
refresh
do
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
end
end
def
watch
(
room
)
def
watch
(
room
)
Widget_Msgbox
.
new
(
"
观战"
,
"ygocore不支持加入已经开始游戏的房间
"
,
:ok
=>
"确定"
)
Widget_Msgbox
.
new
(
"
加入房间"
,
"游戏已经开始
"
,
:ok
=>
"确定"
)
end
end
def
join
(
room
)
def
join
(
room
)
return
if
@last_clicked
and
Time
.
now
-
@last_clicked
<
3
#防止重复点击
if
$game
.
password
.
nil?
or
$game
.
password
.
empty?
and
room
.
pvp?
unless
$config
[
'ygocore'
][
'path'
]
and
File
.
file?
$config
[
'ygocore'
][
'path'
]
return
Widget_Msgbox
.
new
(
"加入房间"
,
"必须有账号才能加入竞技场房间"
,
:ok
=>
"确定"
)
Widget_Msgbox
.
new
(
"加入房间"
,
"请指定ygocore主程序位置"
)
$scene
.
draw
require
'tk'
$config
[
'ygocore'
][
'path'
]
=
Tk
.
getOpenFile
.
encode
(
"UTF-8"
)
save_config
@last_clicked
=
Time
.
now
end
end
room_name
=
if
room
.
pvp?
and
room
.
match?
return
unless
ygocore_path
"PM#"
+
room
.
name
refresh
do
elsif
room
.
pvp?
if
room
.
full?
#如果游戏已经开了
"P#"
+
room
.
name
Widget_Msgbox
.
new
(
"加入房间"
,
"游戏已经开始"
,
:ok
=>
"确定"
)
elsif
room
.
match?
elsif
!
$game
.
rooms
.
include?
room
"M#"
+
room
.
name
Widget_Msgbox
.
new
(
"加入房间"
,
"游戏已经取消"
,
:ok
=>
"确定"
)
else
room
.
name
end
if
$config
[
'ygocore'
][
'path'
]
and
File
.
file?
$config
[
'ygocore'
][
'path'
]
$scene
.
draw
#写入配置文件并运行ygocore
Dir
.
chdir
(
File
.
dirname
(
$config
[
'ygocore'
][
'path'
]))
do
$log
.
debug
(
'当前目录'
){
Dir
.
pwd
.
encode
(
"UTF-8"
)}
system_conf
=
{}
begin
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
line
.
force_encoding
"UTF-8"
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
system_conf
[
field
]
=
contents
end
rescue
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
.
debug
(
Dir
.
foreach
(
'.'
).
to_a
.
inspect
)
end
system_conf
[
'nickname'
]
=
"
#{
@user
.
name
}#{
"$"
unless
@password
.
empty?
}#{
@password
}
"
system_conf
[
'lastip'
]
=
Server
system_conf
[
'lastport'
]
=
Port
.
to_s
open
(
'system.conf'
,
'w'
)
{
|
file
|
file
.
write
system_conf
.
collect
{
|
key
,
value
|
"
#{
key
}
=
#{
value
}
"
}.
join
(
"
\n
"
)}
$log
.
debug
(
'ygocore路径'
)
{
$config
[
'ygocore'
][
'path'
]}
IO
.
popen
(
"
\"
#{
$config
[
'ygocore'
][
'path'
]
}
\"
"
.
encode
(
"GBK"
))
#执行外部程序....有中文的情况下貌似只能这样了orz
end
#初始化windows API
require
'win32api'
@@FindWindow
=
Win32API
.
new
(
"user32"
,
"FindWindow"
,
"pp"
,
"l"
)
@@SendMessage
=
Win32API
.
new
(
'user32'
,
'SendMessage'
,
[
"L"
,
"L"
,
"L"
,
"L"
],
"L"
)
@@SetForegroundWindow
=
Win32API
.
new
(
'user32'
,
'SetForegroundWindow'
,
'l'
,
'v'
)
@@keybd_event
=
Win32API
.
new
(
'user32'
,
'keybd_event'
,
'llll'
,
'v'
)
@@lstrcpy
=
Win32API
.
new
(
'kernel32'
,
'lstrcpyA'
,
[
'I'
,
'P'
],
'P'
);
@@lstrlen
=
Win32API
.
new
(
'kernel32'
,
'lstrlenA'
,
[
'P'
],
'I'
);
@@OpenClipboard
=
Win32API
.
new
(
'user32'
,
'OpenClipboard'
,
[
'I'
],
'I'
);
@@CloseClipboard
=
Win32API
.
new
(
'user32'
,
'CloseClipboard'
,
[],
'I'
);
@@EmptyClipboard
=
Win32API
.
new
(
'user32'
,
'EmptyClipboard'
,
[],
'I'
);
@@SetClipboardData
=
Win32API
.
new
(
'user32'
,
'SetClipboardData'
,
[
'I'
,
'I'
],
'I'
);
@@GlobalAlloc
=
Win32API
.
new
(
'kernel32'
,
'GlobalAlloc'
,
[
'I'
,
'I'
],
'I'
);
@@GlobalLock
=
Win32API
.
new
(
'kernel32'
,
'GlobalLock'
,
[
'I'
],
'I'
);
@@GlobalUnlock
=
Win32API
.
new
(
'kernel32'
,
'GlobalUnlock'
,
[
'I'
],
'I'
);
#获取句柄
hwnd
=
nil
100
.
times
do
if
(
hwnd
=
@@FindWindow
.
call
(
'CIrrDeviceWin32'
,
nil
))
!=
0
break
else
sleep
0.1
end
end
if
hwnd
and
hwnd
!=
0
#操作ygocore进入主机
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
507
,
242
))
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
507
,
242
))
sleep
0.5
if
@@OpenClipboard
.
Call
(
0
)
!=
0
@@EmptyClipboard
.
Call
();
len
=
@@lstrlen
.
Call
(
room_name
.
encode
(
"GBK"
));
hmem
=
@@GlobalAlloc
.
Call
(
GMEM_DDESHARE
,
len
+
1
);
pmem
=
@@GlobalLock
.
Call
(
hmem
);
@@lstrcpy
.
Call
(
pmem
,
room_name
.
encode
(
"GBK"
));
@@SetClipboardData
.
Call
(
CF_TEXT
,
hmem
);
@@GlobalUnlock
.
Call
(
hmem
);
@@CloseClipboard
.
Call
;
else
return
Widget_Msgbox
.
new
(
"加入房间"
,
'填写房间名失败 请把房间名手动填写到房间密码处'
,
:ok
=>
"确定"
)
end
$log
.
debug
(
'加入房间'
){
room_name
}
@@SetForegroundWindow
.
call
(
hwnd
)
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
380
,
500
))
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
380
,
500
))
@@keybd_event
.
call
(
VK_CONTROL
,
0
,
0
,
0
)
@@keybd_event
.
call
(
VK_A
,
0
,
0
,
0
)
#全选以避免密码处已经有字的情况,正常情况下应该无用
@@keybd_event
.
call
(
VK_A
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@keybd_event
.
call
(
VK_V
,
0
,
0
,
0
)
@@keybd_event
.
call
(
VK_V
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@keybd_event
.
call
(
VK_CONTROL
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@keybd_event
.
call
(
VK_TAB
,
0
,
0
,
0
)
@@keybd_event
.
call
(
VK_TAB
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@keybd_event
.
call
(
VK_RETURN
,
0
,
0
,
0
)
@@keybd_event
.
call
(
VK_RETURN
,
0
,
KEYEVENTF_KEYUP
,
0
)
else
else
return
Widget_Msgbox
.
new
(
"加入房间"
,
'ygocore运行失败'
,
:ok
=>
"确定"
)
Game_Event
.
push
Game_Event
::
Join
.
new
(
room
)
end
end
end
end
Widget_Msgbox
.
new
(
"加入房间"
,
"已经加入房间"
).
destroy
#仅仅为了消掉正在加入房间的消息框
end
end
def
refresh
def
refresh
Thread
.
new
do
Thread
.
new
do
...
@@ -172,6 +79,8 @@ class Ygocore < Game
...
@@ -172,6 +79,8 @@ class Ygocore < Game
info
=
file
.
read
.
encode
(
"UTF-8"
)
info
=
file
.
read
.
encode
(
"UTF-8"
)
Game_Event
.
push
Game_Event
::
AllUsers
.
parse
info
Game_Event
.
push
Game_Event
::
AllUsers
.
parse
info
Game_Event
.
push
Game_Event
::
AllRooms
.
parse
info
Game_Event
.
push
Game_Event
::
AllRooms
.
parse
info
p
block_given?
yield
if
block_given?
end
end
end
end
end
end
...
@@ -179,10 +88,16 @@ class Ygocore < Game
...
@@ -179,10 +88,16 @@ class Ygocore < Game
private
private
def
connect
def
connect
end
end
def
MAKELPARAM
(
w1
,
w2
)
def
ygocore_path
return
(
w2
<<
16
)
|
w1
return
$config
[
'ygocore'
][
'path'
]
if
$config
[
'ygocore'
][
'path'
]
and
File
.
file?
$config
[
'ygocore'
][
'path'
]
return
if
@last_clicked
and
Time
.
now
-
@last_clicked
<
3
#防止重复点击
Widget_Msgbox
.
new
(
"加入房间"
,
"请指定ygocore主程序位置"
)
$scene
.
draw
require
'tk'
$config
[
'ygocore'
][
'path'
]
=
Tk
.
getOpenFile
.
encode
(
"UTF-8"
)
save_config
@last_clicked
=
Time
.
now
end
end
def
self
.
get_announcements
def
self
.
get_announcements
#公告
#公告
$config
[
'ygocore'
][
'announcements'
]
||=
[
Announcement
.
new
(
"正在读取公告..."
,
nil
,
nil
)]
$config
[
'ygocore'
][
'announcements'
]
||=
[
Announcement
.
new
(
"正在读取公告..."
,
nil
,
nil
)]
...
...
lib/ygocore/scene_lobby.rb
0 → 100644
View file @
76e54522
#encoding: UTF-8
class
Scene_Lobby
WM_LBUTTONDOWN
=
0x201
WM_LBUTTONUP
=
0x202
VK_CONTROL
=
0x11
VK_A
=
0x41
VK_V
=
0x56
VK_TAB
=
0x09
VK_RETURN
=
0x0D
KEYEVENTF_KEYUP
=
0x02
CF_UNICODETEXT
=
13
;
GMEM_DDESHARE
=
0x2000
;
def
join
(
room
)
room_name
=
if
room
.
pvp?
and
room
.
match?
"PM#"
+
room
.
name
elsif
room
.
pvp?
"P#"
+
room
.
name
elsif
room
.
match?
"M#"
+
room
.
name
else
room
.
name
end
$scene
.
draw
#写入配置文件并运行ygocore
Dir
.
chdir
(
File
.
dirname
(
$config
[
'ygocore'
][
'path'
]))
do
$log
.
debug
(
'当前目录'
){
Dir
.
pwd
.
encode
(
"UTF-8"
)}
system_conf
=
{}
begin
IO
.
readlines
(
'system.conf'
).
each
do
|
line
|
line
.
force_encoding
"UTF-8"
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
system_conf
[
field
]
=
contents
end
rescue
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
.
debug
(
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'
]
=
Ygocore
::
Server
system_conf
[
'lastport'
]
=
Ygocore
::
Port
.
to_s
open
(
'system.conf'
,
'w'
)
{
|
file
|
file
.
write
system_conf
.
collect
{
|
key
,
value
|
"
#{
key
}
=
#{
value
}
"
}.
join
(
"
\n
"
)}
$log
.
debug
(
'ygocore路径'
)
{
$config
[
'ygocore'
][
'path'
]}
IO
.
popen
(
"
\"
#{
$config
[
'ygocore'
][
'path'
]
}
\"
"
.
encode
(
"GBK"
))
#执行外部程序....有中文的情况下貌似只能这样了orz
end
#初始化windows API
require
'win32api'
@@FindWindow
=
Win32API
.
new
(
"user32"
,
"FindWindow"
,
"pp"
,
"l"
)
@@SendMessage
=
Win32API
.
new
(
'user32'
,
'SendMessage'
,
[
"L"
,
"L"
,
"L"
,
"L"
],
"L"
)
@@SetForegroundWindow
=
Win32API
.
new
(
'user32'
,
'SetForegroundWindow'
,
'l'
,
'v'
)
@@keybd_event
=
Win32API
.
new
(
'user32'
,
'keybd_event'
,
'llll'
,
'v'
)
@@lstrcpy
=
Win32API
.
new
(
'kernel32'
,
'lstrcpyW'
,
[
'I'
,
'P'
],
'P'
);
@@lstrlen
=
Win32API
.
new
(
'kernel32'
,
'lstrlenW'
,
[
'P'
],
'I'
);
@@OpenClipboard
=
Win32API
.
new
(
'user32'
,
'OpenClipboard'
,
[
'I'
],
'I'
);
@@CloseClipboard
=
Win32API
.
new
(
'user32'
,
'CloseClipboard'
,
[],
'I'
);
@@EmptyClipboard
=
Win32API
.
new
(
'user32'
,
'EmptyClipboard'
,
[],
'I'
);
@@SetClipboardData
=
Win32API
.
new
(
'user32'
,
'SetClipboardData'
,
[
'I'
,
'I'
],
'I'
);
@@GlobalAlloc
=
Win32API
.
new
(
'kernel32'
,
'GlobalAlloc'
,
[
'I'
,
'I'
],
'I'
);
@@GlobalLock
=
Win32API
.
new
(
'kernel32'
,
'GlobalLock'
,
[
'I'
],
'I'
);
@@GlobalUnlock
=
Win32API
.
new
(
'kernel32'
,
'GlobalUnlock'
,
[
'I'
],
'I'
);
#获取句柄
hwnd
=
nil
50
.
times
do
if
(
hwnd
=
@@FindWindow
.
call
(
'CIrrDeviceWin32'
,
nil
))
!=
0
break
else
sleep
0.1
end
end
if
hwnd
and
hwnd
!=
0
#操作ygocore进入主机
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
507
,
242
))
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
507
,
242
))
sleep
0.5
if
@@OpenClipboard
.
Call
(
0
)
!=
0
$log
.
debug
(
'加入房间'
){
room_name
}
@@EmptyClipboard
.
Call
();
len
=
room_name
.
encode
(
"UTF-16LE"
).
bytesize
$log
.
debug
(
'房间名长度'
){
len
.
to_s
}
hmem
=
@@GlobalAlloc
.
Call
(
GMEM_DDESHARE
,
len
+
2
);
pmem
=
@@GlobalLock
.
Call
(
hmem
);
@@lstrcpy
.
Call
(
pmem
,
room_name
.
encode
(
"UTF-16LE"
));
@@SetClipboardData
.
Call
(
CF_UNICODETEXT
,
hmem
);
@@GlobalUnlock
.
Call
(
hmem
);
@@CloseClipboard
.
Call
;
@@SetForegroundWindow
.
call
(
hwnd
)
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
380
,
500
))
@@SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
380
,
500
))
@@keybd_event
.
call
(
VK_CONTROL
,
0
,
0
,
0
)
@@keybd_event
.
call
(
VK_A
,
0
,
0
,
0
)
#全选以避免密码处已经有字的情况,正常情况下应该无用
@@keybd_event
.
call
(
VK_A
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@keybd_event
.
call
(
VK_V
,
0
,
0
,
0
)
@@keybd_event
.
call
(
VK_V
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@keybd_event
.
call
(
VK_CONTROL
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@keybd_event
.
call
(
VK_TAB
,
0
,
0
,
0
)
@@keybd_event
.
call
(
VK_TAB
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@keybd_event
.
call
(
VK_RETURN
,
0
,
0
,
0
)
@@keybd_event
.
call
(
VK_RETURN
,
0
,
KEYEVENTF_KEYUP
,
0
)
Widget_Msgbox
.
new
(
"加入房间"
,
"已经加入房间"
,
:ok
=>
"确定"
).
destroy
#仅仅为了消掉正在加入房间的消息框
else
Widget_Msgbox
.
new
(
"加入房间"
,
'填写房间名失败 请把房间名手动填写到房间密码处'
,
:ok
=>
"确定"
)
end
else
Widget_Msgbox
.
new
(
"加入房间"
,
'ygocore运行失败'
,
:ok
=>
"确定"
)
end
end
def
MAKELPARAM
(
w1
,
w2
)
return
(
w2
<<
16
)
|
w1
end
end
lib/ygocore/server.yml
View file @
76e54522
---
---
register
:
http://
card.touhou.cc/register
register
:
http://
sh.convnet.net:7955/regist.html
api
:
http://
140.113.242.66
:7922/
api
:
http://
sh.convnet.net
:7922/
index
:
http://
card.touhou.cc
/
index
:
http://
sh.convnet.net:7922
/
server
:
140.113.242.66
server
:
221.226.68.62
port
:
7911
port
:
7911
\ No newline at end of file
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