-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #478
- Loading branch information
Showing
12 changed files
with
113 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Magic | ||
module Cards | ||
PrimalMight = Sorcery("Primal Might") do | ||
cost green: 1, x: 1 | ||
|
||
def multi_target? = true | ||
|
||
def target_choices | ||
[ | ||
battlefield.creatures.controlled_by(controller), | ||
battlefield.creatures.not_controlled_by(controller), | ||
] | ||
end | ||
|
||
def resolve!(targets:, value_for_x:) | ||
first_creature, second_creature = targets | ||
|
||
first_creature.modify_power_toughness!(power: value_for_x, toughness: value_for_x) | ||
first_creature.fight(second_creature) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ class Effect | |
def initialize(player) | ||
@player = player | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
module Magic | ||
module Costs | ||
class Discard | ||
def initialize(player) | ||
attr_reader :player, :predicate | ||
def initialize(player, predicate = nil) | ||
@player = player | ||
@predicate = predicate || -> (c) { true } | ||
end | ||
|
||
def can_pay? | ||
player.hand.count > 0 | ||
end | ||
|
||
def pay(player, discarded_card) | ||
player.hand.discard(discarded_card) | ||
def pay(player, chosen_card) | ||
raise "Invalid target chosen for discard" unless valid_targets.include?(chosen_card) | ||
player.hand.discard(chosen_card) | ||
end | ||
|
||
def finalize!(_player) | ||
end | ||
|
||
def valid_targets | ||
player.hand.select(&predicate) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Magic::Cards::PrimalMight do | ||
include_context "two player game" | ||
|
||
let!(:wood_elves) { ResolvePermanent("Wood Elves", owner: p1) } | ||
let!(:alpine_watchdog) { ResolvePermanent("Alpine Watchdog", owner: p2) } | ||
|
||
let(:primal_might) { Card("Primal Might") } | ||
|
||
it "wood elves get +3/+3, fight alpine watchdog" do | ||
p1.add_mana(green: 4) | ||
p1.cast(card: primal_might, value_for_x: 3) do | ||
_1.targeting(wood_elves, alpine_watchdog) | ||
_1.pay_mana(green: 1, x: { green: 3 }) | ||
end | ||
game.tick! | ||
|
||
expect(wood_elves.power).to eq(4) | ||
expect(alpine_watchdog.damage).to eq(4) | ||
end | ||
end |