Skip to content

Commit 0876350

Browse files
committed
Implement Town Greeter's ability
1 parent 515adaf commit 0876350

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

lib/magic/cards/town_greeter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def choices
2525

2626
def resolve!(target:)
2727
trigger_effect(:move_card_zone, from: target.zone, target: target, to: controller.hand)
28+
trigger_effect(:gain_life, life: 2) if target.type?("Town")
2829
end
2930
end
3031
end

spec/cards/town_greeter_spec.rb

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
before do
99
p1.hand.add(card)
1010
2.times { p1.library.add(Card("Island")) }
11-
2.times { p1.library.add(Card)}
11+
2.times { p1.library.add(Card("Adventurer's Inn")) }
1212
end
1313

1414
describe "entering the battlefield" do
@@ -30,8 +30,32 @@
3030
choice.resolve!(target: choice.choices.first)
3131
game.tick!
3232

33-
expect(p1.hand.by_name("Island").count).to eq(1)
33+
expect(p1.hand.by_name("Adventurer's Inn").count).to eq(1)
3434
expect(p1.graveyard.count).to eq(3)
3535
end
36+
37+
it "mills 4, returns a town card to hand" do
38+
p1.add_mana(green: 2)
39+
p1.cast(card: card) do
40+
_1.pay_mana(generic: { green: 1}, green: 1)
41+
end
42+
43+
game.stack.resolve!
44+
game.tick!
45+
46+
expect(p1.graveyard.count).to eq(4)
47+
48+
choice = game.choices.last
49+
expect(choice).to be_a(Magic::Cards::TownGreeter::Choice)
50+
expect(choice.choices.count).to eq(4)
51+
52+
choice.resolve!(target: choice.choices.by_name("Adventurer's Inn").first)
53+
game.tick!
54+
55+
expect(p1.hand.by_name("Adventurer's Inn").count).to eq(1)
56+
expect(p1.graveyard.count).to eq(3)
57+
58+
expect(p1.life).to eq(22)
59+
end
3660
end
3761
end

0 commit comments

Comments
 (0)