From c87e933dd7c7269d7381683032cd68c0d6be5961 Mon Sep 17 00:00:00 2001 From: Thomas Winwood Date: Fri, 5 Apr 2019 17:55:49 +0100 Subject: [PATCH] Address CardsInHandCondition TODO --- .../src/mage/cards/h/HellfireMongrel.java | 16 +++------------ Mage.Sets/src/mage/cards/l/LavabornMuse.java | 18 +++-------------- .../src/mage/cards/s/ShriekingAffliction.java | 20 +++++-------------- 3 files changed, 11 insertions(+), 43 deletions(-) diff --git a/Mage.Sets/src/mage/cards/h/HellfireMongrel.java b/Mage.Sets/src/mage/cards/h/HellfireMongrel.java index 14f5824c2b..b28d4e75f6 100644 --- a/Mage.Sets/src/mage/cards/h/HellfireMongrel.java +++ b/Mage.Sets/src/mage/cards/h/HellfireMongrel.java @@ -3,19 +3,18 @@ package mage.cards.h; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.condition.common.CardsInHandCondition; import mage.abilities.condition.Condition; import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.ComparisonType; import mage.constants.SubType; import mage.constants.TargetController; import mage.constants.Zone; -import mage.game.Game; -import mage.players.Player; /** * @@ -34,7 +33,7 @@ public final class HellfireMongrel extends CardImpl { // At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, Hellfire Mongrel deals 2 damage to him or her. this.addAbility(new ConditionalInterveningIfTriggeredAbility( new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(2), TargetController.OPPONENT, false, true), - new CardsInActivePlayersHandCondition(), + (Condition)new CardsInHandCondition(ComparisonType.FEWER_THAN, 3, null, TargetController.ACTIVE), "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." )); } @@ -48,12 +47,3 @@ public final class HellfireMongrel extends CardImpl { return new HellfireMongrel(this); } } - -class CardsInActivePlayersHandCondition implements Condition { - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(game.getActivePlayerId()); - return player != null && player.getHand().size() <= 2; - } -} diff --git a/Mage.Sets/src/mage/cards/l/LavabornMuse.java b/Mage.Sets/src/mage/cards/l/LavabornMuse.java index 79d6e154bd..c43fa87603 100644 --- a/Mage.Sets/src/mage/cards/l/LavabornMuse.java +++ b/Mage.Sets/src/mage/cards/l/LavabornMuse.java @@ -3,19 +3,18 @@ package mage.cards.l; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.condition.common.CardsInHandCondition; import mage.abilities.condition.Condition; import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.ComparisonType; import mage.constants.SubType; import mage.constants.TargetController; import mage.constants.Zone; -import mage.game.Game; -import mage.players.Player; /** * @@ -32,7 +31,7 @@ public final class LavabornMuse extends CardImpl { // At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, Lavaborn Muse deals 3 damage to him or her. this.addAbility(new ConditionalInterveningIfTriggeredAbility( new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(3), TargetController.OPPONENT, false, true), - new CardsInActivePlayersHandCondition(), + (Condition)new CardsInHandCondition(ComparisonType.FEWER_THAN, 3, null, TargetController.ACTIVE), "At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, {this} deals 3 damage to him or her.")); } @@ -45,14 +44,3 @@ public final class LavabornMuse extends CardImpl { return new LavabornMuse(this); } } - -// TODO: Figure out CardsInHandCondition parameters and use that instead of rewriting this -// TODO: Update HellfireMongrel, ShriekingAffliction to use the CardsInHandCondition? -class CardsInActivePlayersHandCondition implements Condition { - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(game.getActivePlayerId()); - return player != null && player.getHand().size() <= 2; - } -} diff --git a/Mage.Sets/src/mage/cards/s/ShriekingAffliction.java b/Mage.Sets/src/mage/cards/s/ShriekingAffliction.java index 27b1459b50..50f0cb86e9 100644 --- a/Mage.Sets/src/mage/cards/s/ShriekingAffliction.java +++ b/Mage.Sets/src/mage/cards/s/ShriekingAffliction.java @@ -1,17 +1,16 @@ package mage.cards.s; -import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.condition.common.CardsInHandCondition; import mage.abilities.condition.Condition; import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; import mage.abilities.effects.common.LoseLifeTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.ComparisonType; import mage.constants.TargetController; import mage.constants.Zone; -import mage.game.Game; -import mage.players.Player; import java.util.UUID; @@ -29,8 +28,9 @@ public final class ShriekingAffliction extends CardImpl { new BeginningOfUpkeepTriggeredAbility( Zone.BATTLEFIELD, new LoseLifeTargetEffect(3), TargetController.OPPONENT, false, true - ), ShriekingAfflictionCondition.instance, "At the beginning of each opponent’s upkeep, " + - "if that player has one or fewer cards in hand, they lose 3 life." + ), + (Condition)new CardsInHandCondition(ComparisonType.FEWER_THAN, 2, null, TargetController.ACTIVE), + "At the beginning of each opponent’s upkeep, if that player has one or fewer cards in hand, they lose 3 life." )); } @@ -43,13 +43,3 @@ public final class ShriekingAffliction extends CardImpl { return new ShriekingAffliction(this); } } - -enum ShriekingAfflictionCondition implements Condition { - instance; - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(game.getActivePlayerId()); - return player != null && player.getHand().size() < 2; - } -} \ No newline at end of file