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
482b469c
Commit
482b469c
authored
Dec 19, 2011
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
流程与回合结束
parent
fe974547
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
78 additions
and
64 deletions
+78
-64
README.txt
README.txt
+2
-2
lib/action.rb
lib/action.rb
+15
-1
lib/card.rb
lib/card.rb
+1
-1
lib/game.rb
lib/game.rb
+1
-1
lib/game_card.rb
lib/game_card.rb
+6
-0
lib/iduel/action.rb
lib/iduel/action.rb
+3
-2
lib/iduel/iduel.rb
lib/iduel/iduel.rb
+13
-9
lib/nbx/action.rb
lib/nbx/action.rb
+5
-4
lib/scene_duel.rb
lib/scene_duel.rb
+24
-39
lib/scene_hall.rb
lib/scene_hall.rb
+1
-1
lib/scene_watch.rb
lib/scene_watch.rb
+2
-0
lib/window_field.rb
lib/window_field.rb
+2
-3
lib/window_list.rb
lib/window_list.rb
+1
-1
lib/window_phases.rb
lib/window_phases.rb
+2
-0
mycard.cmd
mycard.cmd
+0
-0
No files found.
README.txt
View file @
482b469c
==
iduel
==
mycard
You should document your project here.
这是一个游戏王对战器,与nbx和iduel协议兼容,目前开发进度50%
\ No newline at end of file
lib/action.rb
View file @
482b469c
...
...
@@ -69,6 +69,13 @@ class Action
super
(
from_player
)
@phase
=
phase
end
def
run
$game
.
phase
=
phase
if
@from_player
and
phase
==
:EP
Game_Event
.
push
Game_Event
::
Action
.
new
(
TurnEnd
.
new
(
true
,
$game
.
player_field
,
$game
.
turn_player
?
turn
:
turn
.
next
))
end
super
end
end
class
Move
<
Action
attr_reader
:from_pos
,
:to_pos
,
:card
,
:position
...
...
@@ -258,6 +265,8 @@ class Action
@field
=
field
end
def
run
super
return
if
@field
.
is_a?
Game_Field
#本地信息,无需处理。
player_field
.
lp
=
@field
[
:lp
]
if
player_field
.
hand
.
size
>
@field
[
:hand
]
player_field
.
hand
.
pop
(
player_field
.
hand
.
size
-
@field
[
:hand
])
...
...
@@ -284,7 +293,6 @@ class Action
player_field
.
field
[
pos
]
=
nil
end
end
p
player_field
end
end
...
...
@@ -294,6 +302,12 @@ class Action
super
(
from_player
,
field
,
msg
)
@turn
=
turn
end
def
run
$game
.
phase
=
:DP
$game
.
turn
=
@turn
.
next
$game
.
turn_player
=
!
from_player
super
end
end
class
Show
<
Move
attr_reader
:from_pos
,
:card
...
...
lib/card.rb
View file @
482b469c
...
...
@@ -22,7 +22,7 @@ class Card
@all
[
id
]
||
old_new
(
@db
.
get_first_row
(
"select * from YGODATA where id =
#{
id
}
"
))
when
Symbol
row
=
@db
.
get_first_row
(
"select * from YGODATA where name = '
#{
id
}
'"
)
row
&&
(
@all
[
row
[
'id'
].
to_i
]
||
old_new
(
row
)
)
(
row
&&
(
@all
[
row
[
'id'
].
to_i
]
||
old_new
(
row
)))
||
Card
.
new
(
'id'
=>
0
,
'number'
=>
:"00000000"
,
'name'
=>
name
,
'card_type'
=>
:
通常怪兽
,
'stats'
=>
""
,
'archettypes'
=>
""
,
'mediums'
=>
""
,
'lore'
=>
""
)
when
Hash
old_new
(
id
)
when
nil
...
...
lib/game.rb
View file @
482b469c
...
...
@@ -3,7 +3,7 @@
#游戏适配器的抽象类
class
Game
attr_reader
:users
,
:rooms
attr_accessor
:user
,
:room
,
:player_field
,
:opponent_field
attr_accessor
:user
,
:room
,
:player_field
,
:opponent_field
,
:turn
,
:turn_player
,
:phase
def
initialize
@users
=
[]
@rooms
=
[]
...
...
lib/game_card.rb
View file @
482b469c
...
...
@@ -9,6 +9,12 @@ class Game_Card
@card
=
card
||
Card
.
find
(
nil
)
reset
end
def
atk
@card
.
atk
.
to_i
#把"?"转为0
end
def
def
@card
.
atk
.
to_i
#把"?"转为0
end
def
reset
@position
=
:set
@atk
=
@card
.
atk
...
...
lib/iduel/action.rb
View file @
482b469c
#encoding: UTF-8
#这个文件iduel和nbx相同,编辑时推荐使用软/硬链接来保持一致
require_relative
'../action'
class
Action
CardFilter
=
/((?:<)?(?:\[.*?\])?\[(?:.*?)\][\s\d]*(?:>)?|一张怪兽卡|一张魔\/陷卡|\?\?)/
...
...
@@ -31,7 +32,7 @@ class Action
if
index
=
card
.
rindex
(
"["
)
index
+=
1
name
=
card
[
index
,
card
.
rindex
(
"]"
)
-
index
].
to_sym
Card
.
find
(
name
)
||
Card
.
new
(
'id'
=>
0
,
'number'
=>
:"00000000"
,
'name'
=>
name
,
'card_type'
=>
:
通常怪兽
,
'stats'
=>
""
,
'archettypes'
=>
""
,
'mediums'
=>
""
)
Card
.
find
(
name
)
else
Card
.
find
(
nil
)
end
...
...
@@ -313,7 +314,7 @@ class Action
end
class
TurnEnd
def
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→=[0:0:0]==回合结束==<
0
>=[0]
\r\n
"
+
@field
.
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→=[0:0:0]==回合结束==<
#{
@turn
}
>=[0]
\r\n
"
+
@field
.
escape
end
end
class
Shuffle
...
...
lib/iduel/iduel.rb
View file @
482b469c
#encoding: UTF-8
class
Iduel
<
Game
V
ERSION
=
"20110131"
V
ersion
=
"20110131"
Server
=
"iduel.ocgsoft.cn"
Port
=
38522
...
...
@@ -15,15 +15,19 @@ class Iduel < Game
require_relative
'action'
require_relative
'event'
require_relative
'user'
@conn
=
TCPSocket
.
open
(
Server
,
Port
)
@conn
.
set_encoding
"GBK"
Thread
.
abort_on_exception
=
true
@recv
=
Thread
.
new
{
recv
@conn
.
gets
(
RS
)
while
@conn
}
begin
@conn
=
TCPSocket
.
open
(
Server
,
Port
)
@conn
.
set_encoding
"GBK"
Thread
.
abort_on_exception
=
true
@recv
=
Thread
.
new
{
recv
@conn
.
gets
(
RS
)
while
@conn
}
rescue
Game_Event
.
push
Game_Event
::
Error
.
new
(
$!
.
class
,
$!
.
message
)
end
end
def
login
(
username
,
password
)
md5
=
Digest
::
MD5
.
hexdigest
(
password
)
send
(
0
,
username
,
md5
,
checknum
(
"LOGINMSG"
,
username
,
md5
),
V
ERSION
)
send
(
0
,
username
,
md5
,
checknum
(
"LOGINMSG"
,
username
,
md5
),
V
ersion
)
end
def
refresh
send
(
1
,
@key
,
checknum
(
"UPINFOMSG"
,
@session
))
...
...
@@ -45,7 +49,7 @@ class Iduel < Game
end
end
def
action
(
action
)
send
(
2
,
"
#{
checknum
(
"RMSG"
,
@session
)
}
@
#{
@key
}
"
,
"
#{
action
.
escape
}
▊▊▊000000"
)
if
@room
.
include?
@user
#TODO:iduel校验字串
send
(
2
,
"
#{
checknum
(
"RMSG"
,
@session
)
}
@
#{
@key
}
"
,
"
#{
action
.
escape
}
鈻娾枈鈻�00000"
)
if
@room
.
include?
@user
#TODO:iduel鏍¢獙瀛椾覆
end
def
exit
send
(
11
,
@key
,
checknum
(
"ULO"
,
"
#{
@session
}
"
))
...
...
@@ -58,13 +62,13 @@ class Iduel < Game
def
send
(
head
,
*
args
)
info
=
"#
#{
head
.
to_s
(
16
).
upcase
}
|
#{
args
.
join
(
','
)
}
"
.
encode
(
"GBK"
)
+
RS
puts
"<<
#{
info
}
"
(
@conn
.
write
info
)
rescue
Game_Event
.
push
Game_Event
::
Error
.
new
(
0
)
(
@conn
.
write
info
)
rescue
Game_Event
.
push
Game_Event
::
Error
.
new
(
$!
.
class
,
$!
.
message
)
end
def
recv
(
info
)
if
info
.
nil?
@conn
.
close
@conn
=
nil
Game_Event
::
Error
.
new
(
0
)
Game_Event
::
Error
.
parse
(
0
)
else
info
.
chomp!
(
RS
)
info
.
encode!
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
...
...
lib/nbx/action.rb
View file @
482b469c
#encoding: UTF-8
#这个文件iduel和nbx相同,编辑时推荐使用软/硬链接来保持一致
require_relative
'../action'
class
Action
CardFilter
=
/((?:<)?(?:\[.*?\])?\[(?:.*?)\][\s\d]*(?:>)?|一张怪兽卡|一张魔\/陷卡|\?\?)/
...
...
@@ -12,7 +13,7 @@ class Action
pos
[
index
,
pos
.
index
(
")"
)
-
index
].
to_i
else
case
pos
when
"手卡"
when
"手卡"
,
"手牌"
:hand
when
"场上"
,
"魔陷区"
,
"怪兽区"
:field
...
...
@@ -31,7 +32,7 @@ class Action
if
index
=
card
.
rindex
(
"["
)
index
+=
1
name
=
card
[
index
,
card
.
rindex
(
"]"
)
-
index
].
to_sym
Card
.
find
(
name
)
||
Card
.
new
(
'id'
=>
0
,
'number'
=>
:"00000000"
,
'name'
=>
name
,
'card_type'
=>
:
通常怪兽
,
'stats'
=>
""
,
'archettypes'
=>
""
,
'mediums'
=>
""
)
Card
.
find
(
name
)
else
Card
.
find
(
nil
)
end
...
...
@@ -253,7 +254,7 @@ 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
}
效果发(?:\~)?动/
when
/(?:己方)?
#{
PosFilter
}
.*
?
#{
CardFilter
}
效果发(?:\~)?动/
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
))
...
...
@@ -313,7 +314,7 @@ class Action
end
class
TurnEnd
def
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→=[0:0:0]==回合结束==<
0
>=[0]
\r\n
"
+
@field
.
escape
"[
#{
@id
}
]
#{
from_player
?
'◎'
:
'●'
}
→=[0:0:0]==回合结束==<
#{
@turn
}
>=[0]
\r\n
"
+
@field
.
escape
end
end
class
Shuffle
...
...
lib/scene_duel.rb
View file @
482b469c
...
...
@@ -33,40 +33,33 @@ class Scene_Duel < Scene
@background
=
Surface
.
load
"graphics/field/main.png"
Surface
.
blit
(
@background
,
0
,
0
,
0
,
0
,
$screen
,
0
,
0
)
@player1_lp
=
Window_LP
.
new
(
0
,
0
,
@room
.
player1
,
true
)
@player2_lp
=
Window_LP
.
new
(
360
,
0
,
@room
.
player2
,
false
)
@phases_window
=
Window_Phases
.
new
(
124
,
357
)
@turn_player
=
true
$game
.
player_field
=
Game_Field
.
new
@deck
$game
.
opponent_field
=
Game_Field
.
new
@fieldback_window
=
Window_FieldBack
.
new
(
130
,
174
)
init_game
@player_lp_window
=
Window_LP
.
new
(
0
,
0
,
@room
.
player1
,
true
)
@opponent_lp_window
=
Window_LP
.
new
(
360
,
0
,
@room
.
player2
,
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
@phases_window
=
Window_Phases
.
new
(
124
,
357
)
@fieldback_window
=
Window_FieldBack
.
new
(
130
,
174
)
@cardinfo_window
=
Window_CardInfo
.
new
(
715
,
0
)
@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
)
create_action_window
super
#(Thread.list - [Thread.current]).each{|t|t.kill}
#p Thread.list
end
def
create_action_window
@player_field_window
.
action_window
=
Window_Action
.
new
end
def
init_game
$game
.
player_field
=
Game_Field
.
new
@deck
$game
.
opponent_field
=
Game_Field
.
new
$game
.
turn_player
=
true
#
$game
.
turn
=
0
end
def
change_phase
(
phase
)
action
Action
::
ChangePhase
.
new
(
@turn_player
,
[
:DP
,
:SP
,
:M1
,
:BP
,
:M2
,
:EP
][
phase
])
if
phase
==
5
@turn_player
=
!
@turn_player
@phase
=
0
@phases_window
.
player
=
@turn_player
action
Action
::
TurnEnd
.
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
)
else
@phase
=
@phases_window
.
phase
=
phase
@phases_window
.
refresh
end
action
Action
::
ChangePhase
.
new
(
true
,
phase
)
end
def
reset
action
Action
::
Reset
.
new
(
true
)
...
...
@@ -80,12 +73,8 @@ class Scene_Duel < Scene
case
event
.
button
when
Mouse
::
BUTTON_LEFT
if
@phases_window
.
include?
event
.
x
,
event
.
y
if
@turn_player
@phases_window
.
mousemoved
event
.
x
,
event
.
y
change_phase
(
@phases_window
.
index
)
else
@phases_window
.
index
=
@phase
end
@phases_window
.
mousemoved
event
.
x
,
event
.
y
change_phase
(
Window_Phases
::
Phases
[
@phases_window
.
index
])
end
when
Mouse
::
BUTTON_RIGHT
if
@player_field_window
.
action_window
...
...
@@ -113,14 +102,7 @@ class Scene_Duel < Scene
def
action
(
action
)
if
action
.
from_player
str
=
action
.
escape
if
str
=~
/^\[\d+\] (?:●|◎)→(.*)$/m
str
=
$1
end
$chat_window
.
add
action
.
from_player
,
str
end
action
.
run
Game_Event
.
push
Game_Event
::
Action
.
new
(
action
)
end
def
handle_game
(
event
)
...
...
@@ -131,9 +113,12 @@ class Scene_Duel < Scene
str
=
$1
end
$chat_window
.
add
event
.
action
.
from_player
,
str
action
event
.
actio
n
event
.
action
.
ru
n
@player_field_window
.
refresh
@opponent_field_window
.
refresh
@phases_window
.
player
=
$game
.
turn_player
@phases_window
.
phase
=
$game
.
phase
@fieldback_window
.
card
=
$game
.
player_field
.
field
[
0
]
||
$game
.
opponent_field
.
field
[
0
]
when
Game_Event
::
Error
Widget_Msgbox
.
new
(
event
.
title
,
event
.
message
){
$scene
=
Scene_Title
.
new
}
when
Game_Event
::
Leave
...
...
lib/scene_hall.rb
View file @
482b469c
...
...
@@ -54,7 +54,7 @@ class Scene_Hall < Scene
if
@roomlist
.
list
and
room
=
@roomlist
.
list
.
find
{
|
room
|
room
.
player1
==
$game
.
user
or
room
.
player2
==
$game
.
user
}
$game
.
qroom
room
end
$game
.
close
$game
.
exit
$scene
=
Scene_Login
.
new
end
when
Event
::
KeyUp
...
...
lib/scene_watch.rb
View file @
482b469c
...
...
@@ -5,6 +5,8 @@
#==============================================================================
require_relative
'scene_duel'
class
Scene_Watch
<
Scene_Duel
def
create_action_window
end
def
action
(
action
)
action
.
run
end
...
...
lib/window_field.rb
View file @
482b469c
...
...
@@ -32,7 +32,6 @@ class Window_Field < Window
refresh
end
def
refresh
$scene
.
fieldback_window
.
card
=
$game
.
player_field
.
field
[
0
]
||
$game
.
opponent_field
.
field
[
0
]
rescue
nil
@items
.
clear
@cards
.
clear
if
!
@field
.
deck
.
empty?
...
...
@@ -97,7 +96,7 @@ class Window_Field < Window
end
def
index
=
(
index
)
return
if
index
==
@index
if
@index
if
@index
and
@items
.
has_key?
(
@index
)
||
(
@index
==
:deck
and
!
@field
.
deck
.
empty?
)
||
(
@index
==
:removed
and
!
@field
.
removed
.
empty?
)
||
(
@index
==
:extra
and
!
@field
.
extra
.
empty?
)
||
(
@index
==
:graveyard
and
!
@field
.
graveyard
.
empty?
)
clear
(
@items
[
@index
][
0
]
-
1
,
@items
[
@index
][
1
]
-
1
,
@items
[
@index
][
2
]
+
2
,
@items
[
@index
][
3
]
+
2
)
draw_item
(
@index
,
0
)
end
...
...
@@ -214,7 +213,7 @@ class Window_Field < Window
end
end
def
clicked
return
if
!
@player
||
@index
.
nil?
return
unless
@action_window
&&
@index
action
=
case
@index
when
:deck
case
@action_window
.
index
...
...
lib/window_list.rb
View file @
482b469c
...
...
@@ -40,7 +40,7 @@ class Window_List < Window
def
list
=
(
list
)
@list
=
list
@item_max
=
@list
.
size
@height
=
@item_max
*
WLH
@height
=
@item_max
*
self
.
class
::
WLH
refresh
end
def
refresh
...
...
lib/window_phases.rb
View file @
482b469c
class
Window_Phases
<
Window_List
WLH
=
80
#其实是列宽
Phases
=
[
:DP
,
:SP
,
:M1
,
:BP
,
:M2
,
:EP
]
def
initialize
(
x
,
y
)
@phases_player
=
Surface
.
load
'graphics/system/phases_player.png'
@phases_opponent
=
Surface
.
load
'graphics/system/phases_opponent.png'
...
...
@@ -14,6 +15,7 @@ class Window_Phases < Window_List
refresh
end
def
phase
=
(
phase
)
phase
=
Phases
.
index
(
phase
)
unless
(
0
..
5
).
include?
phase
return
if
phase
==
@phase
@index
=
@phase
@phase
=
phase
...
...
iduel
.cmd
→
mycard
.cmd
View file @
482b469c
File moved
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