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
fbff5c91
Commit
fbff5c91
authored
Jan 14, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量卡片操作初步
parent
0e2b5e19
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
124 additions
and
27 deletions
+124
-27
1.txt
1.txt
+0
-1
lib/action.rb
lib/action.rb
+93
-10
lib/card.rb
lib/card.rb
+5
-2
lib/game_card.rb
lib/game_card.rb
+3
-0
lib/iduel/action.rb
lib/iduel/action.rb
+4
-1
lib/window_field.rb
lib/window_field.rb
+18
-13
lib/window_title.rb
lib/window_title.rb
+1
-0
No files found.
1.txt
deleted
100644 → 0
View file @
0e2b5e19
通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 - bind(2)
\ No newline at end of file
lib/action.rb
View file @
fbff5c91
...
...
@@ -84,6 +84,8 @@ class Action
@position
=
position
end
def
run
puts
'-----------------------------------'
p
self
from_field
=
case
@from_pos
when
0
..
10
player_field
.
field
...
...
@@ -99,10 +101,7 @@ class Action
player_field
.
extra
when
:removed
player_field
.
removed
else
$log
.
warn
__FILE__
,
'奇怪的from_field'
end
from_pos
=
if
@from_pos
.
is_a?
Integer
if
@from_pos
>
10
@from_pos
-
11
...
...
@@ -110,10 +109,12 @@ class Action
@from_pos
end
elsif
@card
==
:deck
0
player_field
.
deck
.
size
-
1
else
(
@card
.
is_a?
(
Game_Card
)
?
from_field
.
index
(
@card
)
:
from_field
.
index
{
|
card
|
card
.
card
==
@card
})
||
from_field
.
index
{
|
card
|!
card
.
known?
}
end
# p from_pos, from_field
# p from_field[from_pos] if from_pos
to_field
=
case
@to_pos
when
Integer
player_field
.
field
...
...
@@ -138,7 +139,7 @@ class Action
from_field
[
from_pos
].
card
=
@card
from_field
[
from_pos
]
when
:deck
player_field
.
deck
.
fir
st
player_field
.
deck
.
la
st
end
if
@to_pos
if
from_field
==
player_field
.
field
...
...
@@ -165,7 +166,7 @@ class Action
if
@to_pos
if
@to_pos
.
is_a?
Integer
to_field
[
@to_pos
]
=
card
elsif
@to_pos
==
:hand
or
@to_pos
==
:deck
bottom
elsif
@to_pos
==
:hand
or
@to_pos
==
:deck
to_field
<<
card
else
to_field
.
unshift
card
...
...
@@ -251,6 +252,9 @@ class Action
@from_player
=
from_player
super
(
from_player
,
:deck
,
:hand
,
:deck
,
msg
,
:set
)
end
end
class
Counter
<
Action
end
class
MultiDraw
<
Action
def
initialize
(
from_player
,
count
,
msg
=
nil
)
...
...
@@ -259,7 +263,85 @@ class Action
end
def
run
super
player_field
.
hand
+=
player_field
.
deck
.
shift
(
@count
)
player_field
.
hand
+=
player_field
.
deck
.
pop
(
@count
)
end
end
class
AllMonstersSendToGraveyard
<
SendToGraveyard
def
initialize
(
from_player
,
cards
)
@from_player
=
from_player
@cards
=
cards
end
def
run
@cards
=
if
@cards
@cards
.
collect
do
|
card
|
if
card
.
is_a?
Game_Card
card
else
index
=
player_field
.
field
[
6
..
10
].
index
{
|
fieldcard
|
fieldcard
and
fieldcard
.
card
==
card
}
||
player_field
.
field
[
6
..
10
].
index
{
|
fieldcard
|
fieldcard
and
!
fieldcard
.
known?
}
if
index
index
+=
6
card
=
player_field
.
field
[
index
]
player_field
.
field
[
index
]
=
nil
card
else
Game_Card
.
new
(
@card
)
$log
.
warn
'似乎凭空产生了卡片'
end
end
end
else
player_field
.
field
[
6
..
10
].
compact
end
player_field
.
field
[
6
..
10
]
=
nil
player_field
.
graveyard
+=
@cards
end
end
class
AllMonstersRemove
<
Remove
def
initialize
(
from_player
,
cards
)
@from_player
=
from_player
@cards
=
cards
end
def
run
@cards
||=
player_field
.
field
[
6
..
10
].
compact
player_field
.
field
[
6
..
10
]
=
nil
player_field
.
removed
+=
@cards
end
end
class
AllMonstersReturnToDeck
<
ReturnToDeck
def
initialize
(
from_player
,
cards
)
@from_player
=
from_player
@cards
=
cards
end
def
run
@cards
||=
player_field
.
field
[
6
..
10
].
compact
player_field
.
field
[
6
..
10
]
=
nil
player_field
.
deck
+=
@cards
end
end
class
AllMonstersReturnToHand
<
ReturnToHand
def
initialize
(
from_player
,
cards
)
@from_player
=
from_player
@cards
=
cards
end
def
run
@cards
||=
player_field
.
field
[
6
..
10
].
compact
player_field
.
field
[
6
..
10
]
=
nil
player_field
.
hand
+=
@cards
end
end
class
AllMonstersCounter
<
Counter
def
initialize
(
from_player
)
@from_player
=
from_player
end
def
run
player_field
.
field
[
6
..
10
].
each_with_index
do
|
card
,
index
|
if
card
player_field
.
removed
<<
card
player_field
.
field
[
index
+
6
]
=
nil
end
end
end
end
class
RefreshField
<
Action
...
...
@@ -327,14 +409,15 @@ class Action
end
end
class
EffectActivate
<
Move
def
initialize
(
from_player
,
from_pos
,
card
)
@from_player
=
from_player
def
initialize
(
from_player
,
from_pos
,
card
,
target_pos
=
nil
,
target_player
=
nil
)
if
(
0
..
10
).
include?
(
from_pos
)
position
=
:"face-up"
else
position
=
nil
end
super
(
from_player
,
from_pos
,
nil
,
card
,
nil
,
position
)
super
(
from_player
,
from_pos
,
to_pos
,
card
,
nil
,
position
)
@target_pos
=
target_pos
@target_player
=
target_player
end
end
class
ViewDeck
<
Action
;
end
...
...
lib/card.rb
View file @
fbff5c91
...
...
@@ -152,10 +152,10 @@ attr_accessor :tokens
@image
||=
Surface
.
load
"
#{
PicPath
}
/
#{
@id
-
1
}
.jpg"
rescue
Surface
.
load
"graphics/field/card.jpg"
end
def
image_small
@image_small
||=
image
.
transform_surface
(
0xFF000000
,
0
,
54.0
/
image
.
w
,
81.0
/
image
.
h
,
0
)
@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
,
0
)
@image_horizontal
||=
image_small
.
transform_surface
(
0xFF000000
,
90
,
1
,
1
,
Surface
::
TRANSFORM_SAFE
)
end
def
unknown?
@id
==
1
...
...
@@ -169,6 +169,9 @@ attr_accessor :tokens
def
spell?
[:
通常魔法
,
:
速攻魔法
,
:
装备魔法
,
:
场地魔法
,
:
仪式魔法
,
:
永续魔法
].
include?
card_type
end
def
inspect
"[
#{
card_type
}
][
#{
name
}
]"
end
Unknown
=
Card
.
new
(
'id'
=>
0
,
'number'
=>
:"00000000"
,
'name'
=>
""
,
'lore'
=>
''
,
'card_type'
=>
:
通常怪兽
,
'stats'
=>
""
,
'archettypes'
=>
""
,
'mediums'
=>
""
)
Unknown
.
instance_eval
{
@image
=
CardBack
;
@image_small
=
CardBack_Small
}
end
\ No newline at end of file
lib/game_card.rb
View file @
fbff5c91
...
...
@@ -47,4 +47,7 @@ class Game_Card
end
@card
.
send
(
method
,
*
args
)
end
def
inspect
"<
#{
object_id
}#{
known?
?
@card
.
inspect
:
'??'
}
>"
end
end
\ No newline at end of file
lib/iduel/action.rb
View file @
fbff5c91
#encoding: UTF-8
#这个文件iduel和nbx相同,编辑时推荐使用软/硬链接来保持一致
class
Action
CardFilter
=
/((?:<)?(?:\[.*?\])?\[(?:.*?)\]
[\s\d]*
(?:>)?|一张怪兽卡|一张魔\/陷卡|\?\?)/
CardFilter
=
/((?:<)?(?:\[.*?\])?\[(?:.*?)\]
.*?
(?:>)?|一张怪兽卡|一张魔\/陷卡|\?\?)/
PosFilter
=
/((?:手卡|手牌|场上|魔陷区|怪兽区|墓地|额外牌堆|除外区|卡组|卡组顶端|\(\d+\)){1,2})/
PositionFilter
=
/(表攻|表守|里守|攻击表示|防守表示|里侧表示|背面守备表示)/
PhaseFilter
=
/(抽卡`阶段|准备`阶段|主`阶段1|战斗`阶段|主`阶段2|结束`阶段)/
...
...
@@ -260,6 +260,9 @@ class Action
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
/己方场上所有怪兽卡\|(~
#{
CardFilter
}
)*~全部送往墓地/
cards
=
$&
.
scan
(
CardFilter
).
collect
{
|
matched
|
parse_card
matched
.
first
}
AllMonstersSendToGraveyard
.
new
(
from_player
,
cards
)
when
/
#{
PhaseFilter
}
/
ChangePhase
.
new
(
from_player
,
parse_phase
(
$1
))
when
/LP(损失|回复|变成)<(-?\d+)>/
...
...
lib/window_field.rb
View file @
fbff5c91
...
...
@@ -36,7 +36,7 @@ class Window_Field < Window
@cards
.
clear
if
!
@field
.
deck
.
empty?
@items
[
:deck
]
=
Deck_Pos
+
Card_Size
@cards
[
:deck
]
=
@field
.
deck
.
fir
st
@cards
[
:deck
]
=
@field
.
deck
.
la
st
end
if
!
@field
.
extra
.
empty?
@items
[
:extra
]
=
Extra_Pos
+
Card_Size
...
...
@@ -70,31 +70,36 @@ class Window_Field < Window
end
if
!
@player
#对手的情况,把卡片位置翻转
@items
.
each_pair
do
|
key
,
value
|
value
[
0
]
=
@width
-
value
[
0
]
-
Card_Size
[
0
]
value
[
1
]
=
@height
-
value
[
1
]
-
Card_Size
[
1
]
if
(
6
..
10
).
include?
(
key
)
and
@cards
[
key
].
position
!=
:attack
value
[
0
]
=
@width
-
value
[
0
]
-
Card_Size
[
1
]
value
[
1
]
=
@height
-
value
[
1
]
-
Card_Size
[
0
]
else
value
[
0
]
=
@width
-
value
[
0
]
-
Card_Size
[
0
]
value
[
1
]
=
@height
-
value
[
1
]
-
Card_Size
[
1
]
end
@items
[
key
]
=
value
end
end
clear
@items
.
each_key
{
|
index
|
draw_item
(
index
)}
@items
.
each_key
{
|
index
|
draw_item
(
index
,
@index
==
index
?
1
:
0
)}
refresh_action_window
end
def
draw_item
(
index
,
status
=
0
)
x
,
y
=
item_rect
(
index
)
if
(
6
..
10
).
include?
(
index
)
and
@cards
[
index
].
position
!=
:attack
@contents
.
put
(
@cards
[
index
].
image_horizontal
,
item_rect
(
index
)[
0
],
item_rect
(
index
)[
1
]
)
@contents
.
put
(
@border_horizontal
,
item_rect
(
index
)[
0
]
-
1
,
item_rect
(
index
)[
1
]
-
1
)
if
status
==
1
@contents
.
put
(
@cards
[
index
].
image_horizontal
,
x
,
y
)
@contents
.
put
(
@border_horizontal
,
x
-
1
,
y
-
1
)
if
status
==
1
else
@contents
.
put
(
@cards
[
index
].
image_small
,
item_rect
(
index
)[
0
],
item_rect
(
index
)[
1
]
)
@contents
.
put
(
@border
,
item_rect
(
index
)[
0
]
-
1
,
item_rect
(
index
)[
1
]
-
1
)
if
status
==
1
@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
size
=
@font
.
text_size
(
'/'
)
y
=
Field_Pos
[
index
][
1
]
+
Card_Size
[
1
]
-
size
[
1
]
size
=
size
[
0
]
x
=
Field_Pos
[
index
][
0
]
+
(
Card_Size
[
0
]
-
size
)
/
2
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
+
s
ize
,
y
,
0xFF
,
0xFF
,
0xFF
)
@font
.
draw_blended_utf8
(
@contents
,
@cards
[
index
].
def
.
to_s
,
x
+
s
pacing
,
y
,
0xFF
,
0xFF
,
0xFF
)
end
end
def
item_rect
(
index
)
...
...
lib/window_title.rb
View file @
fbff5c91
#encoding: UTF-8
require_relative
'window_list'
class
Window_Title
<
Window_List
Button_Count
=
5
...
...
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