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
89688fc9
Commit
89688fc9
authored
Jan 18, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iduel html replay
parent
fbff5c91
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
468 additions
and
149 deletions
+468
-149
lib/action.rb
lib/action.rb
+272
-69
lib/card.rb
lib/card.rb
+35
-19
lib/game_card.rb
lib/game_card.rb
+7
-4
lib/iduel/action.rb
lib/iduel/action.rb
+79
-26
lib/iduel/replay.rb
lib/iduel/replay.rb
+48
-16
lib/scene_duel.rb
lib/scene_duel.rb
+13
-10
lib/window_field.rb
lib/window_field.rb
+14
-5
No files found.
lib/action.rb
View file @
89688fc9
This diff is collapsed.
Click to expand it.
lib/card.rb
View file @
89688fc9
...
@@ -111,22 +111,22 @@ class Card
...
@@ -111,22 +111,22 @@ class Card
@all
.
clear
#清空缓存
@all
.
clear
#清空缓存
end
end
end
end
attr_accessor
:id
attr_accessor
:id
attr_accessor
:number
attr_accessor
:number
attr_accessor
:name
attr_accessor
:name
attr_accessor
:card_type
attr_accessor
:card_type
attr_accessor
:monster_type
attr_accessor
:monster_type
attr_accessor
:atk
attr_accessor
:atk
attr_accessor
:def
attr_accessor
:def
attr_accessor
:attribute
attr_accessor
:attribute
attr_accessor
:type
attr_accessor
:type
attr_accessor
:level
attr_accessor
:level
attr_accessor
:lore
attr_accessor
:lore
attr_accessor
:status
attr_accessor
:status
attr_accessor
:stats
attr_accessor
:stats
attr_accessor
:archettypes
attr_accessor
:archettypes
attr_accessor
:mediums
attr_accessor
:mediums
attr_accessor
:tokens
attr_accessor
:tokens
def
initialize
(
hash
)
def
initialize
(
hash
)
@id
=
hash
[
'id'
].
to_i
@id
=
hash
[
'id'
].
to_i
...
@@ -145,17 +145,27 @@ attr_accessor :tokens
...
@@ -145,17 +145,27 @@ attr_accessor :tokens
@archettypes
=
hash
[
'archettypes'
].
split
(
"
\t
"
).
collect
{
|
archettype
|
stat
.
to_sym
}
@archettypes
=
hash
[
'archettypes'
].
split
(
"
\t
"
).
collect
{
|
archettype
|
stat
.
to_sym
}
@mediums
=
hash
[
'mediums'
].
split
(
"
\t
"
).
collect
{
|
medium
|
medium
.
to_sym
}
@mediums
=
hash
[
'mediums'
].
split
(
"
\t
"
).
collect
{
|
medium
|
medium
.
to_sym
}
@tokens
=
hash
[
'tokens'
]
&&
hash
[
'tokens'
].
split
(
"
\t
"
).
collect
{
|
token
|
token
.
to_i
}
@tokens
=
hash
[
'tokens'
]
&&
hash
[
'tokens'
].
split
(
"
\t
"
).
collect
{
|
token
|
token
.
to_i
}
@token
=
hash
[
'token'
]
Card
.
cache
[
@id
]
=
self
Card
.
cache
[
@id
]
=
self
end
def
create_image
@image
||=
Surface
.
load
(
"graphics/field/card.jpg"
).
display_format
end
end
def
image
def
image
@image
||=
Surface
.
load
"
#{
PicPath
}
/
#{
@id
-
1
}
.jpg"
rescue
Surface
.
load
"graphics/field/card.jpg"
@image
||=
Surface
.
load
(
"
#{
PicPath
}
/
#{
@id
-
1
}
.jpg"
).
display_format
rescue
create_image
end
end
def
image_small
def
image_small
@image_small
||=
image
.
transform_surface
(
0xFF000000
,
0
,
54.0
/
image
.
w
,
81.0
/
image
.
h
,
Surface
::
TRANSFORM_SAFE
)
@image_small
||=
image
.
transform_surface
(
0xFF000000
,
0
,
54.0
/
image
.
w
,
81.0
/
image
.
h
,
Surface
::
TRANSFORM_SAFE
)
end
end
def
image_horizontal
def
image_horizontal
@image_horizontal
||=
image_small
.
transform_surface
(
0xFF000000
,
90
,
1
,
1
,
Surface
::
TRANSFORM_SAFE
)
if
@image_horizontal
.
nil?
image_horizontal
=
image_small
.
transform_surface
(
0xFF000000
,
90
,
1
,
1
,
Surface
::
TRANSFORM_SAFE
)
@image_horizontal
=
image_horizontal
.
copy_rect
(
1
,
1
,
81
,
54
)
#SDL的bug,会多出1像素的黑边
image_horizontal
.
destroy
end
@image_horizontal
end
end
def
unknown?
def
unknown?
@id
==
1
@id
==
1
...
@@ -169,6 +179,12 @@ attr_accessor :tokens
...
@@ -169,6 +179,12 @@ attr_accessor :tokens
def
spell?
def
spell?
[:
通常魔法
,
:
速攻魔法
,
:
装备魔法
,
:
场地魔法
,
:
仪式魔法
,
:
永续魔法
].
include?
card_type
[:
通常魔法
,
:
速攻魔法
,
:
装备魔法
,
:
场地魔法
,
:
仪式魔法
,
:
永续魔法
].
include?
card_type
end
end
def
extra?
[:
融合怪兽
,
:
同调怪兽
,
:
超量怪兽
].
include?
card_type
end
def
token?
@token
end
def
inspect
def
inspect
"[
#{
card_type
}
][
#{
name
}
]"
"[
#{
card_type
}
][
#{
name
}
]"
end
end
...
...
lib/game_card.rb
View file @
89688fc9
#encoding: UTF-8
#encoding: UTF-8
class
Game_Card
class
Game_Card
attr_accessor
:card
,
:position
#attack|defense|set,
attr_accessor
:card
,
:position
,
:counters
attr_
accesso
r
:atk
,
:def
attr_
write
r
:atk
,
:def
@@count
=
0
@@count
=
0
def
initialize
(
card
=
nil
)
def
initialize
(
card
=
nil
)
@@count
+=
1
@@count
+=
1
...
@@ -13,16 +13,19 @@ class Game_Card
...
@@ -13,16 +13,19 @@ class Game_Card
@card
.
atk
.
to_i
#把"?"转为0
@card
.
atk
.
to_i
#把"?"转为0
end
end
def
def
def
def
@card
.
atk
.
to_i
#把"?"转为0
@card
.
def
.
to_i
#把"?"转为0
end
end
def
reset
(
reset_position
=
true
)
def
reset
(
reset_position
=
true
)
@position
=
:set
if
reset_position
@position
=
:set
if
reset_position
@atk
=
@card
.
atk
@atk
=
@card
.
atk
@def
=
@card
.
def
@def
=
@card
.
def
@counters
=
0
end
end
def
card
=
(
card
)
def
card
=
(
card
)
return
if
@card
==
card
@card
=
card
@card
=
card
reset
(
false
)
@atk
=
@card
.
atk
@def
=
@card
.
def
end
end
def
known?
def
known?
@card
!=
Card
::
Unknown
@card
!=
Card
::
Unknown
...
...
lib/iduel/action.rb
View file @
89688fc9
This diff is collapsed.
Click to expand it.
lib/iduel/replay.rb
View file @
89688fc9
#encoding: UTF-8
#encoding: UTF-8
class
Replay
class
Replay
Delimiter
=
/^.+?\(\d+\)(?:\(\d+:\d+:\d+\))?(?:: |:)\n ?/
User_Filter
=
/(.+?)\((\d+)\)(?:\(\d+:\d+:\d+\))?(?::|:) */
Player_Filter
=
/^(.+?)\((\d+)\)(?:\(\d+:\d+:\d+\))?(?:: |:)\n ?\[\d+\] ◎→/
Delimiter
=
/^
#{
User_Filter
}
\n ?/
Opponent_Filter
=
/^(.+?)\((\d+)\)(?:\(\d+:\d+:\d+\))?(?:: |:)\n ?\[\d+\] ●→/
Player_Filter
=
/
#{
Delimiter
}
\[\d+\] ◎→/
Opponent_Filter
=
/
#{
Delimiter
}
\[\d+\] ●→/
HTML_Player_Filter
=
/<font color=blue><strong>
#{
User_Filter
}
<\/strong>/
HTML_Opponent_Filter
=
/<font color=red><strong>
#{
User_Filter
}
<\/strong>/
attr_accessor
:room
,
:player1
,
:player2
,
:actions
attr_accessor
:room
,
:player1
,
:player2
,
:actions
def
add
(
action
)
def
add
(
action
)
# user = action.from_player ? $game.player1 : $game.player2
# user = action.from_player ? $game.player1 : $game.player2
...
@@ -13,26 +16,55 @@ class Replay
...
@@ -13,26 +16,55 @@ class Replay
file
=
open
(
filename
)
file
=
open
(
filename
)
file
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
file
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
result
=
self
.
new
(
file
)
result
=
self
.
new
(
file
)
contents
=
file
.
read
contents
=
file
.
read
.
strip
if
contents
=~
Player_Filter
if
contents
[
0
,
7
]
==
"<table>"
result
.
player1
=
User
.
new
(
$2
.
to_i
,
$1
)
result
.
player1
=
User
.
new
(
$2
.
to_i
,
$1
)
if
contents
=~
HTML_Player_Filter
result
.
player2
=
User
.
new
(
$2
.
to_i
,
$1
)
if
contents
=~
HTML_Opponent_Filter
from_players
=
contents
.
scan
(
Regexp
.
union
(
HTML_Player_Filter
,
HTML_Opponent_Filter
)).
collect
{
|
matched
|
matched
[
0
]
?
true
:
false
}
#匹配player成功matched前两位有值,opponent成功后两位有值,["尸体", "100015", nil, nil], il, nil], [nil, nil, "游戏的徒弟", "288436"]
#去除HTML标签
contents
.
gsub!
(
/<.*?>/
,
''
)
#处理HTML转义字符
require
'cgi'
contents
=
CGI
.
unescape_html
(
contents
)
else
else
result
.
player1
=
User
.
new
(
0
,
"我"
)
result
.
player1
=
User
.
new
(
$2
.
to_i
,
$1
)
if
contents
=~
Player_Filter
end
result
.
player2
=
User
.
new
(
$2
.
to_i
,
$1
)
if
contents
=~
Opponent_Filter
if
contents
=~
Opponent_Filter
from_players
=
contents
.
scan
(
Delimiter
).
collect
do
|
matched
|
result
.
player2
=
User
.
new
(
$2
.
to_i
,
$1
)
id
=
matched
[
1
].
to_i
name
=
matched
[
0
]
if
result
.
player1
and
result
.
player1
.
id
==
id
true
elsif
result
.
player2
and
result
.
player2
.
id
==
id
false
elsif
result
.
player1
.
nil?
result
.
player1
=
User
.
new
(
id
,
name
)
true
elsif
result
.
player2
.
nil?
result
.
player2
=
User
.
new
(
id
,
name
)
false
else
else
result
.
player2
=
User
.
new
(
1
,
"对手"
)
#无法匹配玩家,一般是观战消息..
false
end
end
end
end
result
.
actions
=
contents
.
split
(
Delimiter
).
collect
do
|
action_str
|
result
.
player1
||=
User
.
new
(
0
,
"我"
)
action_str
.
strip!
result
.
player2
||=
User
.
new
(
1
,
"对手"
)
next
if
action_str
.
empty?
lines
=
contents
.
split
(
Delimiter
)
lines
.
shift
#split后,在第一个操作之前会多出一个空白元素
lines
=
lines
.
each_slice
(
lines
.
size
/
from_players
.
size
).
collect
{
|
a
|
a
.
last
.
strip
}
from_players
=
from_players
.
to_enum
result
.
actions
=
lines
.
collect
do
|
action_str
|
action
=
Action
.
parse
action_str
action
=
Action
.
parse
action_str
action
.
from_player
=
from_players
.
next
Game_Event
::
Action
.
new
(
action
,
action_str
)
Game_Event
::
Action
.
new
(
action
,
action_str
)
end
.
compact
end
$game
.
room
=
result
.
room
=
Room
.
new
(
0
,
"Replay"
,
result
.
player1
,
result
.
player2
)
$game
.
room
=
result
.
room
=
Room
.
new
(
0
,
"Replay"
,
result
.
player1
,
result
.
player2
)
result
result
end
end
def
self
.
html_decode
(
text
)
text
.
gsub
(
Regexp
.
new
(
HTML_Replacement
.
keys
.
collect
{
|
key
|
Regexp
.
escape
key
}.
join
(
'|'
)),
HTML_Replacement
)
end
def
get
def
get
@actions
.
shift
@actions
.
shift
end
end
...
...
lib/scene_duel.rb
View file @
89688fc9
...
@@ -39,13 +39,16 @@ class Scene_Duel < Scene
...
@@ -39,13 +39,16 @@ class Scene_Duel < Scene
@fieldback_window
=
Window_FieldBack
.
new
(
130
,
174
)
@fieldback_window
=
Window_FieldBack
.
new
(
130
,
174
)
@cardinfo_window
=
Window_CardInfo
.
new
(
715
,
0
)
@cardinfo_window
=
Window_CardInfo
.
new
(
715
,
0
)
@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
)
@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
=
Window_Field
.
new
(
4
,
60
,
$game
.
opponent_field
,
false
)
@player_lp_window
=
Window_LP
.
new
(
0
,
0
,
@room
.
player1
,
true
)
@opponent_lp_window
=
Window_LP
.
new
(
360
,
0
,
@room
.
player2
,
false
)
@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
Card
.
find
(:
方程式同调士
)
Card
.
find
(:
异星的最终战士
)
super
super
end
end
...
@@ -151,11 +154,11 @@ class Scene_Duel < Scene
...
@@ -151,11 +154,11 @@ class Scene_Duel < Scene
super
super
end
end
def
refresh
def
refresh
@fieldback_window
.
card
=
$game
.
player_field
.
field
[
0
]
||
$game
.
opponent_field
.
field
[
0
]
@player_field_window
.
refresh
@player_field_window
.
refresh
@opponent_field_window
.
refresh
@opponent_field_window
.
refresh
@phases_window
.
player
=
$game
.
turn_player
@phases_window
.
player
=
$game
.
turn_player
@phases_window
.
phase
=
$game
.
phase
@phases_window
.
phase
=
$game
.
phase
@fieldback_window
.
card
=
$game
.
player_field
.
field
[
0
]
||
$game
.
opponent_field
.
field
[
0
]
@player_lp_window
.
lp
=
$game
.
player_field
.
lp
@player_lp_window
.
lp
=
$game
.
player_field
.
lp
@opponent_lp_window
.
lp
=
$game
.
opponent_field
.
lp
@opponent_lp_window
.
lp
=
$game
.
opponent_field
.
lp
end
end
...
...
lib/window_field.rb
View file @
89688fc9
...
@@ -89,18 +89,27 @@ class Window_Field < Window
...
@@ -89,18 +89,27 @@ class Window_Field < Window
if
(
6
..
10
).
include?
(
index
)
and
@cards
[
index
].
position
!=
:attack
if
(
6
..
10
).
include?
(
index
)
and
@cards
[
index
].
position
!=
:attack
@contents
.
put
(
@cards
[
index
].
image_horizontal
,
x
,
y
)
@contents
.
put
(
@cards
[
index
].
image_horizontal
,
x
,
y
)
@contents
.
put
(
@border_horizontal
,
x
-
1
,
y
-
1
)
if
status
==
1
@contents
.
put
(
@border_horizontal
,
x
-
1
,
y
-
1
)
if
status
==
1
x
+=
(
Card_Size
[
1
]
-
Card_Size
[
0
])
/
2
y
-=
(
Card_Size
[
1
]
-
Card_Size
[
0
])
/
2
else
else
@contents
.
put
(
@cards
[
index
].
image_small
,
x
,
y
)
@contents
.
put
(
@cards
[
index
].
image_small
,
x
,
y
)
@contents
.
put
(
@border
,
x
-
1
,
y
-
1
)
if
status
==
1
@contents
.
put
(
@border
,
x
-
1
,
y
-
1
)
if
status
==
1
end
end
if
(
6
..
10
).
include?
(
index
)
and
@cards
[
index
].
position
!=
:set
if
(
6
..
10
).
include?
(
index
)
and
@cards
[
index
].
position
!=
:set
spacing
,
height
=
@font
.
text_size
(
'/'
)
spacing
,
height
=
@font
.
text_size
(
'/'
)
x
+=
(
Card_Size
[
0
]
-
spacing
)
/
2
atkdef_x
=
x
+
(
Card_Size
[
0
]
-
spacing
)
/
2
y
+=
Card_Size
[
1
]
-
height
atkdef_y
=
y
+
Card_Size
[
1
]
-
height
@font
.
draw_blended_utf8
(
@contents
,
'/'
,
x
,
y
,
0xFF
,
0xFF
,
0xFF
)
@font
.
draw_blended_utf8
(
@contents
,
'/'
,
atkdef_x
,
atkdef_y
,
0xFF
,
0xFF
,
0xFF
)
@font
.
draw_blended_utf8
(
@contents
,
@cards
[
index
].
atk
.
to_s
,
x
-
@font
.
text_size
(
@cards
[
index
].
atk
.
to_s
)[
0
],
y
,
0xFF
,
0xFF
,
0xFF
)
@font
.
draw_blended_utf8
(
@contents
,
@cards
[
index
].
atk
.
to_s
,
atkdef_x
-
@font
.
text_size
(
@cards
[
index
].
atk
.
to_s
)[
0
],
atkdef_y
,
0xFF
,
0xFF
,
0xFF
)
@font
.
draw_blended_utf8
(
@contents
,
@cards
[
index
].
def
.
to_s
,
x
+
spacing
,
y
,
0xFF
,
0xFF
,
0xFF
)
@font
.
draw_blended_utf8
(
@contents
,
@cards
[
index
].
def
.
to_s
,
atkdef_x
+
spacing
,
atkdef_y
,
0xFF
,
0xFF
,
0xFF
)
end
if
@cards
[
index
].
counters
!=
0
height
||=
@font
.
text_size
(
'/'
)[
1
]
#不太规范,凑合能用
counters_x
=
x
counters_y
=
y
+
Card_Size
[
1
]
-
height
*
2
@font
.
draw_blended_utf8
(
@contents
,
@cards
[
index
].
counters
.
to_s
,
counters_x
,
counters_y
,
0xFF
,
0xFF
,
0xFF
)
end
end
end
end
def
item_rect
(
index
)
def
item_rect
(
index
)
@items
[
index
]
@items
[
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