-
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 #202
- Loading branch information
Showing
2 changed files
with
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Magic | ||
module Cards | ||
class LifeGoesOn < Instant | ||
card_name "Life Goes On" | ||
cost "{G}" | ||
|
||
def resolve! | ||
creature_died = current_turn.events.count { |event| event.is_a?(Events::CreatureDied) } > 0 | ||
life_gain = 4 | ||
life_gain += 4 if creature_died | ||
|
||
trigger_effect(:gain_life, life: life_gain) | ||
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Magic::Cards::LifeGoesOn do | ||
include_context "two player game" | ||
let(:life_goes_on) { Card("Life Goes On") } | ||
context "when no creature died" do | ||
it "player gains 4 life" do | ||
p1.add_mana(green: 1) | ||
p1.cast(card: life_goes_on) do | ||
_1.pay_mana(green: 1) | ||
end | ||
|
||
game.tick! | ||
expect(p1.life).to eq(24) | ||
end | ||
end | ||
|
||
context "when a creature died" do | ||
let(:creature) { ResolvePermanent("Wood Elves") } | ||
|
||
before do | ||
creature.sacrifice! | ||
end | ||
|
||
it "player gains 8 life" do | ||
p1.add_mana(green: 1) | ||
p1.cast(card: life_goes_on) do | ||
_1.pay_mana(green: 1) | ||
end | ||
|
||
game.tick! | ||
expect(p1.life).to eq(28) | ||
end | ||
end | ||
end |