-
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 #206
- Loading branch information
Showing
9 changed files
with
145 additions
and
7 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
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,53 @@ | ||
module Magic | ||
module Cards | ||
class Pridemalkin < Creature | ||
card_name "Pridemalkin" | ||
cost "{2}{G}" | ||
type "Creature -- Cat" | ||
power 2 | ||
toughness 1 | ||
|
||
class Choice < Magic::Choice | ||
def choices | ||
Magic::Targets::Choices.new( | ||
choices: game.battlefield.by_any_type(T::Creature).controlled_by(owner), | ||
amount: 1 | ||
) | ||
end | ||
|
||
def resolve!(target:) | ||
actor.trigger_effect( | ||
:add_counter, | ||
source: actor, | ||
target: target, | ||
counter_type: Counters::Plus1Plus1 | ||
) | ||
end | ||
end | ||
|
||
enters_the_battlefield do | ||
game.choices.add(Choice.new(actor: actor)) | ||
end | ||
|
||
class TrampleAddition < StaticAbility | ||
def initialize(source:) | ||
@source = source | ||
end | ||
|
||
def keywords | ||
[Cards::Keywords::TRAMPLE] | ||
end | ||
|
||
def applies_to?(permanent) | ||
permanent.counters.of_type(Magic::Counters::Plus1Plus1).any? | ||
end | ||
|
||
def applicable_targets | ||
source.controller.creatures | ||
end | ||
end | ||
|
||
def static_abilities = [TrampleAddition] | ||
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
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
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,15 @@ | ||
module Magic | ||
class StaticAbility | ||
def power | ||
0 | ||
end | ||
|
||
def toughness | ||
0 | ||
end | ||
|
||
def keywords | ||
[] | ||
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,65 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Magic::Cards::Pridemalkin do | ||
include_context "two player game" | ||
|
||
let(:pridemalkin) { Card("Pridemalkin") } | ||
|
||
context "when pridemalkin is the only creature" do | ||
it "adds the counter to itself" do | ||
p1.add_mana(green: 3) | ||
p1.cast(card: pridemalkin) do | ||
_1.pay_mana(generic: { green: 2 }, green: 1) | ||
end | ||
|
||
game.tick! | ||
permanent = creatures.by_name("Pridemalkin").first | ||
game.resolve_choice!(target: permanent) | ||
|
||
aggregate_failures do | ||
expect(permanent.power).to eq(3) | ||
expect(permanent.toughness).to eq(2) | ||
expect(permanent.counters.of_type(Magic::Counters::Plus1Plus1).count).to eq(1) | ||
expect(permanent.has_keyword?(:trample)).to eq(true) | ||
end | ||
end | ||
end | ||
|
||
context "when there is another creature" do | ||
let!(:wood_elves) { ResolvePermanent("Wood Elves") } | ||
|
||
it "adds the counter to wood elves" do | ||
p1.add_mana(green: 3) | ||
p1.cast(card: pridemalkin) do | ||
_1.pay_mana(generic: { green: 2 }, green: 1) | ||
end | ||
|
||
game.tick! | ||
game.resolve_choice!(target: wood_elves) | ||
|
||
aggregate_failures do | ||
expect(wood_elves.power).to eq(2) | ||
expect(wood_elves.toughness).to eq(2) | ||
expect(wood_elves.counters.of_type(Magic::Counters::Plus1Plus1).count).to eq(1) | ||
expect(wood_elves.has_keyword?(:trample)).to eq(true) | ||
end | ||
end | ||
|
||
it "adds the counter to pridemalkin, wood elves doesn't get trample" do | ||
p1.add_mana(green: 3) | ||
p1.cast(card: pridemalkin) do | ||
_1.pay_mana(generic: { green: 2 }, green: 1) | ||
end | ||
|
||
game.tick! | ||
permanent = creatures.by_name("Pridemalkin").first | ||
game.resolve_choice!(target: permanent) | ||
|
||
aggregate_failures do | ||
expect(wood_elves.power).to eq(1) | ||
expect(wood_elves.toughness).to eq(1) | ||
expect(wood_elves.has_keyword?(:trample)).to eq(false) | ||
end | ||
end | ||
end | ||
end |