Skip to content

Commit

Permalink
Add Spined Megalodon
Browse files Browse the repository at this point in the history
Fixes #82
  • Loading branch information
radar committed Feb 24, 2024
1 parent 6b6178c commit f606c7c
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/magic/cards/spined_megalodon.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Magic
module Cards
class SpinedMegalodon < Creature
card_name "Spined Megalodon"
creature_type "Shark"
cost generic: 5, blue: 2
power 5
toughness 7

keywords :hexproof

class ScryTrigger < TriggeredAbility::Base
def should_perform?
return false if event.attacks.none? { |attack| attack.attacker == actor }
true
end

def call
actor.add_choice(:scry, actor: actor)
end
end


def event_handlers
{
Events::PreliminaryAttackersDeclared => ScryTrigger
}
end
end
end
end
26 changes: 26 additions & 0 deletions spec/cards/spined_megalodon_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require "spec_helper"

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

let(:permanent) { ResolvePermanent("Spined Megalodon") }

it "has hexproof" do
expect(permanent).to be_hexproof
end

it "scries 1 when it attacks" do
skip_to_combat!

current_turn.declare_attackers!

p1.declare_attacker(
attacker: permanent,
target: p2
)

current_turn.attackers_declared!

expect(game.choices.first).to be_a(Magic::Choice::Scry)
end
end

0 comments on commit f606c7c

Please sign in to comment.