mirror of
https://github.com/correl/mage.git
synced 2025-01-13 11:01:58 +00:00
refactored all instances of BeginningOfUpkeepAttachedTriggeredAbility
This commit is contained in:
parent
bd22c4a3ae
commit
c6feab68da
9 changed files with 47 additions and 101 deletions
|
@ -1,7 +1,7 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepAttachedTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
|
@ -10,6 +10,7 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
|
@ -38,7 +39,7 @@ public final class CruelReality extends CardImpl {
|
|||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||
|
||||
//At the beginning of enchanted player's upkeep, that player sacrifices a creature or planeswalker. If the player can't, they lose 5 life.
|
||||
this.addAbility(new BeginningOfUpkeepAttachedTriggeredAbility(new CruelRealityEffect()));
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new CruelRealityEffect(), TargetController.ENCHANTED, false));
|
||||
}
|
||||
|
||||
private CruelReality(final CruelReality card) {
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepAttachedTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.ExileFromZoneTargetEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
|
@ -33,9 +30,9 @@ public final class CurseOfOblivion extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// At the beginning of enchanted player's upkeep, that player exiles two cards from their graveyard.
|
||||
this.addAbility(new BeginningOfUpkeepAttachedTriggeredAbility(new ExileFromZoneTargetEffect(
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new ExileFromZoneTargetEffect(
|
||||
Zone.GRAVEYARD, StaticFilters.FILTER_CARD_CARDS, 2, false
|
||||
).setText("that player exiles two cards from their graveyard")));
|
||||
).setText("that player exiles two cards from their graveyard"), TargetController.ENCHANTED, false));
|
||||
}
|
||||
|
||||
private CurseOfOblivion(final CurseOfOblivion card) {
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.common.BeginningOfUpkeepAttachedTriggeredAbility;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DrawCardTargetEffect;
|
||||
import mage.constants.SubType;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.effects.common.DrawCardTargetEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.FilterPlayer;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.other.PlayerIdPredicate;
|
||||
|
@ -22,8 +21,9 @@ import mage.game.permanent.Permanent;
|
|||
import mage.target.TargetPlayer;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author weirddan455
|
||||
*/
|
||||
public final class CurseOfSurveillance extends CardImpl {
|
||||
|
@ -42,11 +42,11 @@ public final class CurseOfSurveillance extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// At the beginning of enchanted player's upkeep, any number of target players other than that player each draw cards equal to the number of Curses attached to that player.
|
||||
ability = new BeginningOfUpkeepAttachedTriggeredAbility(
|
||||
ability = new BeginningOfUpkeepTriggeredAbility(
|
||||
new DrawCardTargetEffect(CurseOfSurveillanceValue.instance).setText(
|
||||
"any number of target players other than that player each draw cards equal to the number of Curses attached to that player"
|
||||
),
|
||||
false, false
|
||||
TargetController.ENCHANTED, false
|
||||
);
|
||||
ability.setTargetAdjuster(CurseOfSurveillanceTargetAdjuster.instance);
|
||||
ability.addTarget(new TargetPlayer(0, Integer.MAX_VALUE, false));
|
||||
|
@ -68,13 +68,12 @@ enum CurseOfSurveillanceValue implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
UUID enchantedPlayerId = (UUID) effect.getValue("enchantedPlayer");
|
||||
int curses = 0;
|
||||
if (enchantedPlayerId != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent != null && permanent.hasSubtype(SubType.CURSE, game) && permanent.isAttachedTo(enchantedPlayerId)) {
|
||||
curses++;
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent != null
|
||||
&& permanent.hasSubtype(SubType.CURSE, game)
|
||||
&& permanent.isAttachedTo(game.getActivePlayerId())) {
|
||||
curses++;
|
||||
}
|
||||
}
|
||||
return curses;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepAttachedTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
|
@ -10,6 +10,7 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -31,8 +32,10 @@ public final class CurseOfTheBloodyTome extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// At the beginning of enchanted player's upkeep, that player puts the top two cards of their library into their graveyard.
|
||||
this.addAbility(new BeginningOfUpkeepAttachedTriggeredAbility(
|
||||
new PutLibraryIntoGraveTargetEffect(2).setText("that player mills two cards")
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
|
||||
new PutLibraryIntoGraveTargetEffect(2)
|
||||
.setText("that player mills two cards"),
|
||||
TargetController.ENCHANTED, false
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepAttachedTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
|
@ -10,6 +10,7 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||
|
@ -39,7 +40,9 @@ public final class CurseOfThePiercedHeart extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// At the beginning of enchanted player's upkeep, Curse of the Pierced Heart deals 1 damage to that player.
|
||||
this.addAbility(new BeginningOfUpkeepAttachedTriggeredAbility(new CurseOfThePiercedHeartEffect()));
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
|
||||
new CurseOfThePiercedHeartEffect(), TargetController.ENCHANTED, false
|
||||
));
|
||||
}
|
||||
|
||||
private CurseOfThePiercedHeart(final CurseOfThePiercedHeart card) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepAttachedTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
|
@ -12,6 +12,7 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
|
@ -35,9 +36,10 @@ public final class CurseOfThirst extends CardImpl {
|
|||
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
|
||||
|
||||
// At the beginning of enchanted player's upkeep, Curse of Thirst deals damage to that player equal to the number of Curses attached to them.
|
||||
this.addAbility(new BeginningOfUpkeepAttachedTriggeredAbility(
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
|
||||
new DamageTargetEffect(CursesAttachedCount.instance)
|
||||
.setText("{this} deals damage to that player equal to the number of Curses attached to them")
|
||||
.setText("{this} deals damage to that player equal to the number of Curses attached to them"),
|
||||
TargetController.ENCHANTED, false
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package mage.cards.i;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepAttachedTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.GainLifeEffect;
|
||||
|
@ -45,8 +45,9 @@ public final class InfectiousCurse extends CardImpl {
|
|||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new InfectiousCurseCostReductionEffect()));
|
||||
|
||||
// At the beginning of enchanted player's upkeep, that player loses 1 life and you gain 1 life.
|
||||
Ability ability = new BeginningOfUpkeepAttachedTriggeredAbility(
|
||||
new LoseLifeTargetEffect(1).setText("that player loses 1 life")
|
||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(
|
||||
new LoseLifeTargetEffect(1).setText("that player loses 1 life"),
|
||||
TargetController.ENCHANTED, false
|
||||
);
|
||||
ability.addEffect(new GainLifeEffect(1).concatBy("and"));
|
||||
this.addAbility(ability);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepAttachedTriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
|
@ -10,6 +10,7 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -38,7 +39,9 @@ public final class TormentOfScarabs extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// At the beginning of enchanted player's upkeep, that player loses 3 life unless they sacrifice a nonland permanent or discards a card.
|
||||
this.addAbility(new BeginningOfUpkeepAttachedTriggeredAbility(new TormentOfScarabsEffect()));
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
|
||||
new TormentOfScarabsEffect(), TargetController.ENCHANTED, false
|
||||
));
|
||||
}
|
||||
|
||||
private TormentOfScarabs(final TormentOfScarabs card) {
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class BeginningOfUpkeepAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final boolean setTargetPointer;
|
||||
|
||||
public BeginningOfUpkeepAttachedTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public BeginningOfUpkeepAttachedTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, optional, true);
|
||||
}
|
||||
|
||||
public BeginningOfUpkeepAttachedTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
private BeginningOfUpkeepAttachedTriggeredAbility(final BeginningOfUpkeepAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeginningOfUpkeepAttachedTriggeredAbility copy() {
|
||||
return new BeginningOfUpkeepAttachedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent enchantment = getSourcePermanentOrLKI(game);
|
||||
if (enchantment == null || !game.isActivePlayer(enchantment.getAttachedTo())) {
|
||||
return false;
|
||||
}
|
||||
if (setTargetPointer) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(enchantment.getAttachedTo()));
|
||||
}
|
||||
this.getEffects().setValue("enchantedPlayer", enchantment.getAttachedTo());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTriggerPhrase() {
|
||||
return "At the beginning of enchanted player's upkeep, " ;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue