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
f7dfd90e
Commit
f7dfd90e
authored
Mar 06, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ygocore
parent
62baa2e3
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
93 additions
and
58 deletions
+93
-58
lib/iduel/user.rb
lib/iduel/user.rb
+3
-0
lib/user.rb
lib/user.rb
+3
-0
lib/window_announcements.rb
lib/window_announcements.rb
+1
-1
lib/window_login.rb
lib/window_login.rb
+2
-2
lib/window_roomlist.rb
lib/window_roomlist.rb
+2
-2
lib/window_userinfo.rb
lib/window_userinfo.rb
+0
-1
lib/window_userlist.rb
lib/window_userlist.rb
+3
-15
lib/ygocore/event.rb
lib/ygocore/event.rb
+19
-8
lib/ygocore/game.rb
lib/ygocore/game.rb
+34
-29
lib/ygocore/room.rb
lib/ygocore/room.rb
+8
-0
lib/ygocore/user.rb
lib/ygocore/user.rb
+18
-0
No files found.
lib/iduel/user.rb
View file @
f7dfd90e
...
...
@@ -51,4 +51,7 @@ class User
require
'launchy'
Launchy
.
open
(
"http://www.duelcn.com/home.php?mod=space&uid=
#{
@id
-
100000
}
"
)
end
def
color
@friend
?
[
255
,
0
,
0
]
:
[
0
,
0
,
0
]
end
end
lib/user.rb
View file @
f7dfd90e
...
...
@@ -31,4 +31,7 @@ class User
def
viewinfo
end
def
color
[
0
,
0
,
0
]
end
end
\ No newline at end of file
lib/window_announcements.rb
View file @
f7dfd90e
...
...
@@ -53,7 +53,7 @@ class Window_Announcements < Window
else
@count
+=
1
end
if
@count
>=
180
if
@count
>=
180
and
!
@items
.
empty?
@index
=
(
@index
+
1
)
%
@items
.
size
@count
=
0
@item
=
@items
[
@index
]
...
...
lib/window_login.rb
View file @
f7dfd90e
...
...
@@ -9,10 +9,10 @@ class Window_Login < Window
@button
=
Surface
.
load
(
"graphics/login/button.png"
)
super
(
x
,
y
,
597
,
338
)
@username_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
80
,
165
,
WLH
){
|
text
|
@username_inputbox
.
value
=
text
;
@password_inputbox
.
clicked
;
false
}
@username
?
@username_inputbox
.
value
=
@username
:
@username_inputbox
.
refresh
@username
&&
!
@username
.
empty?
?
@username_inputbox
.
value
=
@username
:
@username_inputbox
.
refresh
@password_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
125
,
165
,
WLH
){
|
text
|
Widget_InputBox
.
determine
;
self
.
index
=
:login
;
clicked
;
false
}
@password_inputbox
.
type
=
:password
@password
?
@password_inputbox
.
value
=
@password
:
@password_inputbox
.
refresh
@password
&&
!
@password
.
empty?
?
@password_inputbox
.
value
=
@password
:
@password_inputbox
.
refresh
@color
=
[
255
,
255
,
255
]
@color_stroke
=
[
0
,
0
,
0
]
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
...
...
lib/window_roomlist.rb
View file @
f7dfd90e
...
...
@@ -29,8 +29,8 @@ class Window_RoomList < Window_Scrollable
@font
.
draw_blended_utf8
(
@contents
,
room
.
full?
?
"【决斗中】"
:
room
.
private?
?
"【私密房】"
:
"【等待中】"
,
8
,
y
+
24
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
room
.
name
,
128
,
y
+
8
,
*
room
.
color
)
unless
room
.
name
.
empty?
or
room
.
name
.
size
>
100
p
room
.
name
if
room
.
name
.
size
>
100
@font
.
draw_blended_utf8
(
@contents
,
room
.
player1
.
name
,
128
,
y
+
24
,
*
@
color
)
if
room
.
player1
@font
.
draw_blended_utf8
(
@contents
,
room
.
player2
.
name
,
256
,
y
+
24
,
*
@
color
)
if
room
.
player2
@font
.
draw_blended_utf8
(
@contents
,
room
.
player1
.
name
,
128
,
y
+
24
,
*
room
.
player1
.
color
)
if
room
.
player1
@font
.
draw_blended_utf8
(
@contents
,
room
.
player2
.
name
,
256
,
y
+
24
,
*
room
.
player2
.
color
)
if
room
.
player2
end
def
mousemoved
(
x
,
y
)
...
...
lib/window_userinfo.rb
View file @
f7dfd90e
...
...
@@ -23,7 +23,6 @@ class Window_UserInfo < Window
@contents
.
put
(
@avatar_boarder
,
0
,
0
)
end
@font
.
draw_blended_utf8
(
@contents
,
@user
.
name
,
160
,
12
,
0x00
,
0x00
,
0x00
)
@font
.
draw_blended_utf8
(
@contents
,
"id:
#{
@user
.
id
}
"
,
160
,
12
+
16
*
2
,
0x00
,
0x00
,
0x00
)
@font
.
draw_blended_utf8
(
@contents
,
"Lv:
#{
@user
.
level
}
"
,
160
,
12
+
16
*
3
,
0x00
,
0x00
,
0x00
)
if
@user
.
respond_to?
:level
and
@user
.
level
#TODO:规范化,level是iduel专属的,但是又不太想让iduel来重定义这个window
...
...
lib/window_userlist.rb
View file @
f7dfd90e
...
...
@@ -20,30 +20,18 @@ class Window_UserList < Window_Scrollable
#@contents.set_alpha(RLEACCEL, 80)
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0xFFFFFFFF
)
self
.
items
=
items
#@contents.f
end
def
draw_item
(
index
,
status
=
0
)
case
status
when
0
@font
.
draw_blended_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
(
item_color
(
index
))
)
@font
.
draw_blended_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
@items
[
index
].
color
)
when
1
@font
.
draw_shaded_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
(
item_color
(
index
)
+
@color_over
))
@font
.
draw_shaded_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
(
@items
[
index
].
color
+
@color_over
))
when
2
@font
.
draw_shaded_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
(
item_color
(
index
)
+
@color_click
))
@font
.
draw_shaded_utf8
(
@contents
,
@items
[
index
].
name
,
0
,
item_rect
(
index
)[
1
],
*
(
@items
[
index
].
color
+
@color_click
))
end
end
def
item_color
(
index
)
@items
[
index
].
friend?
?
@color_friend
:
@color
end
#def clear(x=0, y=0, width=@width, height=@height)
# Surface.blit(x, )
#end
#def clear(x=0,y=0,width=@width,height=@height)
# @contents.fill_rect(x,y,width,height,0x66FFFFFF)
#end
def
clicked
#$scene.refresh_rect(*item_rect(@index)){draw_item(@index, 2)} if @index
return
unless
@index
@userwindow
=
Window_User
.
new
(
100
,
100
,
@items
[
@index
])
end
...
...
lib/ygocore/event.rb
View file @
f7dfd90e
#encoding: UTF-8
class
Game_Event
User_Filter
=
/<li>(:::观战:|===决斗1=|===决斗2=)<font color="(?:blue|gray)">(.+?)(\(未认证\)|)<\/font>;<\/li>/
Room_Filter
=
/<div style="width:300px; height:150px; border:1px #ececec solid; float:left;padding:5px; margin:5px;">房间名称:(.+?) (<font color=red>决斗已开始!<\/font>|<font color=blue>等待<\/font>)(<font color="#CC6633" title="竞技场,接受服务器录像、场次统计,非认证玩家不得加入">[竞]<\/font>|)<font size="1">\(ID:(\d+)\)<\/font>
#{
User_Filter
}
+?<\/div>/
def
initialize
end
Room_Filter
=
/<div style="width:300px; height:150px; border:1px #ececec solid; float:left;padding:5px; margin:5px;">房间名称:(.+?) (<font color=(?:\")?red(?:\")?>决斗已开始!<\/font>|<font color=(?:\")?blue(?:\")?>等待<\/font>)(<font color="#CC6633" title="竞技场,接受服务器录像、场次统计,非认证玩家不得加入">\[竞\]<\/font>|)<font size="1">\(ID:(\d+)\)<\/font>
#{
User_Filter
}
+?<\/div>/
class
AllRooms
<
Game_Event
def
self
.
parse
(
info
)
@rooms
=
[]
info
.
scan
(
Room_Filter
)
do
|
name
,
status
,
p
rivate
,
id
|
info
.
scan
(
Room_Filter
)
do
|
name
,
status
,
p
vp
,
id
|
player1
=
player2
=
nil
$&
.
scan
(
User_Filter
)
do
|
player
,
name
,
certified
|
if
player
[
"1"
]
player1
=
User
.
new
(
name
.
to_sym
,
name
)
player1
=
User
.
new
(
name
.
to_sym
,
name
,
certified
.
empty?
)
elsif
player
[
"2"
]
player2
=
User
.
new
(
name
.
to_sym
,
name
)
player2
=
User
.
new
(
name
.
to_sym
,
name
,
certified
.
empty?
)
end
end
room
=
Room
.
new
(
id
.
to_i
,
name
,
player1
,
player2
,
false
,
status
[
"等待"
]
?
[
0
,
0
,
255
]
:
[
255
,
0
,
0
])
if
status
[
"等待"
]
@rooms
.
unshift
room
else
@rooms
<<
room
end
@rooms
<<
Room
.
new
(
id
.
to_i
,
name
,
player1
,
player2
,
!!
private
,
status
[
"等待"
]
?
[
0
,
0
,
255
]
:
[
255
,
0
,
0
])
end
self
.
new
@rooms
end
end
class
AllUsers
<
Game_Event
def
self
.
parse
(
info
)
@users
=
[]
info
.
scan
(
User_Filter
)
do
|
player
,
name
,
certified
|
@users
<<
User
.
new
(
name
.
to_sym
,
name
,
certified
.
empty?
)
end
self
.
new
@users
end
end
end
\ No newline at end of file
lib/ygocore/game.rb
View file @
f7dfd90e
...
...
@@ -6,7 +6,6 @@ class Ygocore < Game
Port
=
7911
Server
=
'221.226.68.62'
require
'win32api'
WM_LBUTTONDOWN
=
0x201
WM_LBUTTONUP
=
0x202
VK_CONTROL
=
0x11
...
...
@@ -15,13 +14,11 @@ class Ygocore < Game
VK_TAB
=
0x09
VK_RETURN
=
0x0D
KEYEVENTF_KEYUP
=
0x02
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'
)
def
initialize
super
load
File
.
expand_path
(
'event.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'user.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'room.rb'
,
File
.
dirname
(
__FILE__
))
end
def
login
(
username
,
password
)
connect
...
...
@@ -51,7 +48,7 @@ class Ygocore < Game
next
if
line
[
0
,
1
]
==
'#'
field
,
contents
=
line
.
chomp
.
split
(
' = '
,
2
)
system_conf
[
field
]
=
contents
system_conf
[
'nickname'
]
=
"
#{
@user
.
name
}
$
#{
@password
}
"
system_conf
[
'nickname'
]
=
"
#{
@user
.
name
}
#{
"$"
unless
@password
.
empty?
}
#{
@password
}
"
system_conf
[
'lastip'
]
=
Server
system_conf
[
'lastport'
]
=
Port
.
to_s
end
...
...
@@ -61,10 +58,16 @@ class Ygocore < Game
require
'launchy'
Launchy
.
open
$config
[
'ygocore'
][
'path'
]
#初始化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'
)
#获取句柄
hwnd
=
nil
100
.
times
do
if
(
hwnd
=
FindWindow
.
call
(
'CIrrDeviceWin32'
,
nil
))
!=
0
if
(
hwnd
=
@@
FindWindow
.
call
(
'CIrrDeviceWin32'
,
nil
))
!=
0
break
else
sleep
0.1
...
...
@@ -72,24 +75,24 @@ class Ygocore < Game
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
))
@@
SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
507
,
242
))
@@
SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
507
,
242
))
sleep
0.2
require
'win32/clipboard'
Win32
::
Clipboard
.
set_data
(
room
.
name
)
SetForegroundWindow
.
call
(
hwnd
)
SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
380
,
500
))
SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
380
,
500
))
K
eybd_event
.
call
(
VK_CONTROL
,
0
,
0
,
0
)
K
eybd_event
.
call
(
VK_A
,
0
,
0
,
0
)
#全选以避免密码处已经有字的情况,正常情况下应该无用
K
eybd_event
.
call
(
VK_A
,
0
,
KEYEVENTF_KEYUP
,
0
)
K
eybd_event
.
call
(
VK_V
,
0
,
0
,
0
)
K
eybd_event
.
call
(
VK_V
,
0
,
KEYEVENTF_KEYUP
,
0
)
K
eybd_event
.
call
(
VK_CONTROL
,
0
,
KEYEVENTF_KEYUP
,
0
)
K
eybd_event
.
call
(
VK_TAB
,
0
,
0
,
0
)
K
eybd_event
.
call
(
VK_TAB
,
0
,
KEYEVENTF_KEYUP
,
0
)
K
eybd_event
.
call
(
VK_RETURN
,
0
,
0
,
0
)
K
eybd_event
.
call
(
VK_RETURN
,
0
,
KEYEVENTF_KEYUP
,
0
)
Win32
::
Clipboard
.
set_data
(
room
.
name
.
encode
(
"GBK"
).
force_encoding
(
"UTF-8"
)
)
@@
SetForegroundWindow
.
call
(
hwnd
)
@@
SendMessage
.
call
(
hwnd
,
WM_LBUTTONDOWN
,
0
,
MAKELPARAM
(
380
,
500
))
@@
SendMessage
.
call
(
hwnd
,
WM_LBUTTONUP
,
0
,
MAKELPARAM
(
380
,
500
))
@@k
eybd_event
.
call
(
VK_CONTROL
,
0
,
0
,
0
)
@@k
eybd_event
.
call
(
VK_A
,
0
,
0
,
0
)
#全选以避免密码处已经有字的情况,正常情况下应该无用
@@k
eybd_event
.
call
(
VK_A
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@k
eybd_event
.
call
(
VK_V
,
0
,
0
,
0
)
@@k
eybd_event
.
call
(
VK_V
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@k
eybd_event
.
call
(
VK_CONTROL
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@k
eybd_event
.
call
(
VK_TAB
,
0
,
0
,
0
)
@@k
eybd_event
.
call
(
VK_TAB
,
0
,
KEYEVENTF_KEYUP
,
0
)
@@k
eybd_event
.
call
(
VK_RETURN
,
0
,
0
,
0
)
@@k
eybd_event
.
call
(
VK_RETURN
,
0
,
KEYEVENTF_KEYUP
,
0
)
else
Widget_Msgbox
.
new
(
"加入房间"
,
'ygocore运行失败'
)
end
...
...
@@ -98,14 +101,16 @@ class Ygocore < Game
$scene
=
Scene_Lobby
.
new
end
def
refresh
#
Thread.new do
Thread
.
new
do
begin
open
(
'http://sh.convnet.net:7922/'
)
do
|
file
|
file
.
set_encoding
(
"GBK"
)
Game_Event
.
push
Game_Event
::
AllRooms
.
parse
file
.
read
.
encode
(
"UTF-8"
)
info
=
file
.
read
.
encode
(
"UTF-8"
)
Game_Event
.
push
Game_Event
::
AllUsers
.
parse
info
Game_Event
.
push
Game_Event
::
AllRooms
.
parse
info
end
end
end
#end
end
private
def
connect
...
...
lib/ygocore/room.rb
0 → 100644
View file @
f7dfd90e
# To change this template, choose Tools | Templates
# and open the template in the editor.
class
Room
def
full?
color
==
[
255
,
0
,
0
]
#方法不规范 凑合用
end
end
lib/ygocore/user.rb
0 → 100644
View file @
f7dfd90e
# To change this template, choose Tools | Templates
# and open the template in the editor.
class
User
def
initialize
(
id
,
name
=
""
,
certified
=
true
)
@id
=
id
@name
=
name
@certified
=
certified
end
def
set
(
id
,
name
=
:keep
,
certified
=
:keep
)
@id
=
id
unless
id
==
:keep
@name
=
name
unless
name
==
:keep
@certified
=
certified
unless
certified
==
:keep
end
def
color
@certified
?
[
0
,
0
,
255
]
:
[
128
,
128
,
128
]
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