refactor more cards using ConditionalInterveningIfTriggeredAbility

This commit is contained in:
theelk801 2025-06-05 12:13:59 -04:00
parent d861f67232
commit d952e3b2ce
26 changed files with 207 additions and 288 deletions

View file

@ -13,13 +13,8 @@ import mage.game.stack.StackObject;
public class DiscardedByOpponentTriggeredAbility extends TriggeredAbilityImpl {
public DiscardedByOpponentTriggeredAbility(Effect effect) {
this(effect, false);
}
public DiscardedByOpponentTriggeredAbility(Effect effect, boolean textCardName) {
super(Zone.GRAVEYARD, effect, false);
setTriggerPhrase("When a spell or ability an opponent controls causes you to discard "
+ (textCardName ? "{this}, " : "this card, "));
setTriggerPhrase("When a spell or ability an opponent controls causes you to discard this card");
}
protected DiscardedByOpponentTriggeredAbility(final DiscardedByOpponentTriggeredAbility ability) {
@ -38,12 +33,10 @@ public class DiscardedByOpponentTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (getSourceId().equals(event.getTargetId())) {
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
if (stackObject != null) {
return game.getOpponents(this.getControllerId()).contains(stackObject.getControllerId());
}
if (!getSourceId().equals(event.getTargetId())) {
return false;
}
return false;
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
return stackObject != null && game.getOpponents(this.getControllerId()).contains(stackObject.getControllerId());
}
}

View file

@ -8,7 +8,6 @@ import mage.game.Game;
/**
* @author TheElk801
*/
public enum FullPartyCondition implements Condition {
instance;
@ -16,4 +15,9 @@ public enum FullPartyCondition implements Condition {
public boolean apply(Game game, Ability source) {
return PartyCount.instance.calculate(game, source, null) >= 4;
}
@Override
public String toString() {
return "you have a full party";
}
}

View file

@ -12,9 +12,9 @@ import mage.game.Game;
*/
public class KickedCostCondition implements Condition {
protected String kickerCostText;
protected final String kickerCostText;
public KickedCostCondition(String kickerCostText) {
public KickedCostCondition(String kickerCostText) {
this.kickerCostText = kickerCostText;
}
@ -22,4 +22,9 @@ public class KickedCostCondition implements Condition {
public boolean apply(Game game, Ability source) {
return KickerAbility.getKickedCounterStrict(game, source, kickerCostText) > 0;
}
@Override
public String toString() {
return "it was kicked with its " + kickerCostText + " kicker";
}
}