-
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.
- Loading branch information
Showing
4 changed files
with
127 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module Magic | ||
module Cards | ||
ComposerOfSpring = Creature("Composer of Spring") do | ||
cost "{1}{G}" | ||
creature_type "Satyr Bard" | ||
power 2 | ||
toughness 3 | ||
end | ||
|
||
class ComposerOfSpring < Creature | ||
class EntersTrigger < TriggeredAbility::EnterTheBattlefield | ||
def should_perform? | ||
enchantment? && under_your_control? | ||
end | ||
|
||
|
||
def call | ||
choice = if battlefield.controlled_by(controller).enchantments.count > 6 | ||
LandOrCreatureChoice | ||
else | ||
LandChoice | ||
end | ||
|
||
game.add_choice(choice.new(actor: actor)) | ||
end | ||
end | ||
|
||
class LandChoice < Magic::Choice::May | ||
def choices | ||
controller.hand.lands | ||
end | ||
|
||
def resolve!(target:) | ||
target.resolve!(enters_tapped: true) | ||
end | ||
end | ||
|
||
class LandOrCreatureChoice < Magic::Choice::May | ||
def choices | ||
controller.hand.lands + controller.hand.creatures | ||
end | ||
|
||
def resolve!(target:) | ||
target.resolve!(enters_tapped: true) | ||
end | ||
end | ||
|
||
def event_handlers | ||
{ | ||
Events::EnteredTheBattlefield => EntersTrigger | ||
} | ||
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 |
---|---|---|
|
@@ -51,5 +51,9 @@ def battlefield? | |
def exile? | ||
false | ||
end | ||
|
||
def lands | ||
cards.lands | ||
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Magic::Cards::ComposerOfSpring do | ||
include_context "two player game" | ||
|
||
subject { ResolvePermanent("Composer of Spring") } | ||
|
||
context "when an enchantment enters under your control" do | ||
it "may put a land from your hand into play tapped" do | ||
subject | ||
|
||
p1.add_mana(white: 3) | ||
p1.cast(card: Card("Nine Lives")) do | ||
_1.pay_mana(generic: { white: 1 }, white: 2) | ||
end | ||
|
||
game.tick! | ||
|
||
expect(game.choices.last).to be_a(Magic::Cards::ComposerOfSpring::LandChoice) | ||
expect(game.choices.last.choices).to eq(p1.hand.lands) | ||
|
||
chosen_land = p1.hand.lands.first | ||
|
||
game.resolve_choice!(target: chosen_land) | ||
|
||
game.tick! | ||
|
||
expect(game.battlefield.by_name("Forest").count).to eq(1) | ||
end | ||
|
||
context "when there are 6 or more enchantments" do | ||
before do | ||
6.times { ResolvePermanent("Nine Lives", owner: p1) } | ||
|
||
p1.hand.add(Card("Wood Elves")) | ||
end | ||
|
||
it "may put a land or creature from your hand into play tapped" do | ||
subject | ||
|
||
p1.add_mana(white: 3) | ||
p1.cast(card: Card("Nine Lives")) do | ||
_1.pay_mana(generic: { white: 1 }, white: 2) | ||
end | ||
|
||
game.tick! | ||
|
||
expect(game.choices.last).to be_a(Magic::Cards::ComposerOfSpring::LandOrCreatureChoice) | ||
expect(game.choices.last.choices).to eq(p1.hand.lands + p1.hand.creatures) | ||
|
||
chosen_creature = p1.hand.creatures.first | ||
|
||
game.resolve_choice!(target: chosen_creature) | ||
|
||
game.tick! | ||
|
||
expect(game.battlefield.by_name(chosen_creature.name).count).to eq(1) | ||
end | ||
|
||
|
||
end | ||
end | ||
end |