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
fa9b2490
Commit
fa9b2490
authored
Feb 27, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
公告
parent
e9c3391f
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
88 additions
and
47 deletions
+88
-47
lib/iduel/event.rb
lib/iduel/event.rb
+2
-6
lib/iduel/game.rb
lib/iduel/game.rb
+18
-1
lib/iduel/window_login.rb
lib/iduel/window_login.rb
+5
-4
lib/nbx/game.rb
lib/nbx/game.rb
+4
-2
lib/nbx/window_login.rb
lib/nbx/window_login.rb
+0
-8
lib/scene_duel.rb
lib/scene_duel.rb
+12
-10
lib/scene_lobby.rb
lib/scene_lobby.rb
+6
-1
lib/scene_login.rb
lib/scene_login.rb
+8
-7
lib/window_announcements.rb
lib/window_announcements.rb
+25
-0
lib/window_cardinfo.rb
lib/window_cardinfo.rb
+1
-1
lib/window_gameselect.rb
lib/window_gameselect.rb
+2
-2
lib/window_login.rb
lib/window_login.rb
+2
-2
lib/window_userinfo.rb
lib/window_userinfo.rb
+3
-3
No files found.
lib/iduel/event.rb
View file @
fa9b2490
...
...
@@ -9,26 +9,22 @@ class Game_Event
Login
when
"C"
AllUsers
when
"F"
when
"F"
,
"Q"
#F=加入观战
Join
when
"G"
Watch
when
"H"
when
"H"
,
"M"
Leave
when
"J"
Action
when
"K"
WatchAction
when
"M"
Leave
when
'N'
PrivateChat
when
"O"
Chat
when
"P"
AllRooms
when
"Q"
NewRoom
when
"R"
QROOMOK
#卡表
else
...
...
lib/iduel/game.rb
View file @
fa9b2490
#encoding: UTF-8
load
File
.
expand_path
(
'window_login.rb'
,
File
.
dirname
(
__FILE__
))
require
'open-uri'
class
Iduel
<
Game
Version
=
"20110131"
Server
=
"iduel.ocgsoft.cn"
...
...
@@ -89,7 +90,6 @@ class Iduel < Game
private
def
connect
require
'socket'
require
'open-uri'
begin
@conn
=
TCPSocket
.
new
(
Server
,
Port
)
#TODO: 阻塞优化,注意login。下面注释掉的两句实现connect无阻塞,但是login依然会阻塞所以只优化这里没有意义
#@conn = Socket.new(:INET, :STREAM)
...
...
@@ -120,4 +120,21 @@ class Iduel < Game
info
.
gsub!
(
"
\n
"
,
"
\r\n
"
)
(
@conn
.
write
info
)
rescue
Game_Event
.
push
Game_Event
::
Error
.
new
(
$!
.
class
.
to_s
,
$!
.
message
)
end
#公告
$config
[
'iDuel'
][
'announcements'
]
||=
{
"正在读取公告..."
=>
nil
}
Thread
.
new
do
begin
open
(
'http://www.duelcn.com/topic-Announce.html'
)
do
|
file
|
file
.
set_encoding
"GBK"
announcements
=
{}
file
.
read
.
scan
(
/<li><em>.*?<\/em><a href="(.*?)" title="(.*?)" target="_blank">.*?<\/a><\/li>/
).
each
do
|
url
,
title
|
announcements
[
title
.
encode
(
"UTF-8"
)]
=
"http://www.duelcn.com/
#{
url
}
"
end
$config
[
'iDuel'
][
'announcements'
].
replace
announcements
save_config
end
rescue
Exception
=>
exception
$log
.
error
(
'公告'
)
{[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)}
end
end
end
\ No newline at end of file
lib/iduel/window_login.rb
View file @
fa9b2490
#encoding: UTF-8
class
Window_Login
def
clicked
return
if
@last_clicked
and
Time
.
now
-
@last_clicked
<
3
#防止重复点击
case
@index
when
:login
Widget_Msgbox
.
new
(
"iDuel"
,
"正在登陆"
)
...
...
@@ -10,13 +11,13 @@ class Window_Login
$config
[
$config
[
'game'
]][
'password'
]
=
@remember_password
.
checked?
?
@password_inputbox
.
value
:
nil
save_config
$game
.
login
(
@username_inputbox
.
value
,
@password_inputbox
.
value
)
@last_clicked
=
Time
.
now
when
:register
require
'launchy'
Launchy
.
open
(
Iduel
::
Register_Url
)
@last_clicked
=
Time
.
now
when
:replay
require
'tk'
#由于Tk对话框点击取消的时候SDL会再识别一次点击,所以这里做一下处理,对两次间隔小于1s的点击忽略
return
if
@replay_clicked
and
Time
.
now
-
@replay_clicked
<
1
file
=
Tk
.
getOpenFile
if
!
file
.
empty?
$game
=
Iduel
.
new
...
...
@@ -26,7 +27,7 @@ class Window_Login
$log
.
debug
(
'iduel window_login'
){
'loading reply file'
}
$scene
=
Scene_Replay
.
new
Replay
.
load
file
end
@
replay
_clicked
=
Time
.
now
@
last
_clicked
=
Time
.
now
end
end
end
end
\ No newline at end of file
lib/nbx/game.rb
View file @
fa9b2490
#encoding: UTF-8
load
File
.
expand_path
(
'window_login.rb'
,
File
.
dirname
(
__FILE__
))
class
NBX
<
Game
Version
=
"20090622"
Port
=
2583
...
...
@@ -146,4 +145,7 @@ class NBX < Game
end
end
$game
=
NBX
.
new
$config
[
$config
[
'game'
]][
'username'
]
||=
ENV
[
'USERNAME'
]
save_config
$game
.
login
$config
[
$config
[
'game'
]][
'username'
]
lib/nbx/window_login.rb
deleted
100644 → 0
View file @
e9c3391f
#encoding: UTF-8
class
Window_Login
def
initialize
(
*
args
)
$game
=
NBX
.
new
username
=
$config
[
'username'
]
&&
!
$config
[
'username'
].
empty?
?
$config
[
'username'
]
:
$_ENV
[
'username'
]
$game
.
login
username
end
end
lib/scene_duel.rb
View file @
fa9b2490
...
...
@@ -148,16 +148,15 @@ class Scene_Duel < Scene
refresh
when
Game_Event
::
Leave
$scene
=
Scene_Lobby
.
new
when
Game_Event
::
NewRoom
if
event
.
room
==
$game
.
room
@player_lp_window
.
player
=
$game
.
room
.
player1
@opponent_lp_window
.
player
=
$game
.
room
.
player2
player
=
$game
.
room
.
player1
==
$game
.
user
?
$game
.
room
.
player2
:
$game
.
room
.
player1
if
player
notify_send
(
"对手加入房间"
,
"
#{
player
.
name
}
(
#{
player
.
id
}
)"
)
else
notify_send
(
"对手离开房间"
,
"对手离开房间"
)
end
when
Game_Event
::
Join
$game
.
room
=
event
.
room
@player_lp_window
.
player
=
$game
.
room
.
player1
@opponent_lp_window
.
player
=
$game
.
room
.
player2
player
=
$game
.
room
.
player1
==
$game
.
user
?
$game
.
room
.
player2
:
$game
.
room
.
player1
if
player
notify_send
(
"对手加入房间"
,
"
#{
player
.
name
}
(
#{
player
.
id
}
)"
)
else
notify_send
(
"对手离开房间"
,
"对手离开房间"
)
end
else
super
...
...
@@ -177,6 +176,9 @@ class Scene_Duel < Scene
@opponent_lp_window
.
lp
=
$game
.
opponent_field
.
lp
end
def
terminate
unless
$scene
.
is_a?
Scene_Lobby
or
$scene
.
is_a?
Scene_Duel
$game
.
exit
end
save_replay
super
end
...
...
lib/scene_lobby.rb
View file @
fa9b2490
...
...
@@ -11,6 +11,7 @@ class Scene_Lobby < Scene
require_relative
'window_roomlist'
require_relative
'window_chat'
require_relative
'chatmessage'
require_relative
'scene_duel'
attr_reader
:chat_window
def
start
WM
::
set_caption
(
"MyCard -
#{
$config
[
'game'
]
}
-
#{
$game
.
user
.
name
}
(
#{
$game
.
user
.
id
}
)"
,
"MyCard"
)
...
...
@@ -81,7 +82,6 @@ class Scene_Lobby < Scene
when
Game_Event
::
AllRooms
@roomlist
.
items
=
$game
.
rooms
when
Game_Event
::
Join
require_relative
'scene_duel'
$scene
=
Scene_Duel
.
new
(
event
.
room
,
Deck
.
load
(
"test1.TXT"
))
when
Game_Event
::
Watch
require_relative
'scene_watch'
...
...
@@ -115,4 +115,9 @@ class Scene_Lobby < Scene
end
end
end
def
terminate
unless
$scene
.
is_a?
Scene_Lobby
or
$scene
.
is_a?
Scene_Duel
$game
.
exit
end
end
end
\ No newline at end of file
lib/scene_login.rb
View file @
fa9b2490
...
...
@@ -5,20 +5,21 @@
# login
#==============================================================================
require_relative
'window_gameselect'
require_relative
'window_announcements'
require_relative
'window_login'
require_relative
'scene_replay'
class
Scene_Login
<
Scene
def
start
WM
::
set_caption
(
"MyCard"
,
"MyCard"
)
@background
=
Surface
.
load
(
"graphics/login/background.png"
).
display_format
@gameselect_window
=
Window_GameSelect
.
new
(
117
,
269
,
$config
[
"game"
])
$config
[
'game'
]
=
'iDuel'
#临时修补点击过一次局域网之后无限进入局域网的问题
@gameselect_window
=
Window_GameSelect
.
new
(
117
,
269
)
@announcements_window
=
Window_Announcements
.
new
(
313
,
265
,
600
,
24
)
end
#def handle(event)
# case event
# when Event::Active
# if event.gain
# end
#end
def
update
@announcements_window
.
update
super
end
def
handle_game
(
event
)
case
event
when
Game_Event
::
Login
...
...
lib/window_announcements.rb
0 → 100644
View file @
fa9b2490
class
Window_Announcements
<
Window
def
initialize
(
x
,
y
,
width
,
height
)
super
(
x
,
y
,
width
,
height
)
@items
=
$config
[
$config
[
'game'
]][
'announcements'
]
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
18
)
@color
=
[
44
,
64
,
78
]
@last_announcement
=
@items
.
first
refresh
end
def
refresh
clear
@font
.
draw_blended_utf8
(
@contents
,
@items
.
first
[
0
],
0
,
0
,
*
@color
)
end
def
update
if
@items
.
first
!=
@last_announcement
refresh
@last_announcement
=
@items
.
first
end
super
end
def
clicked
require
'launchy'
Launchy
.
open
(
@items
.
first
[
1
])
if
@items
.
first
[
1
]
end
end
lib/window_cardinfo.rb
View file @
fa9b2490
...
...
@@ -35,7 +35,7 @@ class Window_CardInfo < Window
@contents
.
put
@card
.
image
,
0
,
0
@font
.
draw_blended_utf8
(
@contents
,
"[
#{
@card
.
name
}
]"
,
160
,
0
,
0xFF
,
0xFF
,
0x55
)
@font
.
draw_blended_utf8
(
@contents
,
"
卡类:
#{
@card
.
card_type
}
"
,
160
,
WLH
,
0xFF
,
0xFF
,
0x55
)
@font
.
draw_blended_utf8
(
@contents
,
"
#{
@card
.
card_type
}
"
,
160
,
WLH
,
0xFF
,
0xFF
,
0x55
)
if
@card
.
monster?
@font
.
draw_blended_utf8
(
@contents
,
"种族:
#{
@card
.
type
}
"
,
160
,
WLH
*
2
,
0xFF
,
0xFF
,
0xFF
)
@font
.
draw_blended_utf8
(
@contents
,
"星级:
#{
@card
.
level
}
"
,
160
,
WLH
*
3
,
0xFF
,
0xFF
,
0xFF
)
...
...
lib/window_gameselect.rb
View file @
fa9b2490
#encoding: UTF-8
class
Window_GameSelect
<
Window_List
WLH
=
56
def
initialize
(
x
,
y
,
game_name
=
nil
)
def
initialize
(
x
,
y
)
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
24
)
@color
=
[
255
,
255
,
255
]
@game_color
=
[
47
,
156
,
192
]
...
...
@@ -23,7 +23,7 @@ class Window_GameSelect < Window_List
@button
=
Surface
.
load
(
"graphics/login/game_background.png"
)
#@button.set_alpha(RLEACCEL,255)
self
.
items
=
@items
self
.
index
=
@items
.
find_index
{
|
game
|
game
[
"name"
]
==
game_name
}
||
0
self
.
index
=
@items
.
find_index
{
|
game
|
game
[
"name"
]
==
$config
[
'game'
]
}
||
0
clicked
refresh
end
...
...
lib/window_login.rb
View file @
fa9b2490
...
...
@@ -8,9 +8,9 @@ class Window_Login < Window
@password
=
password
@button
=
Surface
.
load
(
"graphics/login/button.png"
)
super
(
x
,
y
,
597
,
338
)
@username_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
80
,
165
,
WLH
){
@password_inputbox
.
clicked
;
false
}
@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
@password_inputbox
=
Widget_InputBox
.
new
(
@x
+
192
,
@y
+
125
,
165
,
WLH
){
Widget_InputBox
.
determine
;
self
.
index
=
:login
;
clicked
;
false
}
@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
@color
=
[
255
,
255
,
255
]
...
...
lib/window_userinfo.rb
View file @
fa9b2490
...
...
@@ -8,7 +8,7 @@
class
Window_UserInfo
<
Window
def
initialize
(
x
,
y
,
user
)
@avatar_boarder
=
Surface
.
load
(
"graphics/lobby/avatar_boader.png"
)
super
(
x
,
y
,
2
4
0
,
144
)
super
(
x
,
y
,
2
8
0
,
144
)
@font
=
TTF
.
open
(
'fonts/WenQuanYi Micro Hei.ttf'
,
16
)
@user
=
user
@background
=
Surface
.
load
(
"graphics/lobby/userinfo.png"
).
display_format
...
...
@@ -26,8 +26,8 @@ class Window_UserInfo < Window
@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
#TODO:规范化,level是iduel专属的,但是又不太想让iduel来重定义这个window
@font
.
draw_blended_utf8
(
@contents
,
"经验:
#{
@user
.
exp
}
"
,
160
,
12
+
16
*
4
,
0x00
,
0x00
,
0x00
)
if
@user
.
respond_to?
:exp
@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
@font
.
draw_blended_utf8
(
@contents
,
"经验:
#{
@user
.
exp
}
"
,
160
,
12
+
16
*
4
,
0x00
,
0x00
,
0x00
)
if
@user
.
respond_to?
:exp
and
@user
.
exp
end
def
dispose
@thread
.
exit
...
...
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