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
aa607677
Commit
aa607677
authored
Dec 20, 2011
by
zh99998
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replay初步
parent
a3afe1d2
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
54 additions
and
17 deletions
+54
-17
lib/action.rb
lib/action.rb
+1
-5
lib/iduel/action.rb
lib/iduel/action.rb
+1
-1
lib/iduel/event.rb
lib/iduel/event.rb
+1
-1
lib/iduel/iduel.rb
lib/iduel/iduel.rb
+7
-5
lib/iduel/user.rb
lib/iduel/user.rb
+5
-2
lib/nbx/action.rb
lib/nbx/action.rb
+1
-1
lib/replay.rb
lib/replay.rb
+18
-0
lib/room.rb
lib/room.rb
+1
-1
lib/scene_duel.rb
lib/scene_duel.rb
+18
-0
lib/scene_hall.rb
lib/scene_hall.rb
+1
-1
No files found.
lib/action.rb
View file @
aa607677
...
@@ -338,11 +338,7 @@ class Action
...
@@ -338,11 +338,7 @@ class Action
super
(
from_player
,
from_pos
,
nil
,
card
,
nil
,
position
)
super
(
from_player
,
from_pos
,
nil
,
card
,
nil
,
position
)
end
end
end
end
class
Ignored
<
Action
class
ViewDeck
<
Action
;
end
def
initialize
(
str
)
@str
=
str
end
end
class
Unknown
<
Action
class
Unknown
<
Action
def
initialize
(
str
)
def
initialize
(
str
)
@str
=
str
@str
=
str
...
...
lib/iduel/action.rb
View file @
aa607677
...
@@ -207,7 +207,7 @@ class Action
...
@@ -207,7 +207,7 @@ class Action
when
"卡组洗切"
,
"切洗卡组"
when
"卡组洗切"
,
"切洗卡组"
Shuffle
.
new
from_player
Shuffle
.
new
from_player
when
"查看卡组"
when
"查看卡组"
Ignored
.
new
"查看卡组"
ViewDeck
.
new
from_player
when
"将顶牌放回卡组底部"
when
"将顶牌放回卡组底部"
ReturnToDeckBottom
.
new
(
from_player
,
:deck
)
ReturnToDeckBottom
.
new
(
from_player
,
:deck
)
when
/抽取\((\d+)\)张卡/
when
/抽取\((\d+)\)张卡/
...
...
lib/iduel/event.rb
View file @
aa607677
...
@@ -106,7 +106,7 @@ class Game_Event
...
@@ -106,7 +106,7 @@ class Game_Event
class
NewRoom
class
NewRoom
def
self
.
parse
(
info
)
def
self
.
parse
(
info
)
id
,
x
,
player1
,
player2
=
info
.
split
(
","
,
4
)
id
,
x
,
player1
,
player2
=
info
.
split
(
","
,
4
)
room
=
Room
.
new
(
id
)
room
=
Room
.
new
(
id
.
to_i
)
room
.
player1
=
User
.
parse
(
player1
)
room
.
player1
=
User
.
parse
(
player1
)
room
.
player2
=
User
.
parse
(
player2
)
room
.
player2
=
User
.
parse
(
player2
)
self
.
new
room
self
.
new
room
...
...
lib/iduel/iduel.rb
View file @
aa607677
...
@@ -33,7 +33,7 @@ class Iduel < Game
...
@@ -33,7 +33,7 @@ class Iduel < Game
send
(
1
,
@key
,
checknum
(
"UPINFOMSG"
,
@session
))
send
(
1
,
@key
,
checknum
(
"UPINFOMSG"
,
@session
))
end
end
def
host
(
name
,
password
=
""
,
lv
=
0
,
color
=
0
)
def
host
(
name
,
password
=
""
,
lv
=
0
,
color
=
0
)
send
(
6
,
@key
,
name
,
password
,
checknum
(
"JOINROOMMSG"
,
@session
+
name
+
password
+
"0"
),
0
,
color
,
lv
,
0
,
nil
,
nil
)
#TODO:v.ak, v.al
send
(
6
,
@key
,
name
,
password
,
checknum
(
"JOINROOMMSG"
,
@session
+
name
+
password
+
"0"
),
0
,
color
,
lv
,
0
,
0
,
0
)
#TODO:v.ak, v.al
end
end
def
join
(
room
,
password
=
""
)
def
join
(
room
,
password
=
""
)
send
(
6
,
@key
,
room
.
id
,
password
,
checknum
(
"JOINROOMMSG"
,
@session
+
room
.
id
.
to_s
+
password
+
"1"
),
1
)
send
(
6
,
@key
,
room
.
id
,
password
,
checknum
(
"JOINROOMMSG"
,
@session
+
room
.
id
.
to_s
+
password
+
"1"
),
1
)
...
@@ -49,13 +49,15 @@ class Iduel < Game
...
@@ -49,13 +49,15 @@ class Iduel < Game
end
end
end
end
def
action
(
action
)
def
action
(
action
)
send
(
2
,
"
#{
checknum
(
"RMSG"
,
@session
)
}
@
#{
@key
}
"
,
"
#{
action
.
escape
}
鈻娾枈鈻�00000"
)
if
@room
.
include?
@user
#TODO:iduel鏍¢獙瀛椾覆
send
(
2
,
"
#{
checknum
(
"RMSG"
,
@session
)
}
@
#{
@key
}
"
,
"
#{
action
.
escape
}
▊▊▊mycard"
)
if
@room
.
include?
@user
#TODO:iduel校验字串
end
end
def
exit
def
exit
send
(
11
,
@key
,
checknum
(
"ULO"
,
"
#{
@session
}
"
))
@recv
.
exit
@recv
.
exit
@conn
.
close
if
@conn
@conn
=
nil
send
(
11
,
@key
,
checknum
(
"ULO"
,
"
#{
@session
}
"
))
@conn
.
close
@conn
=
nil
end
end
end
...
...
lib/iduel/user.rb
View file @
aa607677
class
User
class
User
attr_accessor
:level
,
:exp
attr_accessor
:level
,
:exp
def
self
.
parse
(
info
)
def
self
.
parse
(
info
)
info
=~
/(.+)\((\d+)\)/
if
info
=~
/(.+)\((\d+)\)/
new
$2
.
to_i
,
$1
new
$2
.
to_i
,
$1
else
nil
end
end
end
def
initialize
(
id
,
name
=
""
,
level
=
nil
,
exp
=
nil
)
def
initialize
(
id
,
name
=
""
,
level
=
nil
,
exp
=
nil
)
@id
=
id
@id
=
id
...
...
lib/nbx/action.rb
View file @
aa607677
...
@@ -207,7 +207,7 @@ class Action
...
@@ -207,7 +207,7 @@ class Action
when
"卡组洗切"
,
"切洗卡组"
when
"卡组洗切"
,
"切洗卡组"
Shuffle
.
new
from_player
Shuffle
.
new
from_player
when
"查看卡组"
when
"查看卡组"
Ignored
.
new
"查看卡组"
ViewDeck
.
new
"查看卡组"
when
"将顶牌放回卡组底部"
when
"将顶牌放回卡组底部"
ReturnToDeckBottom
.
new
(
from_player
,
:deck
)
ReturnToDeckBottom
.
new
(
from_player
,
:deck
)
when
/抽取\((\d+)\)张卡/
when
/抽取\((\d+)\)张卡/
...
...
lib/replay.rb
0 → 100644
View file @
aa607677
class
Replay
ReplayPath
=
'replay'
LastReplay
=
'lastreplay.txt'
def
initialize
(
filename
=
LastReplay
)
@file
=
open
(
File
.
expand_path
(
filename
,
ReplayPath
),
'w'
)
end
def
add
(
action
)
action
=
action
.
escape
if
action
.
is_a?
Action
@file
.
write
action
+
"
\n
"
end
def
save
(
filename
=
"
#{
Time
.
now
.
strftime
(
"%Y-%m-%d_%H:%M-%S"
)
}
_
#{
$game
.
room
.
player1
.
name
}
(
#{
$game
.
room
.
player1
.
id
}
)_
#{
$game
.
room
.
player2
.
name
}
(
#{
$game
.
room
.
player2
.
id
}
).txt"
)
close
File
.
rename
(
@file
.
path
,
File
.
expand_path
(
filename
,
ReplayPath
))
end
def
close
@file
.
close
end
end
lib/room.rb
View file @
aa607677
...
@@ -2,7 +2,7 @@ class Room
...
@@ -2,7 +2,7 @@ class Room
Color
=
[[
0
,
0
,
0
],
[
255
,
0
,
0
],
[
0
,
255
,
0
],
[
0
,
0
,
255
],
[
255
,
165
,
0
]]
Color
=
[[
0
,
0
,
0
],
[
255
,
0
,
0
],
[
0
,
255
,
0
],
[
0
,
0
,
255
],
[
255
,
165
,
0
]]
extend
Cacheable
extend
Cacheable
attr_accessor
:id
,
:name
,
:player1
,
:player2
,
:private
,
:color
,
:forbid
attr_accessor
:id
,
:name
,
:player1
,
:player2
,
:private
,
:color
,
:forbid
def
initialize
(
id
,
name
=
""
,
player1
=
nil
,
player2
=
nil
,
private
=
false
,
color
=
[
0
,
0
,
0
],
session
=
nil
,
forbid
=
nil
)
def
initialize
(
id
,
name
=
"
等待更新
"
,
player1
=
nil
,
player2
=
nil
,
private
=
false
,
color
=
[
0
,
0
,
0
],
session
=
nil
,
forbid
=
nil
)
@id
=
id
@id
=
id
@name
=
name
@name
=
name
@player1
=
player1
@player1
=
player1
...
...
lib/scene_duel.rb
View file @
aa607677
...
@@ -13,6 +13,7 @@ class Scene_Duel < Scene
...
@@ -13,6 +13,7 @@ class Scene_Duel < Scene
require_relative
'card'
require_relative
'card'
require_relative
'deck'
require_relative
'deck'
require_relative
'action'
require_relative
'action'
require_relative
'replay'
require_relative
'game_card'
require_relative
'game_card'
require_relative
'game_field'
require_relative
'game_field'
require_relative
'window_roomchat'
require_relative
'window_roomchat'
...
@@ -34,6 +35,7 @@ class Scene_Duel < Scene
...
@@ -34,6 +35,7 @@ class Scene_Duel < Scene
Surface
.
blit
(
@background
,
0
,
0
,
0
,
0
,
$screen
,
0
,
0
)
Surface
.
blit
(
@background
,
0
,
0
,
0
,
0
,
$screen
,
0
,
0
)
init_game
init_game
init_replay
@player_lp_window
=
Window_LP
.
new
(
0
,
0
,
@room
.
player1
,
true
)
@player_lp_window
=
Window_LP
.
new
(
0
,
0
,
@room
.
player1
,
true
)
@opponent_lp_window
=
Window_LP
.
new
(
360
,
0
,
@room
.
player2
,
false
)
@opponent_lp_window
=
Window_LP
.
new
(
360
,
0
,
@room
.
player2
,
false
)
...
@@ -47,11 +49,18 @@ class Scene_Duel < Scene
...
@@ -47,11 +49,18 @@ class Scene_Duel < Scene
@chat_window
=
Window_RoomChat
.
new
(
@cardinfo_window
.
x
,
@cardinfo_window
.
height
,
1024
-
@cardinfo_window
.
x
,
768
-
@cardinfo_window
.
height
)
@chat_window
=
Window_RoomChat
.
new
(
@cardinfo_window
.
x
,
@cardinfo_window
.
height
,
1024
-
@cardinfo_window
.
x
,
768
-
@cardinfo_window
.
height
)
create_action_window
create_action_window
super
super
end
end
def
create_action_window
def
create_action_window
@player_field_window
.
action_window
=
Window_Action
.
new
@player_field_window
.
action_window
=
Window_Action
.
new
end
end
def
init_replay
@replay
=
Replay
.
new
end
def
save_replay
@replay
.
save
if
@replay
end
def
init_game
def
init_game
$game
.
player_field
=
Game_Field
.
new
@deck
$game
.
player_field
=
Game_Field
.
new
@deck
$game
.
opponent_field
=
Game_Field
.
new
$game
.
opponent_field
=
Game_Field
.
new
...
@@ -108,6 +117,11 @@ class Scene_Duel < Scene
...
@@ -108,6 +117,11 @@ class Scene_Duel < Scene
def
handle_game
(
event
)
def
handle_game
(
event
)
case
event
case
event
when
Game_Event
::
Action
when
Game_Event
::
Action
if
event
.
action
.
instance_of?
(
Action
::
Reset
)
and
event
.
action
.
from_player
save_replay
init_replay
end
@replay
.
add
event
.
str
str
=
event
.
str
str
=
event
.
str
if
str
=~
/^\[\d+\] (?:●|◎)→(.*)$/m
if
str
=~
/^\[\d+\] (?:●|◎)→(.*)$/m
str
=
$1
str
=
$1
...
@@ -144,4 +158,8 @@ class Scene_Duel < Scene
...
@@ -144,4 +158,8 @@ class Scene_Duel < Scene
yield
yield
$screen
.
update_rect
(
x
,
y
,
width
,
height
)
$screen
.
update_rect
(
x
,
y
,
width
,
height
)
end
end
def
terminate
save_replay
super
end
end
end
\ No newline at end of file
lib/scene_hall.rb
View file @
aa607677
...
@@ -40,7 +40,7 @@ class Scene_Hall < Scene
...
@@ -40,7 +40,7 @@ class Scene_Hall < Scene
when
Key
::
RETURN
when
Key
::
RETURN
@active_window
.
clicked
@active_window
.
clicked
when
Key
::
F2
when
Key
::
F2
$game
.
host
$game
.
host
(
"test"
)
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"创建房间"
,
"正在等待对手"
)
@joinroom_msgbox
=
Widget_Msgbox
.
new
(
"创建房间"
,
"正在等待对手"
)
when
Key
::
F3
when
Key
::
F3
$game
.
join
'192.168.0.103'
$game
.
join
'192.168.0.103'
...
...
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