Skip to content

Commit

Permalink
Add extinguish all hope
Browse files Browse the repository at this point in the history
  • Loading branch information
radar committed Oct 27, 2024
1 parent 2e2da06 commit daedbd5
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/magic/battlefield_filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def battlefield = game.battlefield
def controller = actor.controller
def creatures = battlefield.creatures
def creatures_you_control = creatures.controlled_by(controller)
def creatures_opponents_control = creatures.not_controlled_by(controller)
def other_creatures_you_control = creatures_you_control - [actor]
end
end
2 changes: 2 additions & 0 deletions lib/magic/card_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def nontoken
def excluding_type(*types)
reject { |c| c.any_type?(*types) }
end
alias_method :not, :excluding_type
alias_method :non, :excluding_type

def except(target)
self.class.new(reject { |c| c == target })
Expand Down
15 changes: 15 additions & 0 deletions lib/magic/cards/extinguish_all_hope.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Magic
module Cards
ExtinguishAllHope = Sorcery("Extinguish All Hope") do
cost generic: 4, black: 2

def resolve!
creatures.non("Enchantment").each do |creature|
trigger_effect(:destroy_target, source: self, target: creature)
end

super
end
end
end
end
8 changes: 8 additions & 0 deletions lib/magic/triggered_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ def you?
controller == event.player
end

def this?
actor == event.permanent
end

def type?(type)
event.permanent.types.include?(type)
end

def perform!
return unless should_perform?
call
Expand Down
31 changes: 31 additions & 0 deletions spec/cards/extinguish_all_hope_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'spec_helper'

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

subject(:card) { Card("Extinguish All Hope") }

let(:wood_elves) { ResolvePermanent("Wood Elves") }
let(:doomwake_giant) { ResolvePermanent("Doomwake Giant") }

context "when card is cast" do
before do
wood_elves
doomwake_giant
end

# Wood Elves = regular creature
# Doomwake Giant = enchantment creature
it "destroys the wood elves, keeps doomwake giant" do
p1.add_mana(black: 6)
p1.cast(card: card) do
_1.pay_mana(generic: { black: 4 }, black: 2)
end

game.tick!

expect(wood_elves.card.zone).to be_graveyard
expect(doomwake_giant.zone).to be_battlefield
end
end
end

0 comments on commit daedbd5

Please sign in to comment.