From 9fc52941df49cb918696c0182f9ace4d41be80a9 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Jan 2024 21:25:59 +1100 Subject: [PATCH] Add Dismal Backwater --- lib/magic/cards/dismal_backwater.rb | 23 +++++++++++++++ spec/cards/dismal_backwater_spec.rb | 45 +++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 lib/magic/cards/dismal_backwater.rb create mode 100644 spec/cards/dismal_backwater_spec.rb diff --git a/lib/magic/cards/dismal_backwater.rb b/lib/magic/cards/dismal_backwater.rb new file mode 100644 index 0000000..54885bd --- /dev/null +++ b/lib/magic/cards/dismal_backwater.rb @@ -0,0 +1,23 @@ +module Magic + module Cards + DismalBackwater = Card("Dismal Backwater") do + type "Land" + + enters_the_battlefield do + permanent.controller.gain_life(1) + end + end + + class DismalBackwater < Card + def enters_tapped? + true + end + + class ManaAbility < Magic::TapManaAbility + choices :blue, :black + end + + def activated_abilities = [ManaAbility] + end + end +end diff --git a/spec/cards/dismal_backwater_spec.rb b/spec/cards/dismal_backwater_spec.rb new file mode 100644 index 0000000..b40e8a5 --- /dev/null +++ b/spec/cards/dismal_backwater_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +RSpec.describe Magic::Cards::DismalBackwater do + include_context "two player game" + + let(:card) { Card("Dismal Backwater") } + + let!(:permanent) do + p1.play_land(land: card) + p1.permanents.by_name("Dismal Backwater").first + end + + it "enters the battlefield tapped" do + game.stack.resolve! + expect(permanent).to be_tapped + end + + it "has the controller gain life" do + expect(p1.life).to eq(21) + 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 black" do + p1.activate_mana_ability(ability: permanent.activated_abilities.first) do + _1.choose(:black) + end + + expect(p1.mana_pool[:black]).to eq(1) + end + + it "cannot tap for another color" do + expect { + p1.activate_mana_ability(ability: permanent.activated_abilities.first) do + _1.choose(:white) + end + }.to raise_error("Invalid choice made for mana ability:") + end +end