Skip to content

Commit

Permalink
Add Life Goes On
Browse files Browse the repository at this point in the history
Fixes #202
  • Loading branch information
radar committed Apr 11, 2024
1 parent 6b1e86b commit fae564c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/magic/cards/life_goes_on.rb
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
35 changes: 35 additions & 0 deletions spec/cards/life_goes_on_spec.rb
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

0 comments on commit fae564c

Please sign in to comment.