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
48dcc949
Commit
48dcc949
authored
Dec 08, 2011
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nbx,动作窗口微调,焦点机制微调
parent
4d71de73
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
222 additions
and
170 deletions
+222
-170
lib/action.rb
lib/action.rb
+79
-39
lib/game.rb
lib/game.rb
+1
-1
lib/game_card.rb
lib/game_card.rb
+6
-1
lib/game_event.rb
lib/game_event.rb
+3
-2
lib/nbx/action.rb
lib/nbx/action.rb
+40
-9
lib/nbx/event.rb
lib/nbx/event.rb
+5
-3
lib/nbx/nbx.rb
lib/nbx/nbx.rb
+15
-11
lib/scene.rb
lib/scene.rb
+18
-22
lib/scene_duel.rb
lib/scene_duel.rb
+9
-45
lib/scene_hall.rb
lib/scene_hall.rb
+3
-0
lib/scene_single.rb
lib/scene_single.rb
+2
-1
lib/window.rb
lib/window.rb
+2
-2
lib/window_action.rb
lib/window_action.rb
+8
-5
lib/window_cardinfo.rb
lib/window_cardinfo.rb
+1
-3
lib/window_field.rb
lib/window_field.rb
+28
-24
lib/window_list.rb
lib/window_list.rb
+1
-1
lib/window_roomchat.rb
lib/window_roomchat.rb
+1
-1
No files found.
lib/action.rb
View file @
48dcc949
#encoding: UTF-8
class
Action
@@id
=
0
attr_accessor
:from_player
,
:msg
attr_accessor
:id
def
initialize
(
from_player
=
true
,
msg
=
nil
)
@id
=
@@id
@from_player
=
from_player
@msg
=
msg
if
@from_player
@@id
+=
1
end
@@id
+=
1
if
@from_player
end
def
player_field
@from_player
?
@@player_field
:
@@
opponent_field
@from_player
?
$game
.
player_field
:
$game
.
opponent_field
end
def
opponent_field
@from_player
?
@@opponent_field
:
@@player_field
end
def
self
.
player_field
=
(
field
)
@@player_field
=
field
end
def
self
.
opponent_field
=
(
field
)
@@opponent_field
=
field
@from_player
?
$game
.
opponent_field
:
$game
.
player_field
end
def
run
$game
.
action
self
...
...
@@ -39,7 +30,7 @@ class Action
def
run
super
player_field
.
hand
=
player_field
.
deck
.
shift
(
5
)
player_field
.
hand
.
each
{
|
card
|
card
.
position
=
:attack
}
#player_field.hand.each{|card|card.position = :set
}
end
end
class
FirstToGo
<
Go
;
end
...
...
@@ -81,7 +72,7 @@ class Action
end
class
Move
<
Action
attr_reader
:from_pos
,
:to_pos
,
:card
,
:position
def
initialize
(
from_player
,
from_pos
,
to_pos
,
card
,
msg
=
nil
,
position
=
:set
)
def
initialize
(
from_player
,
from_pos
,
to_pos
=
nil
,
card
=
Card
::
Unknown
,
msg
=
nil
,
position
=
nil
)
super
(
from_player
,
msg
)
@from_pos
=
from_pos
@to_pos
=
to_pos
...
...
@@ -109,7 +100,7 @@ class Action
if
@from_pos
.
is_a?
Integer
from_pos
=
@from_pos
else
from_pos
=
(
@card
.
is_a?
(
Game_Card
)
?
from_field
.
index
(
@card
)
:
from_field
.
index
{
|
card
|
card
.
card
==
@card
})
or
from_field
.
index
{
|
card
|!
card
.
known?
}
from_pos
=
(
@card
.
is_a?
(
Game_Card
)
?
from_field
.
index
(
@card
)
:
from_field
.
index
{
|
card
|
card
.
card
==
@card
})
||
from_field
.
index
{
|
card
|!
card
.
known?
}
end
to_field
=
case
@to_pos
...
...
@@ -119,32 +110,44 @@ class Action
player_field
.
hand
when
:graveyard
player_field
.
graveyard
when
:deck
when
:deck
,
:deckbottom
player_field
.
deck
when
:extra
player_field
.
extra
when
:removed
player_field
.
removed
end
if
from_pos
card
=
from_field
[
from_pos
]
if
from_field
==
player_field
.
field
from_field
[
from_pos
]
=
nil
else
from_field
.
delete_at
from_pos
if
from_pos
&&
from_field
[
from_pos
]
case
@card
when
Game_Card
card
=
from_field
[
from_pos
]
=
@card
when
nil
,
Card
::
Unknown
card
=
from_field
[
from_pos
]
when
Card
card
=
from_field
[
from_pos
]
card
.
card
=
@card
end
if
@to_pos
if
from_field
==
player_field
.
field
from_field
[
from_pos
]
=
nil
else
from_field
.
delete_at
from_pos
end
end
else
card
=
Game_Card
.
new
(
@card
)
p
"似乎凭空产生了卡片?"
p
self
end
card
.
position
=
@position
if
@to_pos
.
is_a?
Integer
to_field
[
@to_pos
]
=
card
elsif
to_field
==
player_field
.
hand
to_field
<<
card
else
to_field
.
unshift
card
card
.
position
=
@position
if
@position
if
@to_pos
if
@to_pos
.
is_a?
Integer
to_field
[
@to_pos
]
=
card
elsif
@to_pos
==
:hand
or
@to_pos
==
:deckbottom
to_field
<<
card
else
to_field
.
unshift
card
end
end
super
end
...
...
@@ -181,7 +184,7 @@ class Action
end
class
ReturnToHand
<
Move
def
initialize
(
from_player
,
from_pos
,
card
)
super
(
from_player
,
from_pos
,
:hand
,
card
,
nil
,
:
attack
)
super
(
from_player
,
from_pos
,
:hand
,
card
,
nil
,
:
set
)
end
end
class
ReturnToDeck
<
Move
...
...
@@ -189,6 +192,15 @@ class Action
super
(
from_player
,
from_pos
,
:deck
,
card
,
nil
,
:set
)
end
end
class
ReturnToDeckBottom
<
Move
def
initialize
(
from_player
,
from_pos
,
card
=
Card
.
find
(
nil
))
if
from_pos
==
:deck
and
card
==
Card
.
find
(
nil
)
@from_player
=
from_player
card
=
player_field
.
deck
.
first
end
super
(
from_player
,
from_pos
,
:deckbottom
,
card
,
nil
,
:set
)
end
end
class
ReturnToExtra
<
Move
def
initialize
(
from_player
,
from_pos
,
card
)
super
(
from_player
,
from_pos
,
:extra
,
card
,
nil
,
:set
)
...
...
@@ -218,7 +230,17 @@ class Action
class
Draw
<
Move
def
initialize
(
from_player
=
true
,
msg
=
nil
)
@from_player
=
from_player
super
(
from_player
,
:deck
,
:hand
,
player_field
.
deck
.
first
,
msg
,
:attack
)
super
(
from_player
,
:deck
,
:hand
,
player_field
.
deck
.
first
,
msg
,
:set
)
end
end
class
MultiDraw
<
Action
def
initialize
(
from_player
,
count
,
msg
=
nil
)
super
(
from_player
,
msg
)
@count
=
count
end
def
run
super
player_field
.
hand
+=
player_field
.
deck
.
shift
(
@count
)
end
end
class
Refresh_Field
<
Action
...
...
@@ -241,22 +263,40 @@ class Action
@turn
=
turn
end
end
class
Effect_Activate
<
Action
class
Show
<
Move
attr_reader
:from_pos
,
:card
def
initialize
(
from_player
,
from_pos
,
card
)
super
(
from_player
)
super
(
from_player
,
from_pos
,
nil
,
card
)
@from_pos
=
from_pos
@card
=
card
end
def
run
if
@card
.
position
==
:set
if
@card
.
monster?
@card
.
position
=
:defense
end
class
Effect_Activate
<
Move
def
initialize
(
from_player
,
from_pos
,
card
)
@from_player
=
from_player
if
(
0
..
10
).
include?
(
from_pos
)
if
(
6
..
10
).
include?
(
from_pos
)
&&
player_field
.
field
[
from_pos
]
&&
(
player_field
.
field
[
from_pos
].
position
==
:set
||
player_field
.
field
[
from_pos
].
position
==
:defense
)
position
=
:defense
else
@card
.
position
=
:attack
position
=
:attack
end
else
position
=
nil
end
super
super
(
from_player
,
from_pos
,
nil
,
card
,
nil
,
position
)
end
end
class
Unknown
<
Action
def
initialize
(
*
args
)
puts
'unkonwn action'
p
args
end
def
run
puts
'unkonwn action run'
end
end
def
self
.
reset
@@id
=
1
end
reset
end
\ No newline at end of file
lib/game.rb
View file @
48dcc949
...
...
@@ -3,7 +3,7 @@
#游戏适配器的抽象类
class
Game
attr_reader
:users
,
:rooms
attr_accessor
:user
,
:room
attr_accessor
:user
,
:room
,
:player_field
,
:opponent_field
def
initialize
@users
=
[]
@rooms
=
[]
...
...
lib/game_card.rb
View file @
48dcc949
...
...
@@ -14,11 +14,16 @@ class Game_Card
@atk
=
@card
.
atk
@def
=
@card
.
def
end
def
card
=
(
card
)
@card
=
card
@atk
=
@card
.
atk
@def
=
@card
.
def
end
def
known?
@card
!=
Card
::
Unknown
end
def
image_small
if
@position
==
:set
if
@position
==
:set
and
!
$game
.
player_field
.
hand
.
include?
(
self
)
Card
.
find
(
nil
).
image_small
else
@card
.
image_small
...
...
lib/game_event.rb
View file @
48dcc949
...
...
@@ -113,9 +113,10 @@ class Game_Event
end
class
Action
<
Game_Event
attr_reader
:action
def
initialize
(
action
)
attr_reader
:action
,
:str
def
initialize
(
action
,
str
=
Action
.
escape
)
@action
=
action
@str
=
str
end
end
...
...
lib/nbx/action.rb
View file @
48dcc949
#encoding: UTF-8
require_relative
'../action'
class
Action
CardFilter
=
/(
<(?:\[.*?\]\[(?:.*?)\]){0,1}[\s\d]*>
|一张怪兽卡|一张魔\/陷卡)/
.
to_s
CardFilter
=
/(
(?:<){0,1}(?:\[.*?\]\[(?:.*?)\]){0,1}[\s\d]*(?:>){0,1}
|一张怪兽卡|一张魔\/陷卡)/
.
to_s
#FieldCardFilter = /(<>|<??>|<(?:(?:表攻|表守|里守)\|){0,1}\[.*?\]\[(?:.*?)\]){0,1}[\s\d]*>)/.to_s
PosFilter
=
/((?:手卡|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组顶端|\(\d+\)){1,2})/
.
to_s
PositionFilter
=
/(
|
攻击表示|防守表示|里侧表示|背面守备表示)/
.
to_s
PosFilter
=
/((?:手卡|
手牌|
场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组顶端|\(\d+\)){1,2})/
.
to_s
PositionFilter
=
/(攻击表示|防守表示|里侧表示|背面守备表示)/
.
to_s
PhaseFilter
=
/(抽卡`阶段|准备`阶段|主`阶段1|战斗`阶段|主`阶段2|结束`阶段)/
.
to_s
def
self
.
parse_pos
(
pos
)
if
index
=
pos
.
index
(
"("
)
...
...
@@ -148,7 +148,6 @@ class Action
str
=~
/^\[(\d+)\] (.*)▊▊▊.*?$/m
from_player
=
false
id
=
$1
.
to_i
$chat_window
.
add
from_player
,
"[
#{
$1
}
]
#{
$2
}
"
result
=
case
$2
when
/^┊(.*)┊$/m
Chat
.
new
from_player
,
$1
...
...
@@ -172,6 +171,12 @@ class Action
Reset
.
new
from_player
when
"换SIDE……"
Side
.
new
from_player
when
"卡组洗切"
Shuffle
.
new
from_player
when
"将顶牌放回卡组底部"
ReturnToDeckBottom
.
new
(
from_player
,
:deck
)
when
/抽取\((\d+)\)张卡/
MultiDraw
.
new
from_player
,
$1
.
to_i
when
/\[\d+年\d+月\d+日禁卡表\](?:<(.+)> ){0,1}先攻/
FirstToGo
.
new
from_player
,
$1
when
/\[\d+年\d+月\d+日禁卡表\](?:<(.+)> ){0,1}后攻/
...
...
@@ -184,12 +189,14 @@ class Action
Activate
.
new
from_player
,
parse_pos
(
$1
),
parse_pos
(
$3
),
parse_card
(
$2
)
when
/从
#{
PosFilter
}
~召唤
#{
CardFilter
}#{
PosFilter
}
/
Summon
.
new
from_player
,
parse_pos
(
$1
),
parse_pos
(
$3
),
parse_card
(
$2
),
msg
when
/从
#{
PosFilter
}
~特殊召唤
#{
CardFilter
}#{
PosFilter
}
呈
#{
PositionFilter
}
/
SpecialSummon
.
new
from_player
,
parse_pos
(
$1
),
parse_pos
(
$3
),
card
(
$2
),
msg
,
parse_position
(
$4
)
when
/从
#{
PosFilter
}
~特殊召唤
#{
CardFilter
}#{
PosFilter
}
(?:呈
#{
PositionFilter
}
){0,1
}/
SpecialSummon
.
new
from_player
,
parse_pos
(
$1
),
parse_pos
(
$3
),
parse_card
(
$2
),
msg
,
$4
?
parse_position
(
$4
)
:
:attack
when
/从手卡~取
#{
CardFilter
}
盖到
#{
PosFilter
}
/
Set
.
new
from_player
,
:hand
,
parse_pos
(
$2
),
parse_card
(
$1
)
when
/将
#{
CardFilter
}
从~
#{
PosFilter
}
~送往墓地/
SendToGraveyard
.
new
(
from_player
,
parse_pos
(
$2
),
parse_card
(
$1
))
when
/将~
#{
PosFilter
}
~的
#{
CardFilter
}
解~放/
Tribute
.
new
(
from_player
,
parse_pos
(
$1
),
parse_card
(
$2
))
when
/将
#{
PosFilter
}
的
#{
CardFilter
}
从游戏中除外/
Remove
.
new
from_player
,
parse_pos
(
$1
),
parse_card
(
$2
)
when
/
#{
CardFilter
}
从
#{
PosFilter
}
~放回卡组顶端/
...
...
@@ -198,15 +205,19 @@ class Action
ReturnToExtra
.
new
from_player
,
parse_pos
(
$2
),
parse_card
(
$1
)
when
/从
#{
PosFilter
}
取
#{
CardFilter
}
加入手卡/
ReturnToHand
.
new
from_player
,
parse_pos
(
$1
),
parse_card
(
$2
)
when
/
#{
PosFilter
}#{
CardFilter
}
效果发(?:\~){0,1}动/
when
/
(?:己方){0,1}
#{
PosFilter
}#{
CardFilter
}
效果发(?:\~){0,1}动/
Effect_Activate
.
new
(
from_player
,
parse_pos
(
$1
),
parse_card
(
$2
))
when
/
#{
PosFilter
}#{
CardFilter
}
(?:变|改)为
#{
PositionFilter
}
/
ChangePosition
.
new
(
from_player
,
parse_pos
(
$1
),
parse_card
(
$2
),
parse_position
(
$3
))
when
/
#{
PosFilter
}#{
CardFilter
}
打开/
Flip
.
new
(
from_player
,
parse_pos
(
$1
),
parse_card
(
$2
))
when
/
#{
PhaseFilter
}
/
ChangePhase
.
new
(
from_player
,
parse_phase
(
$1
))
else
p
str
,
1
Unknown
.
new
str
end
else
p
str
,
2
Unknown
.
new
str
end
result
.
id
=
id
result
...
...
@@ -228,6 +239,11 @@ class Action
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→抽牌"
end
end
class
MultiDraw
def
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→抽取(
#{
@count
}
)张卡"
end
end
class
Dice
def
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→掷骰子,结果为
#{
@result
}
"
...
...
@@ -321,6 +337,11 @@ class Action
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→
#{
@from_pos
==
:hand
?
"一张卡"
:
@card
.
escape
}
从
#{
pos
}
~放回卡组顶端"
#TODO:set=【一张卡】
end
end
class
ReturnToDeckBottom
def
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→将顶牌放回卡组底部"
end
end
class
ReturnToExtra
def
escape
pos
=
case
@from_pos
...
...
@@ -357,6 +378,16 @@ class Action
end
end
end
class
Show
def
escape
case
from_pos
when
0
..
10
#场上
when
Integer
"第
#{
@from_pos
-
10
}
张手牌为:
#{
@card
.
escape
}
"
end
end
end
class
Effect_Activate
def
escape
pos
=
case
@from_pos
...
...
lib/nbx/event.rb
View file @
48dcc949
...
...
@@ -20,7 +20,7 @@ class Game_Event
case
info
when
/▓SetName:(.*)▓/
NewUser
when
/\[VerInf\]\|(.*)/
when
/\[VerInf\]
|\[LinkOK\]
\|(.*)/
VerInf
when
/(\[☆\]开启 游戏王NetBattleX Version .*\r\n\[.*年.*月.*日禁卡表\]\r\n)▊▊▊.*/
PlayerJoin
...
...
@@ -40,7 +40,7 @@ class Game_Event
class
NewUser
def
self
.
parse
(
info
,
host
=
$game
.
room
.
player2
.
id
)
username
,
need_reply
=
info
.
split
(
','
)
username
=
"对手"
if
username
.
empty?
username
=
"对手"
if
username
.
nil?
or
username
.
empty?
user
=
User
.
new
(
host
,
username
)
need_reply
=
need_reply
==
"1"
if
need_reply
and
user
!=
$game
.
user
#忽略来自自己的回复请求
...
...
@@ -76,7 +76,9 @@ class Game_Event
end
class
Action
def
self
.
parse
(
info
)
self
.
new
::
Action
.
parse
info
info
=~
/(.*)▊▊▊.*/m
str
=
$1
||
info
self
.
new
::
Action
.
parse
(
info
),
str
end
end
class
VerInf
...
...
lib/nbx/nbx.rb
View file @
48dcc949
...
...
@@ -39,15 +39,8 @@ class NBX < Game
def
host
@room
=
Room
.
new
(
@user
.
id
,
@user
.
name
,
@user
)
Game_Event
.
push
Game_Event
::
Host
.
new
(
@room
)
#p @room
#if room.player2
# @conn_hall.send(nil, "NewRoom", room.player1.name,room.player2.name, room.player2.host)
#else
send
(
nil
,
"NewRoom"
,
@room
.
player1
.
name
)
#end
@conn_room_server
=
TCPServer
.
new
'0.0.0.0'
,
Port
#为了照顾NBX强制IPv4
@accept_room
=
Thread
.
new
{
Thread
.
start
(
@conn_room_server
.
accept
)
{
|
client
|
accept
(
client
)}
while
@conn_room_server
}
end
def
action
(
action
)
...
...
@@ -83,10 +76,21 @@ class NBX < Game
def
refresh
send
(
nil
,
'NewUser'
,
@user
.
name
,
1
)
end
def
connect
(
server
,
port
=
Port
)
#@conn = TCPSocket.open(server, port)
#@conn.set_encoding "GBK"
#@recv_hall = Thread.new { recv @conn.gets(RS) while @conn }
def
join
(
host
,
port
=
Port
)
Thread
.
new
{
@conn_room
=
TCPSocket
.
new
(
host
,
port
)
@conn_room
.
set_encoding
"GBK"
@room
=
Room
.
new
(
@user
.
id
,
@user
.
name
,
@user
)
Game_Event
.
push
Game_Event
::
Join
.
new
(
@room
)
send
(
:room
,
"[VerInf]|
#{
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
(
host
,
"对手"
)
while
info
=
@conn_room
.
gets
(
RS
)
recv_room
(
info
)
end
@conn_room
.
close
}
#TODO: 跟accept合并
end
def
recv
(
info
,
addrinfo
)
...
...
lib/scene.rb
View file @
48dcc949
...
...
@@ -62,31 +62,11 @@ class Scene
def
handle
(
event
)
case
event
when
Event
::
MouseMotion
if
@active_window
and
@active_window
.
visible
&&
!
@active_window
.
include?
(
event
.
x
,
event
.
y
)
@active_window
.
lostfocus
@active_window
=
nil
end
self
.
windows
.
reverse
.
each
do
|
window
|
if
window
.
include?
(
event
.
x
,
event
.
y
)
&&
window
.
visible
@active_window
=
window
@active_window
.
mousemoved
(
event
.
x
,
event
.
y
)
break
true
end
end
update_active_window
(
event
.
x
,
event
.
y
)
when
Event
::
MouseButtonDown
update_active_window
(
event
.
x
,
event
.
y
)
case
event
.
button
when
Mouse
::
BUTTON_LEFT
if
@active_window
and
!
@active_window
.
include?
event
.
x
,
event
.
y
@active_window
.
lostfocus
@active_window
=
nil
end
self
.
windows
.
reverse
.
each
do
|
window
|
if
@active_window
and
@active_window
.
visible
&&
!
@active_window
.
include?
(
event
.
x
,
event
.
y
)
@active_window
=
window
@active_window
.
mousemoved
(
event
.
x
,
event
.
y
)
break
end
end
@active_window
.
clicked
if
@active_window
when
4
@active_window
.
cursor_up
...
...
@@ -108,5 +88,21 @@ 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
|
if
window
.
include?
(
x
,
y
)
&&
window
.
visible
if
window
!=
@active_window
@active_window
.
lostfocus
(
window
)
if
@active_window
@active_window
=
window
end
@active_window
.
mousemoved
(
x
,
y
)
return
@active_window
end
end
if
@active_window
@active_window
.
lostfocus
@active_window
=
nil
end
end
end
lib/scene_duel.rb
View file @
48dcc949
...
...
@@ -18,8 +18,6 @@ class Scene_Duel < Scene
require_relative
'window_roomchat'
attr_reader
:cardinfo_window
attr_reader
:action_window
attr_reader
:player_field
attr_reader
:opponent_field
attr_reader
:player_field_window
attr_reader
:opponent_field_window
attr_reader
:fieldback_window
...
...
@@ -39,20 +37,17 @@ class Scene_Duel < Scene
@phases_window
=
Window_Phases
.
new
(
124
,
357
)
@turn_player
=
true
@
player_field
=
Game_Field
.
new
Deck
.
load
(
"test1.TXT"
)
@
opponent_field
=
Game_Field
.
new
$game
.
player_field
=
Game_Field
.
new
Deck
.
load
(
"test1.TXT"
)
$game
.
opponent_field
=
Game_Field
.
new
@fieldback_window
=
Window_FieldBack
.
new
(
130
,
174
)
@player_field_window
=
Window_Field
.
new
(
4
,
398
,
@
player_field
,
true
)
@opponent_field_window
=
Window_Field
.
new
(
4
,
60
,
@
opponent_field
,
false
)
@player_field_window
=
Window_Field
.
new
(
4
,
398
,
$game
.
player_field
,
true
)
@opponent_field_window
=
Window_Field
.
new
(
4
,
60
,
$game
.
opponent_field
,
false
)
@opponent_field_window
.
angle
=
180
Action
.
player_field
=
@player_field
Action
.
opponent_field
=
@opponent_field
@cardinfo_window
=
Window_CardInfo
.
new
(
715
,
0
)
@action_window
=
Window_Action
.
new
@
player_field_window
.
action_window
=
Window_Action
.
new
@chat_window
=
Window_RoomChat
.
new
(
@cardinfo_window
.
x
,
@cardinfo_window
.
height
,
1024
-
@cardinfo_window
.
x
,
768
-
@cardinfo_window
.
height
)
super
#(Thread.list - [Thread.current]).each{|t|t.kill}
...
...
@@ -66,7 +61,7 @@ class Scene_Duel < Scene
@turn_player
=
!
@turn_player
@phase
=
0
@phases_window
.
player
=
@turn_player
Action
::
Turn_End
.
new
(
true
,
"Turn End"
,
@player_field
.
lp
,
@player_field
.
hand
.
size
,
@player_field
.
deck
.
size
,
@player_field
.
graveyard
.
size
,
@player_field
.
removed
.
size
,
@
player_field
,
1
).
run
Action
::
Turn_End
.
new
(
true
,
"Turn End"
,
$game
.
player_field
.
lp
,
$game
.
player_field
.
hand
.
size
,
$game
.
player_field
.
deck
.
size
,
$game
.
player_field
.
graveyard
.
size
,
$game
.
player_field
.
removed
.
size
,
$game
.
player_field
,
1
).
run
else
@phase
=
@phases_window
.
phase
=
phase
@phases_window
.
refresh
...
...
@@ -80,38 +75,6 @@ class Scene_Duel < Scene
end
def
handle
(
event
)
case
event
when
Event
::
MouseMotion
if
@active_window
and
@active_window
.
visible
&&
!
@active_window
.
include?
(
event
.
x
,
event
.
y
)
@active_window
.
lostfocus
@active_window
=
nil
end
self
.
windows
.
reverse
.
each
do
|
window
|
if
window
.
include?
(
event
.
x
,
event
.
y
)
&&
window
.
visible
@active_window
=
window
@active_window
.
mousemoved
(
event
.
x
,
event
.
y
)
break
true
end
end
when
Event
::
MouseButtonDown
case
event
.
button
when
Mouse
::
BUTTON_LEFT
if
@active_window
and
@active_window
.
visible
&&
!
@active_window
.
include?
(
event
.
x
,
event
.
y
)
@active_window
.
lostfocus
@active_window
=
nil
end
self
.
windows
.
reverse
.
each
do
|
window
|
if
window
.
include?
(
event
.
x
,
event
.
y
)
&&
window
.
visible
@active_window
=
window
@active_window
.
mousemoved
(
event
.
x
,
event
.
y
)
break
true
end
end
@active_window
.
clicked
if
@active_window
when
4
@active_window
.
cursor_up
when
5
@active_window
.
cursor_down
end
when
Event
::
MouseButtonUp
case
event
.
button
when
Mouse
::
BUTTON_LEFT
...
...
@@ -124,8 +87,8 @@ class Scene_Duel < Scene
end
end
when
Mouse
::
BUTTON_RIGHT
if
@action_window
@action_window
.
next
if
@
player_field_window
.
action_window
@
player_field_window
.
action_window
.
next
end
end
when
Event
::
KeyDown
...
...
@@ -153,6 +116,7 @@ class Scene_Duel < Scene
def
handle_game
(
event
)
case
event
when
Game_Event
::
Action
$chat_window
.
add
event
.
action
.
from_player
,
event
.
str
event
.
action
.
run
@player_field_window
.
refresh
@opponent_field_window
.
refresh
...
...
lib/scene_hall.rb
View file @
48dcc949
...
...
@@ -42,6 +42,9 @@ class Scene_Hall < Scene
when
Key
::
F2
$game
.
host
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"创建房间"
,
"正在等待对手"
){}
when
Key
::
F3
$game
.
join
'127.0.0.1'
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"加入房间"
,
"正在加入房间"
){}
when
Key
::
F5
if
@roomlist
.
list
and
room
=
@roomlist
.
list
.
find
{
|
room
|
room
.
player1
==
$game
.
user
or
room
.
player2
==
$game
.
user
}
$game
.
qroom
room
...
...
lib/scene_single.rb
View file @
48dcc949
...
...
@@ -12,7 +12,8 @@ class Scene_Single < Scene
login
end
def
login
$game
.
login
(
ENV
[
'username'
])
username
=
$config
[
'username'
]
&&
!
$config
[
'username'
].
empty?
?
$config
[
'username'
]
:
$_ENV
[
'username'
]
$game
.
login
username
end
def
update
while
event
=
Game_Event
.
poll
...
...
lib/window.rb
View file @
48dcc949
...
...
@@ -37,7 +37,7 @@ class Window
end
def
include?
(
x
,
y
)
x
>
@x
&&
x
<
@x
+
@width
&&
y
>
@y
&&
y
<
@y
+
@height
x
>
=
@x
&&
x
<
@x
+
@width
&&
y
>=
@y
&&
y
<
@y
+
@height
end
def
destroy
@destroyed
=
true
...
...
@@ -74,7 +74,7 @@ class Window
def
clicked
#子类定义
end
def
lostfocus
def
lostfocus
(
active_window
=
nil
)
#子类定义
end
end
\ No newline at end of file
lib/window_action.rb
View file @
48dcc949
...
...
@@ -25,6 +25,7 @@ class Window_Action < Window_List
@list_available
=
list
.
values
@height
=
@viewport
[
3
]
=
@list
.
size
*
WLH
+
15
*
2
@item_max
=
@list
.
size
p
list
@index
=
@list_available
.
find_index
(
true
)
||
0
refresh
@visible
=
true
...
...
@@ -34,15 +35,14 @@ class Window_Action < Window_List
end
def
clear
(
x
=
0
,
y
=
0
,
width
=
@width
,
height
=
@height
)
@contents
.
put
(
@up
,
0
,
0
)
Surface
.
transform_draw
(
@middle
,
@contents
,
0
,
1
,(
@list
.
size
*
WLH
+
17
).
to_f
/
@middle
.
h
,
0
,
0
,
0
,
15
,
Surface
::
TRANSFORM_SAFE
)
#+17
那里,我不知道为什么需要这么做,但是如果不+ 内容和底边会有一点空白
Surface
.
transform_draw
(
@middle
,
@contents
,
0
,
1
,(
@list
.
size
*
WLH
+
20
).
to_f
/
@middle
.
h
,
0
,
0
,
0
,
15
,
Surface
::
TRANSFORM_SAFE
)
#+
那里,我不知道为什么需要这么做,但是如果不+ 内容和底边会有一点空白
@contents
.
put
(
@down
,
0
,
@height
-
15
)
end
def
index
=
(
index
)
if
index
if
index
and
index
>
0
and
index
<
@item_max
super
(
index
)
refresh
end
#p @index
end
def
draw_item
(
index
,
status
=
0
)
case
status
...
...
@@ -63,11 +63,14 @@ class Window_Action < Window_List
end
end
def
mousemoved
(
x
,
y
)
self
.
index
=
(
y
-
@y
)
/
WLH
self
.
index
=
(
y
-
@y
-
15
)
/
WLH
end
def
clicked
$scene
.
player_field_window
.
clicked
end
def
lostfocus
def
lostfocus
(
active_window
=
nil
)
if
active_window
!=
$scene
.
player_field_window
$scene
.
player_field_window
.
index
=
nil
end
end
end
\ No newline at end of file
lib/window_cardinfo.rb
View file @
48dcc949
# To change this template, choose Tools | Templates
# and open the template in the editor.
#encoding: UTF-8
class
Window_CardInfo
<
Window
WLH
=
20
def
initialize
(
x
,
y
)
...
...
lib/window_field.rb
View file @
48dcc949
...
...
@@ -19,7 +19,7 @@ class Window_Field < Window
Hand_Pos
=
[
0
,
201
,
62
,
8
]
#手卡: x, y, width, 间距
#Card_Size = [Card::CardBack.w, Card::CardBack.h]
Card_Size
=
[
54
,
81
]
attr_
reade
r
:action_window
attr_
accesso
r
:action_window
def
initialize
(
x
,
y
,
field
,
player
=
true
)
@border
=
Surface
.
load
'graphics/field/border.png'
@border_horizontal
=
Surface
.
load
'graphics/field/border_horizontal.png'
#@border.transform_surface(0x66000000,90,1,1,Surface::TRANSFORM_SAFE|Surface::TRANSFORM_AA)#FUCK!
...
...
@@ -32,7 +32,7 @@ class Window_Field < Window
refresh
end
def
refresh
$scene
.
fieldback_window
.
card
=
$
scene
.
player_field
.
field
[
0
]
||
$scen
e
.
opponent_field
.
field
[
0
]
rescue
nil
$scene
.
fieldback_window
.
card
=
$
game
.
player_field
.
field
[
0
]
||
$gam
e
.
opponent_field
.
field
[
0
]
rescue
nil
@items
.
clear
@cards
.
clear
if
!
@field
.
deck
.
empty?
...
...
@@ -103,7 +103,7 @@ class Window_Field < Window
end
if
index
.
nil?
or
!
@items
.
has_key?
(
index
)
or
(
index
==
:deck
and
@field
.
deck
.
empty?
)
or
(
index
==
:removed
and
@field
.
removed
.
empty?
)
or
(
index
==
:extra
and
@field
.
extra
.
empty?
)
or
(
index
==
:graveyard
and
@field
.
graveyard
.
empty?
)
@index
=
nil
$scene
.
action_window
.
list
=
nil
@action_window
.
list
=
nil
if
@action_window
else
@index
=
index
draw_item
(
@index
,
1
)
...
...
@@ -123,14 +123,14 @@ class Window_Field < Window
}
when
:extra
@card
=
@field
.
extra
.
first
@action_names
=
{
"特殊召唤"
=>
true
,
@action_names
=
{
"特殊召唤"
=>
!
@field
.
empty_field
(
@card
).
nil?
,
"效果发动"
=>
true
,
"从游戏中除外"
=>
true
,
"送入墓地"
=>
true
}
when
:removed
@card
=
@field
.
removed
.
first
@action_names
=
{
"特殊召唤"
=>
@card
.
monster?
,
@action_names
=
{
"特殊召唤"
=>
@card
.
monster?
&&
!
@field
.
empty_field
(
@card
).
nil?
,
"效果发动"
=>
true
,
"加入手卡"
=>
true
,
"返回卡组"
=>
true
,
...
...
@@ -138,7 +138,7 @@ class Window_Field < Window
}
when
:graveyard
@card
=
@field
.
graveyard
.
first
@action_names
=
{
"特殊召唤"
=>
@card
.
monster?
,
@action_names
=
{
"特殊召唤"
=>
@card
.
monster?
&&
!
@field
.
empty_field
(
@card
).
nil?
,
"效果发动"
=>
true
,
"加入手卡"
=>
true
,
"返回卡组"
=>
true
,
...
...
@@ -171,20 +171,22 @@ class Window_Field < Window
}
when
Integer
#手卡
@card
=
@field
.
hand
[
@index
-
11
]
@action_names
=
{
"召唤"
=>
@card
.
monster?
,
@action_names
=
{
"召唤"
=>
@card
.
monster?
&&
!
@field
.
empty_field
(
@card
).
nil?
,
"特殊召唤"
=>
false
,
"发动"
=>
@card
.
spell?
,
"放置到场上"
=>
true
,
"发动"
=>
@card
.
spell?
&&
!
@field
.
empty_field
(
@card
).
nil?
,
"放置到场上"
=>
true
&&
!
@field
.
empty_field
(
@card
).
nil?
,
"放回卡组顶端"
=>
true
,
"送入墓地"
=>
true
,
"从游戏中除外"
=>
true
,
"效果发动"
=>
true
}
end
$scene
.
action_window
.
list
=
@action_names
if
@action_window
@action_window
.
list
=
@action_names
@action_window
.
x
=
@x
+
@items
[
@index
][
0
]
-
(
@action_window
.
width
-
@items
[
@index
][
2
])
/
2
@action_window
.
y
=
@y
+
@items
[
@index
][
1
]
-
@action_window
.
height
end
$scene
.
cardinfo_window
.
card
=
@card
if
@card
.
known?
$scene
.
action_window
.
x
=
@x
+
@items
[
@index
][
0
]
-
(
$scene
.
action_window
.
width
-
@items
[
@index
][
2
])
/
2
$scene
.
action_window
.
y
=
@y
+
@items
[
@index
][
1
]
-
$scene
.
action_window
.
viewport
[
3
]
#height
end
end
def
mousemoved
(
x
,
y
)
...
...
@@ -195,10 +197,10 @@ class Window_Field < Window
end
end
def
cursor_up
$scene
.
action_window
.
cursor_up
@
action_window
.
cursor_up
end
def
cursor_down
$scene
.
action_window
.
cursor_down
@
action_window
.
cursor_down
end
def
cursor_left
#self.index = @index ? (@index - 1) % [@list.size, @item_max].min : 0
...
...
@@ -206,14 +208,16 @@ class Window_Field < Window
def
cursor_right
#self.index = @index ? (@index + 1) % [@list.size, @item_max].min : 0
end
def
lostfocus
self
.
index
=
nil
def
lostfocus
(
active_window
=
nil
)
if
active_window
!=
@action_window
self
.
index
=
nil
end
end
def
clicked
return
if
!
$scene
.
action_window
.
visible
return
if
!
@player
||
@index
.
nil?
case
@index
when
:deck
case
$scene
.
action_window
.
index
case
@
action_window
.
index
when
0
Action
::
Draw
.
new
(
true
).
run
when
1
...
...
@@ -237,7 +241,7 @@ class Window_Field < Window
p
"未实现"
end
when
:extra
case
$scene
.
action_window
.
index
case
@
action_window
.
index
when
0
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
SpecialSummon
.
new
(
true
,
:extra
,
pos
,
@card
,
nil
,
:attack
).
run
...
...
@@ -252,7 +256,7 @@ class Window_Field < Window
Action
::
SendToGraveyard
.
new
(
true
,
:extra
,
@card
).
run
end
when
:removed
case
$scene
.
action_window
.
index
case
@
action_window
.
index
when
0
#特殊召唤
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
SpecialSummon
.
new
(
true
,
:removed
,
pos
,
@card
).
run
...
...
@@ -269,7 +273,7 @@ class Window_Field < Window
Action
::
SendToGraveyard
.
new
(
true
,
:removed
,
@card
).
run
end
when
:graveyard
case
$scene
.
action_window
.
index
case
@
action_window
.
index
when
0
#特殊召唤
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
SpecialSummon
.
new
(
true
,
:graveyard
,
pos
,
@card
).
run
...
...
@@ -286,7 +290,7 @@ class Window_Field < Window
Action
::
Remove
.
new
(
true
,
:graveyard
,
@card
).
run
end
when
0
..
5
#后场
case
$scene
.
action_window
.
index
case
@
action_window
.
index
when
0
#效果发动
Action
::
Effect_Activate
.
new
(
true
,
@index
,
@card
).
run
when
1
#返回卡组
...
...
@@ -301,7 +305,7 @@ class Window_Field < Window
Action
::
ChangePosition
.
new
(
true
,
@index
,
@card
,
:set
).
run
end
when
6
..
10
#前场
case
$scene
.
action_window
.
index
case
@
action_window
.
index
when
0
Action
::
ChangePosition
.
new
(
true
,
@index
,
@card
,
:attack
).
run
when
1
...
...
@@ -328,7 +332,7 @@ class Window_Field < Window
Action
::
ReturnToHand
.
new
(
true
,
@index
,
@card
).
run
end
when
Integer
#手卡
case
$scene
.
action_window
.
index
case
@
action_window
.
index
when
0
#召唤
if
pos
=
@field
.
empty_field
(
@card
)
Action
::
Summon
.
new
(
true
,
:hand
,
pos
,
@card
).
run
...
...
lib/window_list.rb
View file @
48dcc949
...
...
@@ -70,7 +70,7 @@ class Window_List < Window
#return unless include?(x,y)
#self.index = (y - @y) / @single_height
end
def
lostfocus
def
lostfocus
(
active_window
=
nil
)
self
.
index
=
nil
end
def
clicked
...
...
lib/window_roomchat.rb
View file @
48dcc949
...
...
@@ -22,7 +22,7 @@ class Window_RoomChat < Window
@contents
.
fill_rect
(
0
,
0
,
@width
,
@height
,
0x99FFFFFF
)
@list
.
last
(
7
).
each_with_index
do
|
chat
,
index
|
player
,
content
=
chat
@font
.
draw_blended_utf8
(
@contents
,
content
,
0
,
index
*
WLH
,
*
(
player
?
Player_Color
:
Opponent_Color
))
@font
.
draw_blended_utf8
(
@contents
,
content
.
empty?
?
" "
:
content
,
0
,
index
*
WLH
,
*
(
player
?
Player_Color
:
Opponent_Color
))
end
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