-
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.
- Loading branch information
Showing
6 changed files
with
130 additions
and
2 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,54 @@ | ||
module Magic | ||
module Cards | ||
ArchonOfSunsGrace = Creature("Archon of Sun's Grace") do | ||
cost generic: 2, white: 2 | ||
power 3 | ||
toughness 4 | ||
creature_type "Archon" | ||
keywords :flying, :lifelink | ||
end | ||
|
||
class ArchonOfSunsGrace < Creature | ||
PegasusToken = Token.create "Pegasus" do | ||
type "Creature —- Pegasus" | ||
power 2 | ||
toughness 2 | ||
colors :white | ||
keywords :flying | ||
end | ||
|
||
class EntersTrigger < TriggeredAbility::EnterTheBattlefield | ||
def should_perform? | ||
# Whenever an enchantment enters the battlefield under your control ... | ||
enchantment? && under_your_control? | ||
end | ||
|
||
def call | ||
actor.create_token(token_class: PegasusToken) | ||
end | ||
end | ||
|
||
class LifelinkAddition < StaticAbility | ||
def initialize(source:) | ||
@source = source | ||
end | ||
|
||
def keywords | ||
[Cards::Keywords::LIFELINK] | ||
end | ||
|
||
def applicable_targets | ||
source.controller.creatures.of_type("Pegasus") | ||
end | ||
end | ||
|
||
def static_abilities = [LifelinkAddition] | ||
|
||
def event_handlers | ||
{ | ||
Events::EnteredTheBattlefield => EntersTrigger | ||
} | ||
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
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 |
---|---|---|
|
@@ -11,5 +11,9 @@ def toughness | |
def keywords | ||
[] | ||
end | ||
|
||
def applies_to?(_permanent) | ||
true | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
module Magic | ||
class TriggeredAbility | ||
class EnterTheBattlefield < TriggeredAbility | ||
def under_your_control? | ||
event.permanent.controller?(controller) | ||
end | ||
|
||
def enchantment? | ||
event.permanent.enchantment? | ||
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,57 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Magic::Cards::ArchonOfSunsGrace do | ||
include_context "two player game" | ||
|
||
subject { ResolvePermanent("Archon of Sun's Grace") } | ||
|
||
it "has flying" do | ||
expect(subject).to have_keyword(:flying) | ||
end | ||
|
||
it "has lifelink" do | ||
expect(subject).to have_keyword(:lifelink) | ||
end | ||
|
||
context "grants pegasi lifelink" do | ||
let(:pegasus) { described_class::PegasusToken.new(game: game, owner: p1).resolve!} | ||
context "if archon is on the battlefield" do | ||
before do | ||
subject | ||
end | ||
|
||
it "has lifelink" do | ||
expect(pegasus).to have_keyword(:lifelink) | ||
end | ||
end | ||
|
||
context "if archon is not on the battlefield" do | ||
it "does not have lifelink" do | ||
expect(pegasus).not_to have_keyword(:lifelink) | ||
end | ||
end | ||
end | ||
|
||
context "whenever an enchantment enters the battlefield" do | ||
before do | ||
subject | ||
end | ||
|
||
it "... under your control, create a pegasus" do | ||
p1.add_mana(white: 3) | ||
p1.cast(card: Card("Nine Lives")) do | ||
_1.pay_mana(generic: { white: 1 }, white: 2) | ||
end | ||
|
||
game.tick! | ||
|
||
pegasus = creatures.by_name("Pegasus").first | ||
expect(pegasus).not_to be_nil | ||
expect(pegasus.power).to eq(2) | ||
expect(pegasus.toughness).to eq(2) | ||
expect(pegasus).to have_keyword(:flying) | ||
# Pegasus gains lifelink because Archon is on the battlefield | ||
expect(pegasus).to have_keyword(:lifelink) | ||
end | ||
end | ||
end |