Skip to content

Commit

Permalink
Implement Peer Into The Abyss
Browse files Browse the repository at this point in the history
Fixes #371
  • Loading branch information
radar committed Jan 21, 2024
1 parent 1bf2c0e commit 453bee8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/magic/cards/peer_into_the_abyss.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Magic
module Cards
PeerIntoTheAbyss = Sorcery("Peer Into the Abyss") do
cost black: 3, generic: 4

def single_target?
true
end

def target_choices
game.players
end

def resolve!(target:)
effect = Magic::Effects::DrawCards.new(source: self, player: target, number_to_draw: (target.library.count / 2.0).ceil)
game.add_effect(effect)

effect = Magic::Effects::LoseLife.new(source: self, targets: [target], life: (target.life / 2.0).ceil)
game.add_effect(effect)
end
end
end
end
20 changes: 20 additions & 0 deletions spec/cards/peer_into_the_abyss_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'

RSpec.describe Magic::Cards::PeerIntoTheAbyss do
include_context "two player game"
subject(:peer_into_the_abyss) { Card("Peer Into The Abyss") }

it "p2 draws half their library, and loses half their life, rounded up" do
3.times { p2.library.add(Card("Forest")) }
p2.lose_life(1)
p1.add_mana(black: 7)
p1.cast(card: peer_into_the_abyss) do
_1.targeting(p2)
_1.pay_mana(black: 3, generic: { black: 4 })
end
game.tick!

expect(p2.library.count).to eq(1)
expect(p2.life).to eq(9)
end
end

0 comments on commit 453bee8

Please sign in to comment.