Commit 83cdb5a8 authored by 神楽坂玲奈's avatar 神楽坂玲奈

卡片操作

parent 2719711f
......@@ -88,6 +88,7 @@ class Action
@position = position
end
def run
p 1
from_field = case @from_pos
when Integer
player_field.field
......@@ -151,9 +152,21 @@ class Action
super(from_player, from_pos, to_pos, card, nil, :set)
end
end
class Activate < Move; end
class Summon < Move; end
class SpecialSummon < Move; end
class Activate < Move
def initialize(from_player, from_pos, to_pos, card)
super(from_player, from_pos, to_pos, card, nil, :attack)
end
end
class Summon < Move
def initialize(from_player, from_pos, to_pos, card)
super(from_player, from_pos, to_pos, card, nil, :attack)
end
end
class SpecialSummon < Move
def initialize(from_player, from_pos, to_pos, card, position=:attack)
super(from_player, from_pos, to_pos, card, nil, position)
end
end
class SendToGraveyard < Move
def initialize(from_player, from_pos, card)
super(from_player, from_pos, card, :graveyard)
......
......@@ -159,4 +159,10 @@ attr_accessor :tokens
def monster?
!@attribute.nil?
end
def trap?
[:通常陷阱, :反击陷阱, :永续陷阱].include? card_type
end
def spell?
[:通常魔法, :速攻魔法, :装备魔法, :场地魔法, :仪式魔法, :永续魔法].include? card_type
end
end
\ No newline at end of file
......@@ -38,4 +38,25 @@ class Game_Field
@graveyard = []
@removed = []
end
def empty_monster_field
[8,7,9,6,10].each do |pos|
return pos if @field[pos].nil?
end
return
end
def empty_spelltrap_field
[3,2,4,1,5].each do |pos|
return pos if @field[pos].nil?
end
return
end
def empty_field(card)
if card.monster?
empty_monster_field
elsif card.card_type == :场地魔法
@field[0].nil? ? 0 : nil
else
empty_spelltrap_field
end
end
end
\ No newline at end of file
......@@ -62,6 +62,9 @@ class Iduel
end
def action(action)
send(2, "#{checknum("RMSG", @session)}@#{@key}", "#{action.escape}▊▊▊000000") #TODO:iduel校验字串
end
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
......
......@@ -232,6 +232,26 @@ class Action
"[#{@id}] ◎→卡组洗切"
end
end
class Set
def escape
"[#{@id}] ◎→从手卡~取一张#{@card.monster? ? "怪兽卡" : "魔/陷卡"}盖到场上(#{@to_pos})"
end
end
class Summon
def escape
"[#{@id}] ◎→从手卡~召唤#{@card.escape}(#{@to_pos})"
end
end
class SpecialSummon
def escape
"[#{@id}] ◎→从手卡~特殊召唤#{@card.escape}(#{@to_pos})呈守备表示"
end
end
class Activate
def escape
"[#{@id}] ◎→从手卡~发动#{@card.escape}(#{@to_pos})"
end
end
end
......
......@@ -17,7 +17,7 @@ class Scene_Duel < Scene
attr_reader :cardinfo_window
attr_reader :action_window
attr_reader :player_field_window
def initialize(room)
super()
@room = room
......@@ -122,12 +122,15 @@ class Scene_Duel < Scene
case event.sym
when Key::F1
Action::Shuffle.new.run
@player_field_window.refresh
when Key::F2
first_to_go
@player_field_window.refresh
when Key::F3
Action::Dice.new(true).run
when Key::F5
reset
@player_field_window.refresh
end
else
super
......
......@@ -55,6 +55,9 @@ class Window_Action < Window_List
def mousemoved(x,y)
self.index = (y - @y) / WLH
end
def clicked
$scene.player_field_window.clicked
end
def lostfocus
end
end
\ No newline at end of file
......@@ -147,10 +147,10 @@ class Window_Field < Window
}
when Integer #手卡
@index_card = @field.hand[@index-11]
@action_names = {"放置到场上" => true,
"召唤" => @index_card.monster?,
"发动" => !@index_card.monster?,
"特殊召唤" => true,
@action_names = {"召唤" => @index_card.monster?,
"特殊召唤" => false,
"发动" => @index_card.spell?,
"放置到场上" => true,
"放回卡组顶端" => true,
"送入墓地" => true,
"从游戏中除外" => true,
......@@ -197,10 +197,34 @@ class Window_Field < Window
#场上
when Integer #手卡
case $scene.action_window.index
when 0
Action::Set.new(true, :hand, 6, @index_card)
when 0 #召唤
if pos = @field.empty_field(@index_card)
Action::Summon.new(true, :hand, pos, @index_card).run
else
p "场位已满"
end
when 1 #特殊召唤
if pos = @field.empty_field(@index_card)
Action::SpecialSummon.new(true, :hand, pos, @index_card, :attack).run
else
p "场位已满"
end
when 2 #发动
if pos = @field.empty_field(@index_card)
Action::Activate.new(true, :hand, pos, @index_card).run
else
p "场位已满"
end
when 3 #放置
if pos = @field.empty_field(@index_card)
Action::Set.new(true, :hand, pos, @index_card).run
else
p "场位已满"
end
end
end
@index = nil
refresh
mousemoved(Mouse.state[0], Mouse.state[1])
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment