Skip to content

Commit

Permalink
Add Temple of Epiphany
Browse files Browse the repository at this point in the history
Fixes #263
  • Loading branch information
radar committed Jan 28, 2024
1 parent 235ddc1 commit 5c8398f
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
23 changes: 23 additions & 0 deletions lib/magic/cards/temple_of_epiphany.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Magic
module Cards
TempleOfEpiphany = Card("Temple of Epiphany") do
type "Land"

enters_the_battlefield do
game.add_choice(Choice::Scry.new(source: source))
end
end

class TempleOfEpiphany < Card
def enters_tapped?
true
end

class ManaAbility < Magic::TapManaAbility
choices :blue, :red
end

def activated_abilities = [ManaAbility]
end
end
end
6 changes: 5 additions & 1 deletion lib/magic/choice/scry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ class Choice
class Scry < Choice
attr_reader :player, :amount

def initialize(source:, amount:)
def initialize(source:, amount: 1)
@source = source
@amount = amount
super(source: source)
end

def choices
controller.library.first(amount)
end

def resolve!(top: [], bottom: [])
source.controller.scry(amount:, top:, bottom:)
end
Expand Down
48 changes: 48 additions & 0 deletions spec/cards/temple_of_epiphany_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'spec_helper'

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

let(:card) { Card("Temple Of Epiphany") }

let!(:permanent) do
p1.play_land(land: card)
p1.permanents.by_name("Temple of Epiphany").first
end

it "enters the battlefield tapped" do
game.stack.resolve!
expect(permanent).to be_tapped
end

it "scries one" do
choice = game.choices.last
expect(choice).to be_a(Magic::Choice::Scry)

game.resolve_choice!(top: [choice.choices.first])
end

it "taps for blue" do
p1.activate_mana_ability(ability: permanent.activated_abilities.first) do
_1.choose(:blue)
end

expect(p1.mana_pool[:blue]).to eq(1)
end

it "taps for red" do
p1.activate_mana_ability(ability: permanent.activated_abilities.first) do
_1.choose(:red)
end

expect(p1.mana_pool[:red]).to eq(1)
end

it "cannot tap for another color" do
expect {
p1.activate_mana_ability(ability: permanent.activated_abilities.first) do
_1.choose(:green)
end
}.to raise_error("Invalid choice made for mana ability:")
end
end

0 comments on commit 5c8398f

Please sign in to comment.