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
74d56beb
Commit
74d56beb
authored
Dec 29, 2011
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善登陆观战replay
parent
4faa1e51
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
229 additions
and
167 deletions
+229
-167
.gitignore
.gitignore
+1
-0
graphics/login/button.png
graphics/login/button.png
+0
-0
graphics/login/game_background.png
graphics/login/game_background.png
+0
-0
lib/action.rb
lib/action.rb
+2
-3
lib/fpstimer.rb
lib/fpstimer.rb
+16
-15
lib/iduel/action.rb
lib/iduel/action.rb
+2
-3
lib/iduel/game.rb
lib/iduel/game.rb
+17
-14
lib/iduel/game.yml
lib/iduel/game.yml
+1
-1
lib/iduel/replay.rb
lib/iduel/replay.rb
+12
-6
lib/iduel/user.rb
lib/iduel/user.rb
+5
-1
lib/iduel/window_login.rb
lib/iduel/window_login.rb
+10
-0
lib/main.rb
lib/main.rb
+13
-5
lib/nbx/action.rb
lib/nbx/action.rb
+19
-20
lib/nbx/game.rb
lib/nbx/game.rb
+28
-19
lib/replay.rb
lib/replay.rb
+1
-2
lib/scene.rb
lib/scene.rb
+23
-2
lib/scene_duel.rb
lib/scene_duel.rb
+1
-10
lib/scene_hall.rb
lib/scene_hall.rb
+1
-9
lib/scene_login.rb
lib/scene_login.rb
+8
-10
lib/scene_replay.rb
lib/scene_replay.rb
+3
-3
lib/scene_title.rb
lib/scene_title.rb
+2
-1
lib/user.rb
lib/user.rb
+3
-0
lib/window.rb
lib/window.rb
+6
-0
lib/window_action.rb
lib/window_action.rb
+1
-1
lib/window_chat.rb
lib/window_chat.rb
+2
-2
lib/window_field.rb
lib/window_field.rb
+17
-17
lib/window_gameselect.rb
lib/window_gameselect.rb
+1
-6
lib/window_login.rb
lib/window_login.rb
+23
-6
lib/window_lp.rb
lib/window_lp.rb
+1
-1
lib/window_user.rb
lib/window_user.rb
+6
-6
lib/window_userlist.rb
lib/window_userlist.rb
+4
-4
No files found.
.gitignore
View file @
74d56beb
...
...
@@ -2,6 +2,7 @@
/ruby/
/pkg/
/log.log
/err.log
/replay/*
/graphics/avatars/*_*.png
Thumbs.db
\ No newline at end of file
graphics/login/button.png
View file @
74d56beb
This diff was suppressed by a .gitattributes entry.
graphics/login/game_background.png
View file @
74d56beb
This diff was suppressed by a .gitattributes entry.
lib/action.rb
View file @
74d56beb
...
...
@@ -149,8 +149,7 @@ class Action
end
else
card
=
@card
==
:deck
?
player_field
.
deck
.
first
:
Game_Card
.
new
(
@card
)
$log
.
info
"似乎凭空产生了卡片?"
p
self
$log
.
warn
(
"似乎凭空产生了卡片?"
){
self
.
inspect
}
end
if
@position
if
@position
==
:"face-up"
...
...
@@ -160,7 +159,7 @@ class Action
card
.
position
=
:attack
end
else
card
.
position
=
:attack
card
.
position
=
@position
end
end
if
@to_pos
...
...
lib/fpstimer.rb
View file @
74d56beb
...
...
@@ -8,7 +8,6 @@ class FPSTimer
# +accurary+ is the accurary of sleep/SDL.delay in milisecond
def
initialize
(
fps
=
60
,
accurary
=
10
,
skip_limit
=
15
)
@fps
=
fps
@spf
=
(
1.0
/
@fps
)
@accurary
=
accurary
/
1000.0
@skip_limit
=
skip_limit
reset
...
...
@@ -16,7 +15,7 @@ class FPSTimer
# reset timer, you should call just before starting loop
def
reset
@old
=
Time
.
now
.
to_f
@old
=
get_ticks
@skip
=
0
@real_fps
=
@fps
@frame_count
=
0
...
...
@@ -27,25 +26,27 @@ class FPSTimer
# execute given block and wait
def
wait_frame
n
xt
=
@old
+
@spf
if
(
sleeptime
=
nxt
-
Time
.
now
.
to_f
)
>
0
sleep
(
sleeptime
)
n
ow
=
get_ticks
nxt
=
@old
+
(
1.0
/
@fps
)
if
nxt
>
now
||
@skip
>
@skip_limit
yield
@skip
=
0
wait
(
nxt
)
@old
=
nxt
else
@skip
+=
1
@total_skip
+=
1
@old
=
get_ticks
end
@old
=
nxt
calc_real_fps
end
private
def
wait
(
nxt
)
while
nxt
>
get_ticks
+
@accurary
sleep
(
@accurary
-
0.005
)
@count_sleep
+=
1
end
while
nxt
>
get_ticks
# busy loop, do nothing
end
p
nxt
sleeptime
=
nxt
-
get_ticks
sleep
(
sleeptime
)
if
sleeptime
>
0
end
def
get_ticks
...
...
@@ -61,4 +62,4 @@ class FPSTimer
@fps_old
=
now
end
end
end
\ No newline at end of file
end
lib/iduel/action.rb
View file @
74d56beb
...
...
@@ -313,7 +313,7 @@ class Action
end
class
TurnEnd
def
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→=[0:0:0]==回合结束==<
#{
@turn
}
>=[0]
\n
"
+
@field
.
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→=[0:0:0]==回合结束==<
#{
@turn
}
>=[0]
\n
"
+
@field
.
escape
+
"
#{
from_player
?
'◎'
:
'●'
}
→\\"
end
end
class
Shuffle
...
...
@@ -478,8 +478,7 @@ class Game_Field
@field
[
6
..
10
].
collect
{
|
card
|
" <
#{
"
#{
Action
.
escape_position_short
(
card
)
}
|
#{
card
.
position
==
:set
?
'??'
:
"[
#{
card
.
card_type
}
][
#{
card
.
name
}
]
#{
card
.
atk
}#{
' '
+
card
.
def
.
to_s
}
"
}
"
if
card
}
>
\n
"
}.
join
+
"后场:"
+
@field
[
1
..
5
].
collect
{
|
card
|
"<
#{
card
.
position
==
:set
?
'??'
:
card
.
escape
if
card
}
>"
}.
join
+
"
\n
场地|<
#{
@field
[
0
]
?
@field
[
0
].
escape
:
'无'
}
>
\n
"
+
"◎→\\"
"
\n
场地|<
#{
@field
[
0
]
?
@field
[
0
].
escape
:
'无'
}
>
\n
"
end
def
self
.
parse
(
str
)
...
...
lib/iduel/game.rb
View file @
74d56beb
...
...
@@ -19,23 +19,26 @@ class Iduel < Game
def
connect
require
'socket'
require
'open-uri'
@conn
=
TCPSocket
.
new
(
Server
,
Port
)
#TODO: 阻塞优化,注意login。下面注释掉的两句实现connect无阻塞,但是login依然会阻塞所以只优化这里没有意义
#@conn = Socket.new(:INET, :STREAM)
@conn
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
@recv
=
Thread
.
new
do
begin
#@conn.connect Socket.pack_sockaddr_in(Port, Server)
recv
@conn
.
gets
(
RS
)
while
@conn
rescue
=>
exception
Game_Event
.
push
Game_Event
::
Error
.
new
(
exception
.
class
.
to_s
,
exception
.
message
)
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
ensure
self
.
exit
begin
@conn
=
TCPSocket
.
new
(
Server
,
Port
)
#TODO: 阻塞优化,注意login。下面注释掉的两句实现connect无阻塞,但是login依然会阻塞所以只优化这里没有意义
#@conn = Socket.new(:INET, :STREAM)
@conn
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
@recv
=
Thread
.
new
do
begin
#@conn.connect Socket.pack_sockaddr_in(Port, Server)
recv
@conn
.
gets
(
RS
)
while
@conn
rescue
=>
exception
Game_Event
.
push
Game_Event
::
Error
.
new
(
exception
.
class
.
to_s
,
exception
.
message
)
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
ensure
self
.
exit
end
end
rescue
=>
exception
Game_Event
.
push
Game_Event
::
Error
.
new
(
exception
.
class
.
to_s
,
exception
.
message
)
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
end
end
def
login
(
username
,
password
)
connect
md5
=
Digest
::
MD5
.
hexdigest
(
password
)
...
...
lib/iduel/game.yml
View file @
74d56beb
name
:
iduel
\ No newline at end of file
name
:
iDuel
\ No newline at end of file
lib/iduel/replay.rb
View file @
74d56beb
...
...
@@ -5,8 +5,8 @@ class Replay
Opponent_Filter
=
/^(.+?)\((\d+)\)\(\d+:\d+:\d+\): (?:\r)?\n \[\d+\] ●→/
attr_accessor
:room
,
:player1
,
:player2
,
:actions
def
add
(
action
)
# user = action.from_player ? $game.player1 : $game.player2
# @file.write("#{user.name}(#{user.id}):\r\n#{action.escape}\r\n")
# user = action.from_player ? $game.player1 : $game.player2
# @file.write("#{user.name}(#{user.id}):\r\n#{action.escape}\r\n")
end
def
self
.
load
(
filename
)
#TODO:效率优化
...
...
@@ -14,10 +14,16 @@ class Replay
file
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
result
=
self
.
new
(
file
)
contents
=
file
.
read
contents
=~
Player_Filter
result
.
player1
=
User
.
new
(
$2
.
to_i
,
$1
)
contents
=~
Opponent_Filter
result
.
player2
=
User
.
new
(
$2
.
to_i
,
$1
)
if
contents
=~
Player_Filter
result
.
player1
=
User
.
new
(
$2
.
to_i
,
$1
)
else
result
.
player1
=
User
.
new
(
0
,
"我"
)
end
if
contents
=~
Opponent_Filter
result
.
player2
=
User
.
new
(
$2
.
to_i
,
$1
)
else
result
.
player2
=
User
.
new
(
1
,
"对手"
)
end
result
.
actions
=
contents
.
split
(
Delimiter
).
collect
do
|
action_str
|
action_str
.
chomp!
action
=
Action
.
parse
action_str
...
...
lib/iduel/user.rb
View file @
74d56beb
...
...
@@ -23,11 +23,11 @@ class User
cache
=
"graphics/avatars/
#{
@id
}
_
#{
size
}
.png"
result
=
Surface
.
load
(
cache
)
rescue
Surface
.
load
(
"graphics/avatars/loading_
#{
size
}
.gif"
)
if
block_given?
yield
result
Thread
.
new
do
open
(
"http://www.duelcn.com/uc_server/avatar.php?uid=
#{
id
-
100000
}
&size=
#{
size
}
"
,
'rb'
)
{
|
io
|
open
(
cache
,
'wb'
)
{
|
c
|
c
.
write
io
.
read
}}
rescue
cache
=
"graphics/avatars/noavatar_
#{
size
}
.gif"
yield
Surface
.
load
cache
end
yield
result
else
result
end
...
...
@@ -47,4 +47,8 @@ class User
def
room
$game
.
rooms
.
find
{
|
room
|
room
.
include?
self
}
end
def
space
require
'launchy'
Launchy
.
open
(
"http://www.duelcn.com/home.php?mod=space&uid=
#{
@id
-
100000
}
"
)
end
end
\ No newline at end of file
lib/iduel/window_login.rb
View file @
74d56beb
...
...
@@ -10,6 +10,16 @@ class Window_Login
when
:register
require
'launchy'
Launchy
.
open
(
Iduel
::
Register_Url
)
when
:replay
require
'tk'
#由于Tk对话框点击取消的时候SDL会再识别一次点击,所以这里做一下处理,对两次间隔小于1s的点击忽略
return
if
@replay_clicked
and
Time
.
now
-
@replay_clicked
<
1
file
=
Tk
.
getOpenFile
@replay_clicked
=
Time
.
now
return
if
file
.
empty?
$game
=
Iduel
.
new
$game
.
user
=
User
.
new
(
0
)
$scene
=
Scene_Replay
.
new
Replay
.
load
file
end
end
end
lib/main.rb
View file @
74d56beb
...
...
@@ -6,6 +6,15 @@ begin
require
'yaml'
$config
=
YAML
.
load_file
(
"config.yml"
)
#读取命令行参数
log
=
"log.log"
ARGV
.
each
do
|
arg
|
case
arg
when
/--log=(.*)/
log
.
replace
$1
end
end
#初始化SDL
require
'sdl'
include
SDL
...
...
@@ -22,12 +31,11 @@ begin
#初始化日志
require
'logger'
if
false
#调试用,由于将$DEBUG设成true时tk库会输出一大坨奇怪的东西,所以这里不能使用$DEBUG
STDOUT
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
if
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
$log
=
Logger
.
new
(
STDOUT
)
else
$log
=
Logger
.
new
(
"log.log"
)
if
log
==
"STDOUT"
#调试用
log
=
STDOUT
log
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
if
RUBY_PLATFORM
[
"win"
]
||
RUBY_PLATFORM
[
"ming"
]
end
$log
=
Logger
.
new
(
log
)
$log
.
info
(
"main"
){
"初始化成功"
}
rescue
Exception
=>
exception
open
(
'error-程序出错请到论坛反馈.txt'
,
'w'
){
|
f
|
f
.
write
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)}
...
...
lib/nbx/action.rb
View file @
74d56beb
...
...
@@ -5,7 +5,8 @@ class Action
PosFilter
=
/((?:手卡|手牌|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组|卡组顶端|\(\d+\)){1,2})/
PositionFilter
=
/(表攻|表守|里守|攻击表示|防守表示|里侧表示|背面守备表示)/
PhaseFilter
=
/(抽卡`阶段|准备`阶段|主`阶段1|战斗`阶段|主`阶段2|结束`阶段)/
FieldFilter
=
/(?:LP:(\d+)\n手卡(?:数)?:(\d+)\n卡组:(\d+)\n墓地:(\d+)\n除外:(\d+)\n前场:\n <(?:
#{
PositionFilter
}
\|
#{
CardFilter
}
)?>\n <(?:
#{
PositionFilter
}
\|
#{
CardFilter
}
)?>\n <(?:
#{
PositionFilter
}
\|
#{
CardFilter
}
)?>\n <(?:
#{
PositionFilter
}
\|
#{
CardFilter
}
)?>\n <(?:
#{
PositionFilter
}
\|
#{
CardFilter
}
)?>\n后场:<
#{
CardFilter
}
?><
#{
CardFilter
}
?><
#{
CardFilter
}
?><
#{
CardFilter
}
?><
#{
CardFilter
}
?>\n场地\|<(?:无|
#{
CardFilter
}
)>\n(?:◎|●)→\\)/
CountersFilter
=
/\((\d+)\)/
FieldFilter
=
/(?:LP:(\d+)\n手卡(?:数)?:(\d+)\n卡组:(\d+)\n墓地:(\d+)\n除外:(\d+)\n前场:\n <(?:
#{
CountersFilter
}
?
#{
PositionFilter
}
\|
#{
CardFilter
}
)?>\n <(?:
#{
CountersFilter
}
?
#{
PositionFilter
}
\|
#{
CardFilter
}
)?>\n <(?:
#{
CountersFilter
}
?
#{
PositionFilter
}
\|
#{
CardFilter
}
)?>\n <(?:
#{
CountersFilter
}
?
#{
PositionFilter
}
\|
#{
CardFilter
}
)?>\n <(?:
#{
CountersFilter
}
?
#{
PositionFilter
}
\|
#{
CardFilter
}
)?>\n后场:<
#{
CardFilter
}
?><
#{
CardFilter
}
?><
#{
CardFilter
}
?><
#{
CardFilter
}
?><
#{
CardFilter
}
?>\n场地\|<(?:无|
#{
CardFilter
}
)>\n(?:◎|●)→\\)/
def
self
.
parse_pos
(
pos
)
if
index
=
pos
.
index
(
"("
)
index
+=
1
...
...
@@ -54,17 +55,17 @@ class Action
:deck
=>
arr
[
2
].
to_i
,
:graveyard
=>
arr
[
3
].
to_i
,
:removed
=>
arr
[
4
].
to_i
,
6
=>
arr
[
5
]
&&
{
:position
=>
parse_position
(
arr
[
5
]),
:card
=>
parse_card
(
arr
[
6
])},
7
=>
arr
[
7
]
&&
{
:position
=>
parse_position
(
arr
[
7
]),
:card
=>
parse_card
(
arr
[
8
])},
8
=>
arr
[
9
]
&&
{
:position
=>
parse_position
(
arr
[
9
]),
:card
=>
parse_card
(
arr
[
10
])},
9
=>
arr
[
11
]
&&
{
:position
=>
parse_position
(
arr
[
11
]),
:card
=>
parse_card
(
arr
[
12
])},
10
=>
arr
[
1
3
]
&&
{
:position
=>
parse_position
(
arr
[
13
]),
:card
=>
parse_card
(
arr
[
14
])},
1
=>
arr
[
15
]
&&
{
:position
=>
arr
[
15
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
15
])},
2
=>
arr
[
16
]
&&
{
:position
=>
arr
[
16
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
16
])},
3
=>
arr
[
17
]
&&
{
:position
=>
arr
[
17
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
17
])},
4
=>
arr
[
18
]
&&
{
:position
=>
arr
[
18
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
18
])},
5
=>
arr
[
19
]
&&
{
:position
=>
arr
[
19
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
19
])},
0
=>
arr
[
2
0
]
&&
{
:position
=>
arr
[
20
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
20
])}
6
=>
arr
[
7
]
&&
{
:counters
=>
arr
[
5
].
to_i
,
:position
=>
parse_position
(
arr
[
6
]),
:card
=>
parse_card
(
arr
[
7
])},
7
=>
arr
[
10
]
&&
{
:counters
=>
arr
[
8
].
to_i
,
:position
=>
parse_position
(
arr
[
9
]),
:card
=>
parse_card
(
arr
[
10
])},
8
=>
arr
[
13
]
&&
{
:counters
=>
arr
[
11
].
to_i
,
:position
=>
parse_position
(
arr
[
12
]),
:card
=>
parse_card
(
arr
[
13
])},
9
=>
arr
[
16
]
&&
{
:counters
=>
arr
[
14
].
to_i
,
:position
=>
parse_position
(
arr
[
15
]),
:card
=>
parse_card
(
arr
[
16
])},
10
=>
arr
[
1
9
]
&&
{
:counters
=>
arr
[
17
].
to_i
,
:position
=>
parse_position
(
arr
[
18
]),
:card
=>
parse_card
(
arr
[
19
])},
1
=>
arr
[
20
]
&&
{
:position
=>
arr
[
20
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
20
])},
2
=>
arr
[
21
]
&&
{
:position
=>
arr
[
21
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
21
])},
3
=>
arr
[
22
]
&&
{
:position
=>
arr
[
22
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
22
])},
4
=>
arr
[
23
]
&&
{
:position
=>
arr
[
23
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
23
])},
5
=>
arr
[
24
]
&&
{
:position
=>
arr
[
24
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
24
])},
0
=>
arr
[
2
5
]
&&
{
:position
=>
arr
[
25
]
==
"??"
?
:
set
:
:attack
,
:card
=>
parse_card
(
arr
[
25
])}
}
end
def
self
.
parse_position
(
position
)
...
...
@@ -166,7 +167,7 @@ class Action
end
end
def
self
.
parse
(
str
)
from_player
=
false
from_player
=
nil
case
str
when
/^\[(\d+)\] (.*)$/m
id
=
$1
.
to_i
...
...
@@ -206,7 +207,7 @@ class Action
when
"卡组洗切"
,
"切洗卡组"
Shuffle
.
new
from_player
when
"查看卡组"
ViewDeck
.
new
"查看卡组"
ViewDeck
.
new
from_player
when
"将顶牌放回卡组底部"
ReturnToDeckBottom
.
new
(
from_player
,
:deck
)
when
/抽取\((\d+)\)张卡/
...
...
@@ -261,6 +262,8 @@ class Action
Flip
.
new
(
from_player
,
parse_pos
(
$1
),
parse_card
(
$2
))
when
/
#{
PhaseFilter
}
/
ChangePhase
.
new
(
from_player
,
parse_phase
(
$1
))
when
/LP(损失|回复|变成)<(-?\d+)>/
LP
.
new
(
from_player
,
case
$1
when
"损失"
;
:lose
;
when
"回复"
;
:increase
;
when
"变成"
;
:become
end
,
$2
.
to_i
)
else
Unknown
.
new
str
end
...
...
@@ -278,9 +281,6 @@ class Action
def
escape
inspect
end
def
run
$game
.
action
self
if
@from_player
end
class
FirstToGo
def
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→[11年3月1日禁卡表]先攻"
...
...
@@ -313,7 +313,7 @@ class Action
end
class
TurnEnd
def
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→=[0:0:0]==回合结束==<
#{
@turn
}
>=[0]
\n
"
+
@field
.
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→=[0:0:0]==回合结束==<
#{
@turn
}
>=[0]
\n
"
+
@field
.
escape
+
"
#{
from_player
?
'◎'
:
'●'
}
→\\"
end
end
class
Shuffle
...
...
@@ -478,8 +478,7 @@ class Game_Field
@field
[
6
..
10
].
collect
{
|
card
|
" <
#{
"
#{
Action
.
escape_position_short
(
card
)
}
|
#{
card
.
position
==
:set
?
'??'
:
"[
#{
card
.
card_type
}
][
#{
card
.
name
}
]
#{
card
.
atk
}#{
' '
+
card
.
def
.
to_s
}
"
}
"
if
card
}
>
\n
"
}.
join
+
"后场:"
+
@field
[
1
..
5
].
collect
{
|
card
|
"<
#{
card
.
position
==
:set
?
'??'
:
card
.
escape
if
card
}
>"
}.
join
+
"
\n
场地|<
#{
@field
[
0
]
?
@field
[
0
].
escape
:
'无'
}
>
\n
"
+
"◎→\\"
"
\n
场地|<
#{
@field
[
0
]
?
@field
[
0
].
escape
:
'无'
}
>
\n
"
end
def
self
.
parse
(
str
)
...
...
lib/nbx/game.rb
View file @
74d56beb
...
...
@@ -11,12 +11,16 @@ class NBX < Game
require
'open-uri'
load
File
.
expand_path
(
'action.rb'
,
File
.
dirname
(
__FILE__
))
load
File
.
expand_path
(
'event.rb'
,
File
.
dirname
(
__FILE__
))
@conn_hall
=
UDPSocket
.
new
@conn_hall
.
setsockopt
(
Socket
::
SOL_SOCKET
,
Socket
::
SO_BROADCAST
,
true
)
@conn_hall
.
bind
(
'0.0.0.0'
,
Port
)
@recv_hall
=
Thread
.
new
{
recv
*
@conn_hall
.
recvfrom
(
1024
)
while
@conn_hall
}
Thread
.
abort_on_exception
=
true
begin
@conn_hall
=
UDPSocket
.
new
@conn_hall
.
setsockopt
(
Socket
::
SOL_SOCKET
,
Socket
::
SO_BROADCAST
,
true
)
@conn_hall
.
bind
(
'0.0.0.0'
,
Port
)
@recv_hall
=
Thread
.
new
{
recv
*
@conn_hall
.
recvfrom
(
1024
)
while
@conn_hall
}
Thread
.
abort_on_exception
=
true
rescue
=>
exception
Game_Event
.
push
Game_Event
::
Error
.
new
(
exception
.
class
.
to_s
,
exception
.
message
)
$log
.
error
[
exception
.
inspect
,
*
exception
.
backtrace
].
join
(
"
\n
"
)
end
end
def
send
(
user
,
head
,
*
args
)
case
user
...
...
@@ -25,7 +29,7 @@ class NBX < Game
when
nil
#大厅里的广播
@conn_hall
.
send
(
"
#{
head
}
|
#{
args
.
join
(
','
)
}
"
,
0
,
'<broadcast>'
,
Port
)
when
:room
#房间里,发给对手和观战者
@conn_room
.
write
(
head
.
encode
(
"GBK
"
)
+
RS
)
@conn_room
.
write
(
head
.
gsub
(
"
\n
"
,
"
\r\n
"
)
+
RS
)
when
:watchers
#房间里,发给观战者
end
...
...
@@ -35,8 +39,8 @@ class NBX < Game
def
login
(
username
)
Game_Event
.
push
Game_Event
::
Login
.
new
(
User
.
new
(
'localhost'
,
username
))
end
def
host
@room
=
Room
.
new
(
@user
.
id
,
@user
.
name
,
@user
)
def
host
(
name
=
@user
.
name
)
@room
=
Room
.
new
(
@user
.
id
,
name
,
@user
)
Game_Event
.
push
Game_Event
::
Host
.
new
(
@room
)
send
(
nil
,
"NewRoom"
,
@room
.
player1
.
name
)
@conn_room_server
=
TCPServer
.
new
'0.0.0.0'
,
Port
#为了照顾NBX强制IPv4
...
...
@@ -53,21 +57,26 @@ class NBX < Game
if
@conn_room
#如果已经连接了,进入观战
else
#连接
@conn_room
=
client
@conn_room
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
send
(
:room
,
"[LinkOK]|
#{
Version
}
"
)
send
(
:room
,
"▓SetName:
#{
@user
.
name
}
▓"
)
send
(
:room
,
"[☆]开启 游戏王NetBattleX Version 2.7.0
\r\n
[10年3月1日禁卡表]
\r\n
▊▊▊E8CB04"
)
@room
.
player2
=
User
.
new
(
client
.
addr
[
2
],
"对手"
)
while
info
=
@conn_room
.
gets
(
RS
)
recv_room
(
info
)
begin
@conn_room
=
client
@conn_room
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
send
(
:room
,
"[LinkOK]|
#{
Version
}
"
)
send
(
:room
,
"▓SetName:
#{
@user
.
name
}
▓"
)
send
(
:room
,
"[☆]开启 游戏王NetBattleX Version 2.7.0
\r\n
[10年3月1日禁卡表]
\r\n
▊▊▊E8CB04"
)
@room
.
player2
=
User
.
new
(
client
.
addr
[
2
],
"对手"
)
while
info
=
@conn_room
.
gets
(
RS
)
recv_room
(
info
)
end
@conn_room
.
close
@conn_room
=
nil
rescue
Exception
p
$!
end
@conn_room
.
close
#send(:room, "▓SetName:zh▓") #原版协议里还要重复声明一次名字,不过似乎没什么用处,就给省略了
end
end
def
recv_room
(
info
)
info
.
chomp!
(
RS
)
info
.
gsub!
(
"
\r\n
"
,
"
\n
"
)
$log
.
info
">>
#{
info
}
"
Game_Event
.
push
Game_Event
.
parse
info
end
...
...
lib/replay.rb
View file @
74d56beb
...
...
@@ -2,14 +2,13 @@ class Replay
ReplayPath
=
'replay'
LastReplay
=
'lastreplay.txt'
def
initialize
(
filename
=
LastReplay
)
@file
=
open
(
File
.
expand_path
(
filename
,
ReplayPath
),
'w'
)
@file
=
open
(
File
.
expand_path
(
filename
,
ReplayPath
),
'w'
)
unless
filename
.
is_a?
IO
end
def
add
(
action
)
action
=
action
.
escape
if
action
.
is_a?
Action
@file
.
write
action
+
"
\n
"
end
def
save
(
filename
=
"
#{
$game
.
room
.
player1
.
name
}
(
#{
$game
.
room
.
player1
.
id
}
)_
#{
$game
.
room
.
player2
.
name
}
(
#{
$game
.
room
.
player2
.
id
}
)_
#{
Time
.
now
.
strftime
(
"%m%d%H%M"
)
}
.txt"
)
p
filename
close
File
.
rename
(
@file
.
path
,
File
.
expand_path
(
filename
,
ReplayPath
))
end
...
...
lib/scene.rb
View file @
74d56beb
...
...
@@ -4,6 +4,7 @@
# 游戏中全部画面的超级类。
#==============================================================================
require_relative
'fpstimer'
require_relative
'game'
class
Scene
attr_reader
:windows
attr_reader
:background
...
...
@@ -41,7 +42,7 @@ class Scene
# ● 开始处理
#--------------------------------------------------------------------------
def
start
end
def
refresh_rect
(
x
,
y
,
width
,
height
,
background
=
@background
,
ox
=
0
,
oy
=
0
)
Surface
.
blit
(
background
,
x
+
ox
,
y
+
oy
,
width
,
height
,
$screen
,
x
,
y
)
...
...
@@ -66,6 +67,10 @@ class Scene
while
event
=
Event
.
poll
handle
(
event
)
end
#要不要放到一个Scene_Game里来处理这个?
while
event
=
Game_Event
.
poll
handle_game
(
event
)
end
end
def
handle
(
event
)
case
event
...
...
@@ -81,8 +86,25 @@ class Scene
when
5
@active_window
.
cursor_down
end
when
Event
::
KeyDown
case
event
.
sym
when
Key
::
F12
$scene
=
Scene_Title
.
new
else
$log
.
debug
(
'unhandled event'
){
event
.
inspect
}
end
when
Event
::
Quit
$scene
=
nil
else
$log
.
debug
(
'unhandled event'
){
event
.
inspect
}
end
end
def
handle_game
(
event
)
case
event
when
Game_Event
::
Error
Widget_Msgbox
.
new
(
event
.
title
,
event
.
message
,
:ok
=>
"确定"
){
$scene
=
Scene_Title
.
new
}
else
$log
.
debug
event
end
end
#--------------------------------------------------------------------------
...
...
@@ -94,7 +116,6 @@ class Scene
# ● 结束处理
#--------------------------------------------------------------------------
def
terminate
#$screen.fill_rect(0,0,$screen.w, $screen.h, 0xFF000000)
end
def
update_active_window
(
x
,
y
)
self
.
windows
.
reverse
.
each
do
|
window
|
...
...
lib/scene_duel.rb
View file @
74d56beb
...
...
@@ -58,7 +58,7 @@ class Scene_Duel < Scene
@replay
=
Replay
.
new
end
def
save_replay
@replay
.
save
if
@replay
#@replay.save if @replay #功能尚不可用
end
def
init_game
$game
.
player_field
=
Game_Field
.
new
@deck
...
...
@@ -153,15 +153,6 @@ class Scene_Duel < Scene
end
def
update
@cardinfo_window
.
update
if
$game
while
event
=
Game_Event
.
poll
handle_game
(
event
)
end
elsif
$game
while
event
=
Game_Event
.
poll
handle_game
(
event
)
end
end
super
end
def
refresh
...
...
lib/scene_hall.rb
View file @
74d56beb
...
...
@@ -86,20 +86,12 @@ class Scene_Hall < Scene
$scene
=
Scene_Watch
.
new
(
event
.
room
)
when
Game_Event
::
Chat
@chat
.
add
event
.
user
,
event
.
content
when
Game_Event
::
Error
Widget_Msgbox
.
new
(
event
.
title
,
event
.
message
){
$scene
=
Scene_Title
.
new
}
#when Game_Event::QROOMOK
# @joinroom_msgbox.message = "读取房间信息" if @joinroom_msgbox && !@joinroom_msgbox.destroyed?
else
$log
.
info
"---unhandled game event----"
$log
.
debug
event
super
end
end
def
update
while
event
=
Game_Event
.
poll
handle_game
(
event
)
end
if
@count
>=
600
$game
.
refresh
@count
=
0
...
...
lib/scene_login.rb
View file @
74d56beb
...
...
@@ -6,28 +6,26 @@
#==============================================================================
require_relative
'window_gameselect'
require_relative
'window_login'
require_relative
'
game
'
require_relative
'
scene_replay
'
class
Scene_Login
<
Scene
Vocab_Logging
=
"Logging"
def
start
@background
=
Surface
.
load
(
"graphics/login/background.png"
)
@gameselect_window
=
Window_GameSelect
.
new
(
117
,
269
,
$config
[
"game"
])
end
def
update
while
event
=
Game_Event
.
poll
handle_game
(
event
)
end
super
end
#def handle(event)
# case event
# when Event::Active
# if event.gain
# end
#
end
def
handle_game
(
event
)
case
event
when
Game_Event
::
Login
require_relative
'scene_hall'
$scene
=
Scene_Hall
.
new
when
Game_Event
::
Error
Widget_Msgbox
.
new
(
event
.
title
,
event
.
message
,
:ok
=>
"确定"
){
$scene
=
Scene_Title
.
new
}
else
$log
.
debug
event
super
end
end
end
\ No newline at end of file
lib/scene_replay.rb
View file @
74d56beb
#encoding: UTF-8
require
'
Scene_W
atch'
require
'
scene_w
atch'
class
Scene_Replay
<
Scene_Watch
def
initialize
(
replay
)
@replay
=
replay
...
...
@@ -11,13 +11,13 @@ class Scene_Replay < Scene_Watch
def
save_replay
end
def
update
if
@count
>=
60
if
@count
>=
10
#
60
event
=
@replay
.
get
if
event
Game_Event
.
push
event
@count
=
0
else
Widget_Msgbox
.
new
(
"回放"
,
"战报回放完毕"
)
{
$scene
=
Scene_Title
.
new
}
Widget_Msgbox
.
new
(
"回放"
,
"战报回放完毕"
,
:ok
=>
"确定"
)
{
$scene
=
Scene_Login
.
new
}
end
end
@count
+=
1
...
...
lib/scene_title.rb
View file @
74d56beb
...
...
@@ -48,7 +48,8 @@ class Scene_Title < Scene
end
def
terminate
@command_window
.
destroy
@background
.
destroy
@background
.
destroy
super
end
end
lib/user.rb
View file @
74d56beb
...
...
@@ -27,4 +27,7 @@ class User
def
room
$game
&&
$game
.
rooms
.
find
{
|
room
|
room
.
player1
==
self
or
room
.
player2
==
self
}
end
def
viewinfo
end
end
\ No newline at end of file
lib/window.rb
View file @
74d56beb
...
...
@@ -73,4 +73,10 @@ class Window
def
lostfocus
(
active_window
=
nil
)
#子类定义
end
def
cursor_up
#子类定义
end
def
cursor_down
#子类定义
end
end
\ No newline at end of file
lib/window_action.rb
View file @
74d56beb
...
...
@@ -38,7 +38,7 @@ class Window_Action < Window_List
@contents
.
put
(
@down
,
0
,
@height
-
15
)
end
def
index
=
(
index
)
if
index
and
index
>
0
and
index
<
@item_max
if
index
and
index
>
=
0
and
index
<
@item_max
super
(
index
)
refresh
end
...
...
lib/window_chat.rb
View file @
74d56beb
...
...
@@ -13,7 +13,7 @@ class Window_Chat < Window
super
(
x
,
y
,
width
,
height
)
@chat_input
=
Widget_InputBox
.
new
(
416
,
723
,
586
,
24
){
|
text
|
$game
.
chat
text
;
add
(
$game
.
user
,
text
)}
@font
=
TTF
.
open
(
"fonts/WenQuanYi Micro Hei.ttf"
,
16
)
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0xFFFFFFFF
)
#
@contents.fill_rect(0,0,@width, @height, 0xFFFFFFFF)
@scroll
=
Widget_ScrollBar
.
new
(
@x
+
@width
-
20
,
@y
,
@height
,
0
)
@list
=
[]
end
...
...
@@ -22,7 +22,7 @@ class Window_Chat < Window
refresh
end
def
refresh
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0x66FFFFFF
)
#
@contents.fill_rect(0,0,@width, @height, 0x66FFFFFF)
@list
.
last
(
7
).
each_with_index
do
|
chat
,
index
|
user
,
content
=
*
chat
@font
.
draw_blended_utf8
(
@contents
,
user
.
name
,
0
,
index
*
WLH
,
*
User_Color
)
...
...
lib/window_field.rb
View file @
74d56beb
...
...
@@ -224,25 +224,25 @@ class Window_Field < Window
when
0
Action
::
Draw
.
new
(
true
)
when
1
Widget_Msgbox
.
new
(
"查看卡组"
,
"功能未实现"
)
Widget_Msgbox
.
new
(
"查看卡组"
,
"功能未实现"
,
:ok
=>
"确定"
)
when
2
Action
::
Shuffle
.
new
(
true
)
when
3
Widget_Msgbox
.
new
(
"抽卡并确认"
,
"功能未实现"
)
Widget_Msgbox
.
new
(
"抽卡并确认"
,
"功能未实现"
,
:ok
=>
"确定"
)
when
4
Widget_Msgbox
.
new
(
"顶牌回卡组底"
,
"功能未实现"
)
Widget_Msgbox
.
new
(
"顶牌回卡组底"
,
"功能未实现"
,
:ok
=>
"确定"
)
when
5
Action
::
SendToGraveyard
.
new
(
true
,
:deck
,
@card
)
when
6
Action
::
Remove
.
new
(
true
,
:deck
,
@card
)
when
7
Widget_Msgbox
.
new
(
"顶牌背面除外"
,
"功能未实现"
)
Widget_Msgbox
.
new
(
"顶牌背面除外"
,
"功能未实现"
,
:ok
=>
"确定"
)
when
8
Widget_Msgbox
.
new
(
"确认顶牌"
,
"功能未实现"
)
when
9
Widget_Msgbox
.
new
(
"双方确认顶牌"
,
"功能未实现"
)
Widget_Msgbox
.
new
(
"双方确认顶牌"
,
"功能未实现"
,
:ok
=>
"确定"
)
when
10
Widget_Msgbox
.
new
(
"对方确认顶牌"
,
"功能未实现"
)
Widget_Msgbox
.
new
(
"对方确认顶牌"
,
"功能未实现"
,
:ok
=>
"确定"
)
end
when
:extra
case
@action_window
.
index
...
...
@@ -252,7 +252,7 @@ class Window_Field < Window
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
SpecialSummon
.
new
(
true
,
:extra
,
pos
,
@card
,
nil
,
:attack
)
else
Widget_Msgbox
.
new
(
"特殊召唤"
,
"场位已满"
)
Widget_Msgbox
.
new
(
"特殊召唤"
,
"场位已满"
,
:ok
=>
"确定"
)
end
when
2
Action
::
EffectActivate
.
new
(
true
,
:extra
,
@card
)
...
...
@@ -264,12 +264,12 @@ class Window_Field < Window
when
:removed
case
@action_window
.
index
when
0
Widget_Msgbox
.
new
(
"查看"
,
"功能未实现"
)
Widget_Msgbox
.
new
(
"查看"
,
"功能未实现"
,
:ok
=>
"确定"
)
when
1
#特殊召唤
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
SpecialSummon
.
new
(
true
,
:removed
,
pos
,
@card
)
else
Widget_Msgbox
.
new
(
"特殊召唤"
,
"场位已满"
)
Widget_Msgbox
.
new
(
"特殊召唤"
,
"场位已满"
,
:ok
=>
"确定"
)
end
when
2
#效果发动
Action
::
EffectActivate
.
new
(
true
,
:removed
,
@card
)
...
...
@@ -283,12 +283,12 @@ class Window_Field < Window
when
:graveyard
case
@action_window
.
index
when
0
Widget_Msgbox
.
new
(
"查看"
,
"功能未实现"
)
Widget_Msgbox
.
new
(
"查看"
,
"功能未实现"
,
:ok
=>
"确定"
)
when
1
#特殊召唤
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
SpecialSummon
.
new
(
true
,
:graveyard
,
pos
,
@card
)
else
Widget_Msgbox
.
new
(
"特殊召唤"
,
"场位已满"
)
Widget_Msgbox
.
new
(
"特殊召唤"
,
"场位已满"
,
:ok
=>
"确定"
)
end
when
2
#效果发动
Action
::
EffectActivate
.
new
(
true
,
:graveyard
,
@card
)
...
...
@@ -329,9 +329,9 @@ class Window_Field < Window
when
5
Action
::
EffectActivate
.
new
(
true
,
@index
,
@card
)
when
6
Widget_Msgbox
.
new
(
"攻击宣言"
,
"功能未实现"
)
Widget_Msgbox
.
new
(
"攻击宣言"
,
"功能未实现"
,
:ok
=>
"确定"
)
when
7
Widget_Msgbox
.
new
(
"转移控制权"
,
"功能未实现"
)
Widget_Msgbox
.
new
(
"转移控制权"
,
"功能未实现"
,
:ok
=>
"确定"
)
when
8
Action
::
ReturnToDeck
.
new
(
true
,
@index
,
@card
)
when
9
...
...
@@ -347,25 +347,25 @@ class Window_Field < Window
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
Summon
.
new
(
true
,
:hand
,
pos
,
@card
)
else
Widget_Msgbox
.
new
(
"召唤"
,
"场位已满"
)
Widget_Msgbox
.
new
(
"召唤"
,
"场位已满"
,
:ok
=>
"确定"
)
end
when
1
#特殊召唤
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
SpecialSummon
.
new
(
true
,
:hand
,
pos
,
@card
,
nil
,
:attack
)
else
Widget_Msgbox
.
new
(
"特殊召唤"
,
"场位已满"
)
Widget_Msgbox
.
new
(
"特殊召唤"
,
"场位已满"
,
:ok
=>
"确定"
)
end
when
2
#发动
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
Activate
.
new
(
true
,
:hand
,
pos
,
@card
)
else
Widget_Msgbox
.
new
(
"发动"
,
"场位已满"
)
Widget_Msgbox
.
new
(
"发动"
,
"场位已满"
,
:ok
=>
"确定"
)
end
when
3
#放置
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
Set
.
new
(
true
,
:hand
,
pos
,
@card
)
else
Widget_Msgbox
.
new
(
"放置"
,
"场位已满"
)
Widget_Msgbox
.
new
(
"放置"
,
"场位已满"
,
:ok
=>
"确定"
)
end
when
4
#返回卡组
Action
::
ReturnToDeck
.
new
(
true
,
:hand
,
@card
)
...
...
lib/window_gameselect.rb
View file @
74d56beb
...
...
@@ -27,12 +27,7 @@ class Window_GameSelect < Window_List
refresh
end
def
draw_item
(
index
,
status
=
0
)
case
status
when
0
Surface
.
blit
(
@button
,
0
,
0
,
@button
.
w
,
@button
.
h
,
@contents
,
0
,
WLH
*
index
)
when
1
2
.
times
{
Surface
.
blit
(
@button
,
0
,
0
,
@button
.
w
,
@button
.
h
,
@contents
,
0
,
WLH
*
index
)}
#我自重
end
Surface
.
blit
(
@button
,
@button
.
w
/
3
*
status
,
0
,
@button
.
w
/
3
,
@button
.
h
,
@contents
,
0
,
WLH
*
index
)
draw_stroked_text
(
@list
[
index
][
"name"
],
24
,
WLH
*
index
+
14
,
2
)
end
def
item_rect
(
index
)
...
...
lib/window_login.rb
View file @
74d56beb
...
...
@@ -20,12 +20,14 @@ class Window_Login < Window
@items
=
{
#:username => [192,80,165,WLH],
#:password => [192,125,165,WLH],
:login
=>
[
192
,
200
,
80
,
36
],
:register
=>
[
285
,
200
,
80
,
36
]
:login
=>
[
192
,
200
,
@button
.
w
/
3
,
@button
.
h
],
:register
=>
[
285
,
200
,
@button
.
w
/
3
,
@button
.
h
],
:replay
=>
[
378
,
200
,
@button
.
w
/
3
,
@button
.
h
]
}
@items_text
=
{
:login
=>
"登陆"
,
:register
=>
"注册"
:register
=>
"注册"
,
:replay
=>
"战报"
}
#self.index = nil
refresh
...
...
@@ -44,14 +46,29 @@ class Window_Login < Window
draw_stroked_text
(
"密码"
,
105
,
125
+
2
,
1
)
end
def
draw_item
(
index
,
rect
,
status
=
0
)
Surface
.
blit
(
@button
,
0
,
0
,
rect
[
2
],
rect
[
3
],
@contents
,
rect
[
0
],
rect
[
1
])
draw_stroked_text
(
@items_text
[
index
],
rect
[
0
]
+
2
0
,
rect
[
1
]
+
9
,
1
,
@font_button
)
Surface
.
blit
(
@button
,
rect
[
2
]
*
status
,
0
,
rect
[
2
],
rect
[
3
],
@contents
,
rect
[
0
],
rect
[
1
])
draw_stroked_text
(
@items_text
[
index
],
rect
[
0
]
+
2
4
,
rect
[
1
]
+
9
,
1
,
@font_button
)
end
def
mousemoved
(
x
,
y
)
@items
.
each_pair
{
|
index
,
rect
|
return
self
.
index
=
index
if
(
x
-
@x
>=
rect
[
0
]
and
x
-
@x
<
rect
[
0
]
+
rect
[
2
]
and
y
-
@y
>=
rect
[
1
]
and
y
-
@y
<
rect
[
1
]
+
rect
[
3
])}
self
.
index
=
@items
.
each_pair
{
|
index
,
rect
|
break
index
if
(
x
-
@x
>=
rect
[
0
]
and
x
-
@x
<
rect
[
0
]
+
rect
[
2
]
and
y
-
@y
>=
rect
[
1
]
and
y
-
@y
<
rect
[
1
]
+
rect
[
3
])}
end
def
lostfocus
(
active_window
=
nil
)
self
.
index
=
nil
end
def
item_rect
(
index
)
@items
[
index
]
end
def
index
=
(
index
)
index
=
nil
if
!
@items
.
has_key?
(
index
)
return
if
@index
==
index
if
@index
clear
(
*
item_rect
(
@index
))
draw_item
(
@index
,
item_rect
(
@index
),
0
)
end
@index
=
index
if
@index
clear
(
*
item_rect
(
@index
))
draw_item
(
@index
,
item_rect
(
@index
),
1
)
end
end
end
lib/window_lp.rb
View file @
74d56beb
...
...
@@ -32,7 +32,7 @@ class Window_LP < Window
else
width
=
[
0
,
[(
200
*
lp
/
8000
),
200
].
min
].
max
@contents
.
fill_rect
(
@width
-
width
-
64
,
0
,
width
,
24
,
0xFFFF0000
)
@font
.
draw_blended_utf8
(
@contents
,
@lp
.
to_s
,
@width
-
width
-
64
,
0
,
*
@color
)
@font
.
draw_blended_utf8
(
@contents
,
@lp
.
to_s
,
@width
-
128
,
0
,
*
@color
)
end
end
end
\ No newline at end of file
lib/window_user.rb
View file @
74d56beb
...
...
@@ -17,9 +17,8 @@ class Window_User < Window_List
end
def
refresh
@thread
.
kill
if
@thread
@contents
.
put
(
@background
,
0
,
0
)
super
@thread
=
@user
.
avatar
(
:middle
)
do
|
avatar
|
clear
(
12
,
12
,
144
,
144
)
@contents
.
put
(
avatar
,
24
,
24
)
@contents
.
put
(
@avatar_boarder
,
12
,
12
)
end
...
...
@@ -27,9 +26,11 @@ class Window_User < Window_List
@font
.
draw_blended_utf8
(
@contents
,
@user
.
name
,
172
,
24
,
0x00
,
0x00
,
0x00
)
@font
.
draw_blended_utf8
(
@contents
,
"id:
#{
@user
.
id
}
"
,
172
,
32
+
WLH
,
0x00
,
0x00
,
0x00
)
@font
.
draw_blended_utf8
(
@contents
,
"
#{
'房间'
+
@user
.
room
.
id
.
to_s
+
' '
if
@user
.
room
}#{
case
@user
.
status
;
when
:hall
;
'大厅'
;
when
:dueling
;
'决斗中'
;
when
:waiting
;
'等待中'
;
end
}
"
,
172
,
32
+
WLH
*
2
,
0x00
,
0x00
,
0x00
)
super
end
def
clear
(
x
=
0
,
y
=
0
,
width
=
@width
,
height
=
@height
)
Surface
.
blit
(
@background
,
x
,
y
,
width
,
height
,
@contents
,
x
,
y
)
end
def
draw_item
(
index
,
status
=
0
)
@font
.
draw_blended_utf8
(
@contents
,
@list
[
index
]
,
172
,
96
+
index
*
WLH
,
0x00
,
0x00
,
0x00
)
...
...
@@ -42,8 +43,7 @@ class Window_User < Window_List
when
0
#发送消息
when
1
require
'launchy'
Launchy
.
open
(
"http://google.com"
)
@user
.
space
when
2
if
@user
.
status
==
:waiting
$game
.
join
(
@user
.
room
)
...
...
lib/window_userlist.rb
View file @
74d56beb
...
...
@@ -3,7 +3,7 @@
#------------------------------------------------------------------------------
# title
#==============================================================================
require_relative
'window_user'
class
Window_UserList
<
Window_List
attr_reader
:x
,
:y
,
:width
,
:height
WLH
=
20
...
...
@@ -36,9 +36,9 @@ class Window_UserList < Window_List
def
item_rect
(
index
)
[
0
,
WLH
*
index
,
@width
,
WLH
]
end
def
clear
(
x
=
0
,
y
=
0
,
width
=
@width
,
height
=
@height
)
@contents
.
fill_rect
(
x
,
y
,
width
,
height
,
0x66FFFFFF
)
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
@userwindow
=
Window_User
.
new
(
100
,
100
,
@list
[
@index
])
...
...
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