Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lib/magic/cards/invigorating_surge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Magic
module Cards
InvigoratingSurge = Instant("Invigorating Surge") do
cost generic: 1, green: 1
end

class InvigoratingSurge < Instant
def single_target?
true
end

def target_choices
controller.creatures
end

def resolve!(target:)
trigger_effect(:add_counter, counter_type: "+1/+1", target: target)
existing = target.counters.of_type(Magic::Counters::Plus1Plus1).count
trigger_effect(:add_counter, counter_type: "+1/+1", target: target, amount: existing)
end
end
end
end
42 changes: 42 additions & 0 deletions spec/cards/invigorating_surge_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true
require "spec_helper"

RSpec.describe Magic::Cards::InvigoratingSurge do
include_context "two player game"

let(:card) { Card("Invigorating Surge") }

context "targeting a creature with no +1/+1 counters" do
let!(:wood_elves) { ResolvePermanent("Wood Elves", owner: p1) }

it "puts one +1/+1 counter, then doubles to two" do
cast_and_resolve(card: card, player: p1, targeting: wood_elves)

expect(wood_elves.counters.of_type(Magic::Counters::Plus1Plus1).count).to eq(2)
end
end

context "targeting a creature with two +1/+1 counters" do
let!(:wood_elves) { ResolvePermanent("Wood Elves", owner: p1) }

before do
wood_elves.add_counter("+1/+1", amount: 2)
end

it "adds one to make three, then doubles to six" do
cast_and_resolve(card: card, player: p1, targeting: wood_elves)

expect(wood_elves.counters.of_type(Magic::Counters::Plus1Plus1).count).to eq(6)
end
end

context "target choices" do
let!(:my_wood_elves) { ResolvePermanent("Wood Elves", owner: p1) }
let!(:opponents_wood_elves) { ResolvePermanent("Wood Elves", owner: p2) }

it "only targets creatures controlled by the caster" do
expect(card.target_choices).to include(my_wood_elves)
expect(card.target_choices).not_to include(opponents_wood_elves)
end
end
end
Loading