From b9be369bd37c0aa39094b7d8d17b2e9258271545 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 24 Apr 2019 22:14:59 +0400 Subject: [PATCH] * Paupers' Cage - fixed that counts controllers cards in hand instead opponents; --- Mage.Sets/src/mage/cards/p/PaupersCage.java | 5 +- .../abilities/other/PaupersCageTest.java | 81 +++++++++++++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/PaupersCageTest.java diff --git a/Mage.Sets/src/mage/cards/p/PaupersCage.java b/Mage.Sets/src/mage/cards/p/PaupersCage.java index 961a57eecbd..fcfad9135d9 100644 --- a/Mage.Sets/src/mage/cards/p/PaupersCage.java +++ b/Mage.Sets/src/mage/cards/p/PaupersCage.java @@ -26,8 +26,9 @@ public final class PaupersCage extends CardImpl { // At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, Paupers' Cage deals 2 damage to him or her. TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(2), TargetController.OPPONENT, false, true); - CardsInHandCondition condition = new CardsInHandCondition(ComparisonType.FEWER_THAN, 3); - this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, condition, "At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, {this} deals 2 damage to him or her.")); + CardsInHandCondition condition = new CardsInHandCondition(ComparisonType.FEWER_THAN, 3, null, TargetController.ACTIVE); + this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, condition, + "At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, {this} deals 2 damage to him or her.")); } public PaupersCage(final PaupersCage card) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/PaupersCageTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/PaupersCageTest.java new file mode 100644 index 00000000000..460b433fcf8 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/PaupersCageTest.java @@ -0,0 +1,81 @@ +package org.mage.test.cards.abilities.other; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author JayDi85 + */ +public class PaupersCageTest extends CardTestPlayerBase { + + // Paupers' Cage + // At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, + // Paupers' Cage deals 2 damage to him or her. + + @Test + public void test_TooManyCards() { + addCard(Zone.BATTLEFIELD, playerA, "Paupers' Cage", 1); + // + addCard(Zone.HAND, playerA, "Island", 5); + addCard(Zone.HAND, playerB, "Island", 5); + + setStrictChooseMode(true); + setStopAt(2, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + } + + @Test + public void test_YouHaveFewCards() { + addCard(Zone.BATTLEFIELD, playerA, "Paupers' Cage", 1); + // + //addCard(Zone.HAND, playerA, "Island", 5); + addCard(Zone.HAND, playerB, "Island", 5); + + setStrictChooseMode(true); + setStopAt(2, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + } + + @Test + public void test_OpponentHaveFewCards() { + addCard(Zone.BATTLEFIELD, playerA, "Paupers' Cage", 1); + // + addCard(Zone.HAND, playerA, "Island", 5); + //addCard(Zone.HAND, playerB, "Island", 5); + + setStrictChooseMode(true); + setStopAt(2, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 20); + assertLife(playerB, 20 - 2); + } + + @Test + public void test_OpponentHaveFewCardsMultipleTurns() { + addCard(Zone.BATTLEFIELD, playerA, "Paupers' Cage", 1); + // + addCard(Zone.HAND, playerA, "Island", 5); + //addCard(Zone.HAND, playerB, "Island", 5); + + setStrictChooseMode(true); + setStopAt(4, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertLife(playerA, 20); + assertLife(playerB, 20 - 2 * 2); + } +}