Address CardsInHandCondition TODO

This commit is contained in:
Thomas Winwood 2019-04-05 17:55:49 +01:00
parent 2018505a62
commit c87e933dd7
3 changed files with 11 additions and 43 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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 opponents 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 opponents 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;
}
}