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
xiaoye
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
@all
.
clear
#清空缓存
end
end
attr_accessor
:id
attr_accessor
:number
attr_accessor
:name
attr_accessor
:card_type
attr_accessor
:monster_type
attr_accessor
:atk
attr_accessor
:def
attr_accessor
:attribute
attr_accessor
:type
attr_accessor
:level
attr_accessor
:lore
attr_accessor
:status
attr_accessor
:stats
attr_accessor
:archettypes
attr_accessor
:mediums
attr_accessor
:tokens
attr_accessor
:id
attr_accessor
:number
attr_accessor
:name
attr_accessor
:card_type
attr_accessor
:monster_type
attr_accessor
:atk
attr_accessor
:def
attr_accessor
:attribute
attr_accessor
:type
attr_accessor
:level
attr_accessor
:lore
attr_accessor
:status
attr_accessor
:stats
attr_accessor
:archettypes
attr_accessor
:mediums
attr_accessor
:tokens
def
initialize
(
hash
)
@id
=
hash
[
'id'
].
to_i
...
...
@@ -145,17 +145,27 @@ attr_accessor :tokens
@archettypes
=
hash
[
'archettypes'
].
split
(
"
\t
"
).
collect
{
|
archettype
|
stat
.
to_sym
}
@mediums
=
hash
[
'mediums'
].
split
(
"
\t
"
).
collect
{
|
medium
|
medium
.
to_sym
}
@tokens
=
hash
[
'tokens'
]
&&
hash
[
'tokens'
].
split
(
"
\t
"
).
collect
{
|
token
|
token
.
to_i
}
@token
=
hash
[
'token'
]
Card
.
cache
[
@id
]
=
self
end
def
create_image
@image
||=
Surface
.
load
(
"graphics/field/card.jpg"
).
display_format
end
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
def
image_small
@image_small
||=
image
.
transform_surface
(
0xFF000000
,
0
,
54.0
/
image
.
w
,
81.0
/
image
.
h
,
Surface
::
TRANSFORM_SAFE
)
end
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
def
unknown?
@id
==
1
...
...
@@ -169,6 +179,12 @@ attr_accessor :tokens
def
spell?
[:
通常魔法
,
:
速攻魔法
,
:
装备魔法
,
:
场地魔法
,
:
仪式魔法
,
:
永续魔法
].
include?
card_type
end
def
extra?
[:
融合怪兽
,
:
同调怪兽
,
:
超量怪兽
].
include?
card_type
end
def
token?
@token
end
def
inspect
"[
#{
card_type
}
][
#{
name
}
]"
end
...
...
lib/game_card.rb
View file @
89688fc9
#encoding: UTF-8
class
Game_Card
attr_accessor
:card
,
:position
#attack|defense|set,
attr_
accesso
r
:atk
,
:def
attr_accessor
:card
,
:position
,
:counters
attr_
write
r
:atk
,
:def
@@count
=
0
def
initialize
(
card
=
nil
)
@@count
+=
1
...
...
@@ -13,16 +13,19 @@ class Game_Card
@card
.
atk
.
to_i
#把"?"转为0
end
def
def
@card
.
atk
.
to_i
#把"?"转为0
@card
.
def
.
to_i
#把"?"转为0
end
def
reset
(
reset_position
=
true
)
@position
=
:set
if
reset_position
@atk
=
@card
.
atk
@def
=
@card
.
def
@counters
=
0
end
def
card
=
(
card
)
return
if
@card
==
card
@card
=
card
reset
(
false
)
@atk
=
@card
.
atk
@def
=
@card
.
def
end
def
known?
@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
class
Replay
Delimiter
=
/^.+?\(\d+\)(?:\(\d+:\d+:\d+\))?(?:: |:)\n ?/
Player_Filter
=
/^(.+?)\((\d+)\)(?:\(\d+:\d+:\d+\))?(?:: |:)\n ?\[\d+\] ◎→/
Opponent_Filter
=
/^(.+?)\((\d+)\)(?:\(\d+:\d+:\d+\))?(?:: |:)\n ?\[\d+\] ●→/
User_Filter
=
/(.+?)\((\d+)\)(?:\(\d+:\d+:\d+\))?(?::|:) */
Delimiter
=
/^
#{
User_Filter
}
\n ?/
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
def
add
(
action
)
# user = action.from_player ? $game.player1 : $game.player2
...
...
@@ -13,26 +16,55 @@ class Replay
file
=
open
(
filename
)
file
.
set_encoding
"GBK"
,
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
result
=
self
.
new
(
file
)
contents
=
file
.
read
if
contents
=~
Player_Filter
result
.
player1
=
User
.
new
(
$2
.
to_i
,
$1
)
contents
=
file
.
read
.
strip
if
contents
[
0
,
7
]
==
"<table>"
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
result
.
player1
=
User
.
new
(
0
,
"我"
)
end
if
contents
=~
Opponent_Filter
result
.
player2
=
User
.
new
(
$2
.
to_i
,
$1
)
result
.
player1
=
User
.
new
(
$2
.
to_i
,
$1
)
if
contents
=~
Player_Filter
result
.
player2
=
User
.
new
(
$2
.
to_i
,
$1
)
if
contents
=~
Opponent_Filter
from_players
=
contents
.
scan
(
Delimiter
).
collect
do
|
matched
|
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
result
.
player2
=
User
.
new
(
1
,
"对手"
)
#无法匹配玩家,一般是观战消息..
false
end
end
end
result
.
actions
=
contents
.
split
(
Delimiter
).
collect
do
|
action_str
|
action_str
.
strip!
next
if
action_str
.
empty?
result
.
player1
||=
User
.
new
(
0
,
"我"
)
result
.
player2
||=
User
.
new
(
1
,
"对手"
)
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
.
from_player
=
from_players
.
next
Game_Event
::
Action
.
new
(
action
,
action_str
)
end
.
compact
end
$game
.
room
=
result
.
room
=
Room
.
new
(
0
,
"Replay"
,
result
.
player1
,
result
.
player2
)
result
end
def
self
.
html_decode
(
text
)
text
.
gsub
(
Regexp
.
new
(
HTML_Replacement
.
keys
.
collect
{
|
key
|
Regexp
.
escape
key
}.
join
(
'|'
)),
HTML_Replacement
)
end
def
get
@actions
.
shift
end
...
...
lib/scene_duel.rb
View file @
89688fc9
...
...
@@ -39,13 +39,16 @@ class Scene_Duel < Scene
@fieldback_window
=
Window_FieldBack
.
new
(
130
,
174
)
@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
)
@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
)
create_action_window
Card
.
find
(:
方程式同调士
)
Card
.
find
(:
异星的最终战士
)
super
end
...
...
@@ -151,11 +154,11 @@ class Scene_Duel < Scene
super
end
def
refresh
@fieldback_window
.
card
=
$game
.
player_field
.
field
[
0
]
||
$game
.
opponent_field
.
field
[
0
]
@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
]
@player_lp_window
.
lp
=
$game
.
player_field
.
lp
@opponent_lp_window
.
lp
=
$game
.
opponent_field
.
lp
end
...
...
lib/window_field.rb
View file @
89688fc9
...
...
@@ -89,18 +89,27 @@ class Window_Field < Window
if
(
6
..
10
).
include?
(
index
)
and
@cards
[
index
].
position
!=
:attack
@contents
.
put
(
@cards
[
index
].
image_horizontal
,
x
,
y
)
@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
@contents
.
put
(
@cards
[
index
].
image_small
,
x
,
y
)
@contents
.
put
(
@border
,
x
-
1
,
y
-
1
)
if
status
==
1
end
if
(
6
..
10
).
include?
(
index
)
and
@cards
[
index
].
position
!=
:set
spacing
,
height
=
@font
.
text_size
(
'/'
)
x
+=
(
Card_Size
[
0
]
-
spacing
)
/
2
y
+=
Card_Size
[
1
]
-
height
@font
.
draw_blended_utf8
(
@contents
,
'/'
,
x
,
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
].
def
.
to_s
,
x
+
spacing
,
y
,
0xFF
,
0xFF
,
0xFF
)
atkdef_x
=
x
+
(
Card_Size
[
0
]
-
spacing
)
/
2
atkdef_y
=
y
+
Card_Size
[
1
]
-
height
@font
.
draw_blended_utf8
(
@contents
,
'/'
,
atkdef_x
,
atkdef_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
,
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
def
item_rect
(
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