mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Moved some custom "Cast only" effects to the framework.
This commit is contained in:
parent
e2c8b8f583
commit
f4a9a66974
22 changed files with 421 additions and 678 deletions
|
@ -30,9 +30,9 @@ package mage.sets.commander2013;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.condition.common.OnOpponentsTurnCondition;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.RequirementEffect;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
|
@ -43,9 +43,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.Phase;
|
||||
import mage.game.turn.TurnMod;
|
||||
|
@ -60,11 +58,9 @@ public class IllusionistsGambit extends CardImpl {
|
|||
super(ownerId, 47, "Illusionist's Gambit", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{2}{U}{U}");
|
||||
this.expansionSetCode = "C13";
|
||||
|
||||
|
||||
// Cast Illusionist's Gambit only during the declare blockers step on an opponent's turn.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new IllusionistsGambitEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(PhaseStep.DECLARE_BLOCKERS, OnOpponentsTurnCondition.getInstance()));
|
||||
|
||||
// Remove all attacking creatures from combat and untap them. After this phase, there is an additional combat phase. Each of those creatures attacks that combat if able. They can't attack you or a planeswalker you control that combat.
|
||||
this.getSpellAbility().addEffect(new IllusionistsGambitRemoveFromCombatEffect());
|
||||
}
|
||||
|
@ -79,38 +75,6 @@ public class IllusionistsGambit extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class IllusionistsGambitEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
IllusionistsGambitEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during the declare blockers step on an opponent's turn";
|
||||
}
|
||||
|
||||
IllusionistsGambitEffect(final IllusionistsGambitEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType().equals(GameEvent.EventType.CAST_SPELL) && event.getSourceId().equals(source.getSourceId())) {
|
||||
if (game.getTurn().getStepType().equals(PhaseStep.DECLARE_BLOCKERS)) {
|
||||
return !game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IllusionistsGambitEffect copy() {
|
||||
return new IllusionistsGambitEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class IllusionistsGambitRemoveFromCombatEffect extends OneShotEffect {
|
||||
|
||||
public IllusionistsGambitRemoveFromCombatEffect() {
|
||||
|
@ -130,7 +94,7 @@ class IllusionistsGambitRemoveFromCombatEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<UUID> attackers = game.getCombat().getAttackers();
|
||||
for (UUID attackerId :attackers) {
|
||||
for (UUID attackerId : attackers) {
|
||||
Permanent creature = game.getPermanent(attackerId);
|
||||
if (creature != null) {
|
||||
creature.removeFromCombat(game);
|
||||
|
@ -237,13 +201,13 @@ class IllusionistsGambitRestrictionEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean canAttack(UUID defenderId, Ability source, Game game) {
|
||||
if (defenderId.equals(source.getControllerId()) ) {
|
||||
if (defenderId.equals(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
// planeswalker
|
||||
Permanent permanent = game.getPermanent(defenderId);
|
||||
if (permanent != null && permanent.getControllerId().equals(source.getControllerId())
|
||||
&& permanent.getCardType().contains(CardType.PLANESWALKER)) {
|
||||
&& permanent.getCardType().contains(CardType.PLANESWALKER)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -31,9 +31,9 @@ import java.util.UUID;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.condition.common.OnOpponentsTurnCondition;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.SacrificeTargetEffect;
|
||||
|
@ -41,14 +41,12 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
@ -65,9 +63,7 @@ public class WakeTheDead extends CardImpl {
|
|||
this.expansionSetCode = "C14";
|
||||
|
||||
// Cast Wake the Dead only during combat on an opponent's turn.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new WakeTheDeadEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, OnOpponentsTurnCondition.getInstance()));
|
||||
|
||||
// Return X target creature cards from your graveyard to the battlefield. Sacrifice those creatures at the beginning of the next end step.
|
||||
this.getSpellAbility().addEffect(new WakeTheDeadReturnFromGraveyardToBattlefieldTargetEffect());
|
||||
|
@ -93,44 +89,6 @@ public class WakeTheDead extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class WakeTheDeadEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
WakeTheDeadEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during combat on an opponent's turn";
|
||||
}
|
||||
|
||||
WakeTheDeadEffect(final WakeTheDeadEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.CAST_SPELL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
if (game.getPhase().getType().equals(TurnPhase.COMBAT)) {
|
||||
return !game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WakeTheDeadEffect copy() {
|
||||
return new WakeTheDeadEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class WakeTheDeadReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect {
|
||||
|
||||
public WakeTheDeadReturnFromGraveyardToBattlefieldTargetEffect() {
|
||||
|
|
|
@ -29,22 +29,18 @@ package mage.sets.commander2015;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ExileTargetEffect;
|
||||
import mage.abilities.effects.common.PutTokenOntoBattlefieldCopyTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
@ -60,9 +56,7 @@ public class MirrorMatch extends CardImpl {
|
|||
this.expansionSetCode = "C15";
|
||||
|
||||
// Cast Mirror Match only during the declare blockers step.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new MirrorMatchRuleModifyingEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(PhaseStep.DECLARE_BLOCKERS));
|
||||
|
||||
// For each creature attacking you or a planeswalker you control, put a token that's a copy of that creature onto the battlefield blocking that creature. Exile those tokens at end of combat.
|
||||
this.getSpellAbility().addEffect(new MirrorMatchEffect());
|
||||
|
@ -79,41 +73,6 @@ public class MirrorMatch extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class MirrorMatchRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
MirrorMatchRuleModifyingEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during the declare blockers step";
|
||||
}
|
||||
|
||||
MirrorMatchRuleModifyingEffect(final MirrorMatchRuleModifyingEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return GameEvent.EventType.CAST_SPELL.equals(event.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
return !game.getTurn().getStepType().equals(PhaseStep.DECLARE_BLOCKERS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MirrorMatchRuleModifyingEffect copy() {
|
||||
return new MirrorMatchRuleModifyingEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MirrorMatchEffect extends OneShotEffect {
|
||||
|
||||
public MirrorMatchEffect() {
|
||||
|
|
|
@ -30,8 +30,8 @@ package mage.sets.darksteel;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.condition.common.MyTurnCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.UntapAllControllerEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
|
||||
|
@ -43,11 +43,9 @@ import mage.constants.Duration;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.turn.TurnMod;
|
||||
|
||||
/**
|
||||
|
@ -60,21 +58,19 @@ public class SavageBeating extends CardImpl {
|
|||
super(ownerId, 67, "Savage Beating", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{3}{R}{R}");
|
||||
this.expansionSetCode = "DST";
|
||||
|
||||
|
||||
// Cast Savage Beating only during your turn and only during combat.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new SavageBeatingTimingEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, null, MyTurnCondition.getInstance(),
|
||||
"Cast {this} only during your turn and only during combat"));
|
||||
|
||||
// Choose one - Creatures you control gain double strike until end of turn;
|
||||
this.getSpellAbility().addEffect(new GainAbilityControlledEffect(DoubleStrikeAbility.getInstance(), Duration.EndOfTurn, new FilterCreaturePermanent(), false));
|
||||
|
||||
|
||||
// or untap all creatures you control and after this phase, there is an additional combat phase.
|
||||
Mode mode = new Mode();
|
||||
mode.getEffects().add(new UntapAllControllerEffect(new FilterControlledCreaturePermanent(), "untap all creatures you control"));
|
||||
mode.getEffects().add(new AdditionalCombatPhaseEffect());
|
||||
this.getSpellAbility().getModes().addMode(mode);
|
||||
|
||||
|
||||
// Entwine {1}{R}
|
||||
this.addAbility(new EntwineAbility("{1}{R}"));
|
||||
}
|
||||
|
@ -89,56 +85,25 @@ public class SavageBeating extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class SavageBeatingTimingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
SavageBeatingTimingEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during your turn and only during combat";
|
||||
class AdditionalCombatPhaseEffect extends OneShotEffect {
|
||||
|
||||
AdditionalCombatPhaseEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "and after this phase, there is an additional combat phase";
|
||||
}
|
||||
|
||||
SavageBeatingTimingEffect(final SavageBeatingTimingEffect effect) {
|
||||
AdditionalCombatPhaseEffect(final AdditionalCombatPhaseEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType().equals(GameEvent.EventType.CAST_SPELL) && event.getSourceId().equals(source.getSourceId())) {
|
||||
if (!game.getActivePlayerId().equals(source.getControllerId()) || !TurnPhase.COMBAT.equals(game.getTurn().getPhaseType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public AdditionalCombatPhaseEffect copy() {
|
||||
return new AdditionalCombatPhaseEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavageBeatingTimingEffect copy() {
|
||||
return new SavageBeatingTimingEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AdditionalCombatPhaseEffect extends OneShotEffect {
|
||||
|
||||
AdditionalCombatPhaseEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "and after this phase, there is an additional combat phase";
|
||||
}
|
||||
|
||||
AdditionalCombatPhaseEffect(final AdditionalCombatPhaseEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalCombatPhaseEffect copy() {
|
||||
return new AdditionalCombatPhaseEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -45,13 +45,11 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
|
@ -135,26 +133,7 @@ class SylvanLibraryEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
int numberOfCardsToPutBack = cardsPutBack.size();
|
||||
if (numberOfCardsToPutBack > 1) {
|
||||
TargetCard target2 = new TargetCard(Zone.HAND, new FilterCard("card to put on the top of your library (last chosen will be on top)"));
|
||||
while (controller.canRespond() && cardsPutBack.size() > 1) {
|
||||
controller.choose(Outcome.Benefit, cardsPutBack, target2, game);
|
||||
Card card = cardsPutBack.get(target2.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
cardsPutBack.remove(card);
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
}
|
||||
target2.clearChosen();
|
||||
}
|
||||
}
|
||||
if (cardsPutBack.size() == 1) {
|
||||
Card card = cardsPutBack.get(cardsPutBack.iterator().next(), game);
|
||||
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
|
||||
}
|
||||
if (numberOfCardsToPutBack > 0) {
|
||||
game.informPlayers(controller.getLogName() + " puts " + numberOfCardsToPutBack + " card(s) back to library");
|
||||
}
|
||||
controller.putCardsOnTopOfLibrary(cardsPutBack, game, source, applyEffectsAfter);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -29,9 +29,11 @@ package mage.sets.fourthedition;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.condition.CompoundCondition;
|
||||
import mage.abilities.condition.common.BeforeAttackersAreDeclaredCondition;
|
||||
import mage.abilities.condition.common.OnOpponentsTurnCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.RequirementEffect;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
|
@ -39,12 +41,8 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.common.AttackedThisTurnWatcher;
|
||||
|
@ -60,13 +58,13 @@ public class SirensCall extends CardImpl {
|
|||
this.expansionSetCode = "4ED";
|
||||
|
||||
// Cast Siren's Call only during an opponent's turn, before attackers are declared.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new SirensCallTimingEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(null, null,
|
||||
new CompoundCondition(OnOpponentsTurnCondition.getInstance(), BeforeAttackersAreDeclaredCondition.getInstance()),
|
||||
"Cast {this} only during an opponent's turn, before attackers are declared"));
|
||||
|
||||
// Creatures the active player controls attack this turn if able.
|
||||
this.getSpellAbility().addEffect(new SirensCallMustAttackEffect());
|
||||
|
||||
|
||||
// At the beginning of the next end step, destroy all non-Wall creatures that player controls that didn't attack this turn. Ignore this effect for each creature the player didn't control continuously since the beginning of the turn.
|
||||
this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SirensCallDestroyEffect())));
|
||||
this.getSpellAbility().addWatcher(new AttackedThisTurnWatcher());
|
||||
|
@ -82,44 +80,6 @@ public class SirensCall extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class SirensCallTimingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
SirensCallTimingEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during an opponent's turn, before attackers are declared";
|
||||
}
|
||||
|
||||
SirensCallTimingEffect(final SirensCallTimingEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.CAST_SPELL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
if (game.getPhase().getType().equals(TurnPhase.BEGINNING) || game.getStep().getType().equals(PhaseStep.BEGIN_COMBAT)) {
|
||||
return !game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SirensCallTimingEffect copy() {
|
||||
return new SirensCallTimingEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SirensCallMustAttackEffect extends RequirementEffect {
|
||||
|
||||
SirensCallMustAttackEffect() {
|
||||
|
@ -154,21 +114,21 @@ class SirensCallMustAttackEffect extends RequirementEffect {
|
|||
}
|
||||
|
||||
class SirensCallDestroyEffect extends OneShotEffect {
|
||||
|
||||
|
||||
SirensCallDestroyEffect() {
|
||||
super(Outcome.DestroyPermanent);
|
||||
this.staticText = "destroy all non-Wall creatures that player controls that didn't attack this turn. Ignore this effect for each creature the player didn't control continuously since the beginning of the turn";
|
||||
}
|
||||
|
||||
|
||||
SirensCallDestroyEffect(final SirensCallDestroyEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SirensCallDestroyEffect copy() {
|
||||
return new SirensCallDestroyEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(game.getActivePlayerId());
|
||||
|
|
|
@ -29,8 +29,8 @@ package mage.sets.invasion;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.condition.common.AfterBlockersAreDeclaredCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
|
@ -38,12 +38,9 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
@ -59,14 +56,12 @@ public class ChaoticStrike extends CardImpl {
|
|||
this.expansionSetCode = "INV";
|
||||
|
||||
// Cast Chaotic Strike only during combat after blockers are declared.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new ChaoticStrikeRuleModifyingEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, AfterBlockersAreDeclaredCondition.getInstance()));
|
||||
|
||||
// Flip a coin. If you win the flip, target creature gets +1/+1 until end of turn.
|
||||
this.getSpellAbility().addEffect(new ChaoticStrikeEffect());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
|
||||
|
||||
// Draw a card.
|
||||
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
|
||||
}
|
||||
|
@ -81,43 +76,6 @@ public class ChaoticStrike extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class ChaoticStrikeRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
ChaoticStrikeRuleModifyingEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during combat after blockers are declared";
|
||||
}
|
||||
|
||||
ChaoticStrikeRuleModifyingEffect(final ChaoticStrikeRuleModifyingEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.CAST_SPELL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
return !game.getPhase().getType().equals(TurnPhase.COMBAT) ||
|
||||
game.getStep().getType().equals(PhaseStep.BEGIN_COMBAT) ||
|
||||
game.getStep().getType().equals(PhaseStep.DECLARE_ATTACKERS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChaoticStrikeRuleModifyingEffect copy() {
|
||||
return new ChaoticStrikeRuleModifyingEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ChaoticStrikeEffect extends OneShotEffect {
|
||||
|
||||
public ChaoticStrikeEffect() {
|
||||
|
@ -137,8 +95,8 @@ class ChaoticStrikeEffect extends OneShotEffect {
|
|||
if (controller.flipCoin(game)) {
|
||||
game.addEffect(new BoostTargetEffect(1, 1, Duration.EndOfTurn), source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,8 @@ package mage.sets.invasion;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.UntapTargetEffect;
|
||||
|
@ -46,11 +45,9 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Rarity;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
|
@ -63,6 +60,7 @@ import mage.target.targetpointer.FixedTarget;
|
|||
public class SpinalEmbrace extends CardImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you don't control");
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.NOT_YOU));
|
||||
}
|
||||
|
@ -71,11 +69,9 @@ public class SpinalEmbrace extends CardImpl {
|
|||
super(ownerId, 276, "Spinal Embrace", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{3}{U}{U}{B}");
|
||||
this.expansionSetCode = "INV";
|
||||
|
||||
|
||||
// Cast Spinal Embrace only during combat.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new SpinalEmbraceEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT));
|
||||
|
||||
// Untap target creature you don't control and gain control of it. It gains haste until end of turn. At the beginning of the next end step, sacrifice it. If you do, you gain life equal to its toughness.
|
||||
this.getSpellAbility().addTarget(new TargetPermanent(filter));
|
||||
this.getSpellAbility().addEffect(new UntapTargetEffect());
|
||||
|
@ -96,40 +92,6 @@ public class SpinalEmbrace extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class SpinalEmbraceEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
SpinalEmbraceEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during combat";
|
||||
}
|
||||
|
||||
SpinalEmbraceEffect(final SpinalEmbraceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.CAST_SPELL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
return !TurnPhase.COMBAT.equals(game.getTurn().getPhaseType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpinalEmbraceEffect copy() {
|
||||
return new SpinalEmbraceEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SpinalEmbraceAddDelayedEffect extends OneShotEffect {
|
||||
|
||||
public SpinalEmbraceAddDelayedEffect() {
|
||||
|
|
|
@ -75,9 +75,8 @@ public class Godsend extends CardImpl {
|
|||
this.supertype.add("Legendary");
|
||||
this.subtype.add("Equipment");
|
||||
|
||||
|
||||
// Equipped creature gets +3/+3.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(3,3,Duration.WhileOnBattlefield)));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(3, 3, Duration.WhileOnBattlefield)));
|
||||
// Whenever equipped creature blocks or becomes blocked by one or more creatures, you may exile one of those creatures.
|
||||
this.addAbility(new GodsendTriggeredAbility());
|
||||
// Opponents can't cast cards with the same name as cards exiled with Godsend.
|
||||
|
@ -99,7 +98,7 @@ public class Godsend extends CardImpl {
|
|||
class GodsendTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private Set<UUID> possibleTargets = new HashSet<>();
|
||||
|
||||
|
||||
GodsendTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new GodsendExileEffect(), true);
|
||||
}
|
||||
|
@ -121,29 +120,29 @@ class GodsendTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent equipment = game.getPermanentOrLKIBattlefield((this.getSourceId()));
|
||||
if (equipment != null && equipment.getAttachedTo()!= null) {
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent equippedPermanent = game.getPermanentOrLKIBattlefield((equipment.getAttachedTo()));
|
||||
if (equippedPermanent != null) {
|
||||
possibleTargets.clear();
|
||||
String targetName = "";
|
||||
if (equippedPermanent.isAttacking()) {
|
||||
for (CombatGroup group: game.getCombat().getGroups()) {
|
||||
if (equippedPermanent.isAttacking()) {
|
||||
for (CombatGroup group : game.getCombat().getGroups()) {
|
||||
if (group.getAttackers().contains(equippedPermanent.getId())) {
|
||||
possibleTargets.addAll(group.getBlockers());
|
||||
}
|
||||
}
|
||||
targetName = "a creature blocking attacker ";
|
||||
} else if (equippedPermanent.getBlocking() > 0) {
|
||||
for (CombatGroup group: game.getCombat().getGroups()) {
|
||||
for (CombatGroup group : game.getCombat().getGroups()) {
|
||||
if (group.getBlockers().contains(equippedPermanent.getId())) {
|
||||
possibleTargets.addAll(group.getAttackers());
|
||||
}
|
||||
}
|
||||
targetName = "a creature blocked by creature ";
|
||||
}
|
||||
if (possibleTargets.size() > 0) {
|
||||
}
|
||||
if (possibleTargets.size() > 0) {
|
||||
this.getTargets().clear();
|
||||
if (possibleTargets.size() == 1) {
|
||||
if (possibleTargets.size() == 1) {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(possibleTargets.iterator().next()));
|
||||
} else {
|
||||
this.getEffects().get(0).setTargetPointer(new FirstTargetPointer());
|
||||
|
@ -170,21 +169,21 @@ class GodsendTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
|
||||
class GodsendExileEffect extends OneShotEffect {
|
||||
|
||||
|
||||
public GodsendExileEffect() {
|
||||
super(Outcome.Exile);
|
||||
this.staticText = "you may exile one of those creatures";
|
||||
}
|
||||
|
||||
|
||||
public GodsendExileEffect(final GodsendExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GodsendExileEffect copy() {
|
||||
return new GodsendExileEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||
|
@ -192,10 +191,9 @@ class GodsendExileEffect extends OneShotEffect {
|
|||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (creature != null && controller != null && sourcePermanent != null) {
|
||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||
controller.moveCardToExileWithInfo(creature, exileId,
|
||||
sourcePermanent.getIdName() + " (" + sourcePermanent.getZoneChangeCounter(game) + ")"
|
||||
, source.getSourceId(), game, Zone.BATTLEFIELD, true);
|
||||
|
||||
controller.moveCardToExileWithInfo(creature, exileId,
|
||||
sourcePermanent.getIdName() + " (" + sourcePermanent.getZoneChangeCounter(game) + ")", source.getSourceId(), game, Zone.BATTLEFIELD, true);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -212,11 +210,6 @@ class GodsendRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GodsendRuleModifyingEffect copy() {
|
||||
return new GodsendRuleModifyingEffect(this);
|
||||
|
@ -238,11 +231,11 @@ class GodsendRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
if (object != null) {
|
||||
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
|
||||
if ((exileZone != null)) {
|
||||
for(Card card:exileZone.getCards(game)) {
|
||||
for (Card card : exileZone.getCards(game)) {
|
||||
if ((card.getName().equals(object.getName()))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,20 +28,14 @@
|
|||
package mage.sets.legends;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.condition.CompoundCondition;
|
||||
import mage.abilities.condition.common.AfterUpkeepStepCondtion;
|
||||
import mage.abilities.condition.common.OnOpponentsTurnCondition;
|
||||
import mage.abilities.effects.common.UntapAllLandsControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -53,11 +47,11 @@ public class Reset extends CardImpl {
|
|||
super(ownerId, 73, "Reset", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{U}{U}");
|
||||
this.expansionSetCode = "LEG";
|
||||
|
||||
|
||||
// Cast Reset only during an opponent's turn after his or her upkeep step.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new ResetReplacementEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(null, null,
|
||||
new CompoundCondition(OnOpponentsTurnCondition.getInstance(), AfterUpkeepStepCondtion.getInstance()),
|
||||
"Cast {this} only during an opponent's turn after his or her upkeep step"));
|
||||
|
||||
// Untap all lands you control.
|
||||
this.getSpellAbility().addEffect(new UntapAllLandsControllerEffect());
|
||||
}
|
||||
|
@ -71,37 +65,3 @@ public class Reset extends CardImpl {
|
|||
return new Reset(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ResetReplacementEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
ResetReplacementEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during an opponent's turn after his or her upkeep step";
|
||||
}
|
||||
|
||||
ResetReplacementEffect(final ResetReplacementEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType().equals(GameEvent.EventType.CAST_SPELL) && event.getSourceId().equals(source.getSourceId())) {
|
||||
if (game.getTurn().getStepType().equals(PhaseStep.UNTAP)
|
||||
|| game.getTurn().getStepType().equals(PhaseStep.UPKEEP)
|
||||
|| !game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResetReplacementEffect copy() {
|
||||
return new ResetReplacementEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,23 +28,17 @@
|
|||
package mage.sets.masterseditionii;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.condition.common.BeforeBlockersAreDeclaredCondition;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.combat.CantBlockTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
|
@ -58,14 +52,12 @@ public class Panic extends CardImpl {
|
|||
this.expansionSetCode = "ME2";
|
||||
|
||||
// Cast Panic only during combat before blockers are declared.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new PanicRuleModifyingEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, BeforeBlockersAreDeclaredCondition.getInstance()));
|
||||
|
||||
// Target creature can't block this turn.
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
this.getSpellAbility().addEffect(new CantBlockTargetEffect(Duration.EndOfTurn));
|
||||
|
||||
|
||||
// Draw a card at the beginning of the next turn's upkeep.
|
||||
this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(new DrawCardSourceControllerEffect(1)), false));
|
||||
}
|
||||
|
@ -79,42 +71,3 @@ public class Panic extends CardImpl {
|
|||
return new Panic(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PanicRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
PanicRuleModifyingEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during combat before blockers are declared";
|
||||
}
|
||||
|
||||
PanicRuleModifyingEffect(final PanicRuleModifyingEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.CAST_SPELL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
return !TurnPhase.COMBAT.equals(game.getTurn().getPhaseType()) ||
|
||||
game.getStep().getType().equals(PhaseStep.DECLARE_BLOCKERS) ||
|
||||
game.getStep().getType().equals(PhaseStep.FIRST_COMBAT_DAMAGE) ||
|
||||
game.getStep().getType().equals(PhaseStep.COMBAT_DAMAGE) ||
|
||||
game.getStep().getType().equals(PhaseStep.END_COMBAT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PanicRuleModifyingEffect copy() {
|
||||
return new PanicRuleModifyingEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,9 @@
|
|||
package mage.sets.masterseditioniv;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.condition.common.BeforeBlockersAreDeclaredCondition;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
|
@ -40,14 +39,9 @@ import mage.abilities.keyword.MenaceAbility;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -60,15 +54,13 @@ public class GorillaWarCry extends CardImpl {
|
|||
this.expansionSetCode = "ME4";
|
||||
|
||||
// Cast Gorilla War Cry only during combat before blockers are declared.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new GorillaWarCryRuleModifyingEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, BeforeBlockersAreDeclaredCondition.getInstance()));
|
||||
|
||||
// All creatures gain menace until end of turn. <i>(They can't be blocked except by two or more creatures.)</i>
|
||||
Effect effect = new GainAbilityAllEffect(new MenaceAbility(), Duration.EndOfTurn, new FilterCreaturePermanent());
|
||||
effect.setText("All creatures gain menace until end of turn. <i>(They can't be blocked except by two or more creatures.)</i>");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
|
||||
|
||||
// Draw a card at the beginning of the next turn's upkeep.
|
||||
this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(new DrawCardSourceControllerEffect(1)), false));
|
||||
}
|
||||
|
@ -82,43 +74,3 @@ public class GorillaWarCry extends CardImpl {
|
|||
return new GorillaWarCry(this);
|
||||
}
|
||||
}
|
||||
|
||||
class GorillaWarCryRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
GorillaWarCryRuleModifyingEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during combat before blockers are declared";
|
||||
}
|
||||
|
||||
GorillaWarCryRuleModifyingEffect(final GorillaWarCryRuleModifyingEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.CAST_SPELL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
return !TurnPhase.COMBAT.equals(game.getTurn().getPhaseType()) ||
|
||||
game.getStep().getType().equals(PhaseStep.DECLARE_BLOCKERS) ||
|
||||
game.getStep().getType().equals(PhaseStep.FIRST_COMBAT_DAMAGE) ||
|
||||
game.getStep().getType().equals(PhaseStep.COMBAT_DAMAGE) ||
|
||||
game.getStep().getType().equals(PhaseStep.END_COMBAT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GorillaWarCryRuleModifyingEffect copy() {
|
||||
return new GorillaWarCryRuleModifyingEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ package mage.sets.mirage;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.condition.common.AfterBlockersAreDeclaredCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
|
@ -40,12 +40,9 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
@ -61,14 +58,12 @@ public class Aleatory extends CardImpl {
|
|||
this.expansionSetCode = "MIR";
|
||||
|
||||
// Cast Aleatory only during combat after blockers are declared.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new AleatoryRuleModifyingEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, AfterBlockersAreDeclaredCondition.getInstance()));
|
||||
|
||||
// Flip a coin. If you win the flip, target creature gets +1/+1 until end of turn.
|
||||
this.getSpellAbility().addEffect(new AleatoryEffect());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
|
||||
|
||||
// Draw a card at the beginning of the next turn's upkeep.
|
||||
this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(new DrawCardSourceControllerEffect(1)), false));
|
||||
}
|
||||
|
@ -83,43 +78,6 @@ public class Aleatory extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class AleatoryRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
AleatoryRuleModifyingEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during combat after blockers are declared";
|
||||
}
|
||||
|
||||
AleatoryRuleModifyingEffect(final AleatoryRuleModifyingEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.CAST_SPELL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
return !game.getPhase().getType().equals(TurnPhase.COMBAT) ||
|
||||
game.getStep().getType().equals(PhaseStep.BEGIN_COMBAT) ||
|
||||
game.getStep().getType().equals(PhaseStep.DECLARE_ATTACKERS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AleatoryRuleModifyingEffect copy() {
|
||||
return new AleatoryRuleModifyingEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AleatoryEffect extends OneShotEffect {
|
||||
|
||||
public AleatoryEffect() {
|
||||
|
@ -139,8 +97,8 @@ class AleatoryEffect extends OneShotEffect {
|
|||
if (controller.flipCoin(game)) {
|
||||
game.addEffect(new BoostTargetEffect(1, 1, Duration.EndOfTurn), source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,25 +29,21 @@ package mage.sets.saviorsofkamigawa;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.condition.common.AfterBlockersAreDeclaredCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.AttackingPredicate;
|
||||
import mage.filter.predicate.permanent.BlockingPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
@ -59,25 +55,23 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
public class CurtainOfLight extends CardImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("unblocked attacking creature");
|
||||
|
||||
|
||||
static {
|
||||
filter.add(new AttackingPredicate());
|
||||
filter.add(Predicates.not(new BlockingPredicate()));
|
||||
}
|
||||
|
||||
|
||||
public CurtainOfLight(UUID ownerId) {
|
||||
super(ownerId, 6, "Curtain of Light", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{W}");
|
||||
this.expansionSetCode = "SOK";
|
||||
|
||||
// Cast Curtain of Light only during combat after blockers are declared.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new CurtainOfLightRuleModifyingEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, AfterBlockersAreDeclaredCondition.getInstance()));
|
||||
|
||||
// Target unblocked attacking creature becomes blocked.
|
||||
this.getSpellAbility().addEffect(new CurtainOfLightEffect());
|
||||
this.getSpellAbility().addEffect(new CurtainOfLightEffect());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
|
||||
|
||||
|
||||
// Draw a card.
|
||||
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
|
||||
}
|
||||
|
@ -92,59 +86,22 @@ public class CurtainOfLight extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class CurtainOfLightRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
CurtainOfLightRuleModifyingEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during combat after blockers are declared";
|
||||
}
|
||||
|
||||
CurtainOfLightRuleModifyingEffect(final CurtainOfLightRuleModifyingEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.CAST_SPELL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
return !game.getPhase().getType().equals(TurnPhase.COMBAT) ||
|
||||
game.getStep().getType().equals(PhaseStep.BEGIN_COMBAT) ||
|
||||
game.getStep().getType().equals(PhaseStep.DECLARE_ATTACKERS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurtainOfLightRuleModifyingEffect copy() {
|
||||
return new CurtainOfLightRuleModifyingEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class CurtainOfLightEffect extends OneShotEffect {
|
||||
|
||||
|
||||
public CurtainOfLightEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Target unblocked attacking creature becomes blocked";
|
||||
}
|
||||
|
||||
|
||||
public CurtainOfLightEffect(final CurtainOfLightEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CurtainOfLightEffect copy() {
|
||||
return new CurtainOfLightEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
|
|
@ -28,26 +28,15 @@
|
|||
package mage.sets.tempestremastered;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.PayLifeCost;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.condition.common.MyTurnCondition;
|
||||
import mage.abilities.costs.common.PayVariableLifeCost;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.GetXValue;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.LoseLifeOpponentsEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -60,13 +49,12 @@ public class Necrologia extends CardImpl {
|
|||
this.expansionSetCode = "TPR";
|
||||
|
||||
// Cast Necrologia only during your end step.
|
||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new NecrologiaTimingEffect());
|
||||
ability.setRuleAtTheTop(true);
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(null, PhaseStep.END_TURN, MyTurnCondition.getInstance(),
|
||||
"Cast {this} only during your end step"));
|
||||
|
||||
// As an additional cost to cast to Necrologia, pay X life.
|
||||
this.getSpellAbility().addCost(new PayVariableLifeCost(true));
|
||||
|
||||
|
||||
// Draw X cards.
|
||||
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(new GetXValue()));
|
||||
}
|
||||
|
@ -80,35 +68,3 @@ public class Necrologia extends CardImpl {
|
|||
return new Necrologia(this);
|
||||
}
|
||||
}
|
||||
|
||||
class NecrologiaTimingEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
NecrologiaTimingEffect() {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
staticText = "Cast {this} only during your end step";
|
||||
}
|
||||
|
||||
NecrologiaTimingEffect(final NecrologiaTimingEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(GameEvent.EventType.CAST_SPELL);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
if (!game.getActivePlayerId().equals(source.getControllerId()) || !PhaseStep.END_TURN.equals(game.getTurn().getStepType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NecrologiaTimingEffect copy() {
|
||||
return new NecrologiaTimingEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.effects.common.ruleModifying.CastOnlyDuringPhaseStepSourceEffect;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CastOnlyDuringPhaseStepSourceAbility extends SimpleStaticAbility {
|
||||
|
||||
public CastOnlyDuringPhaseStepSourceAbility(TurnPhase turnPhase) {
|
||||
this(turnPhase, null, null);
|
||||
}
|
||||
|
||||
public CastOnlyDuringPhaseStepSourceAbility(TurnPhase turnPhase, Condition condition) {
|
||||
this(turnPhase, null, condition);
|
||||
}
|
||||
|
||||
public CastOnlyDuringPhaseStepSourceAbility(PhaseStep phaseStep) {
|
||||
this(null, phaseStep, null);
|
||||
}
|
||||
|
||||
public CastOnlyDuringPhaseStepSourceAbility(PhaseStep phaseStep, Condition condition) {
|
||||
this(null, phaseStep, condition);
|
||||
}
|
||||
|
||||
public CastOnlyDuringPhaseStepSourceAbility(TurnPhase turnPhase, PhaseStep phaseStep, Condition condition) {
|
||||
this(turnPhase, phaseStep, condition, null);
|
||||
}
|
||||
|
||||
public CastOnlyDuringPhaseStepSourceAbility(TurnPhase turnPhase, PhaseStep phaseStep, Condition condition, String effectText) {
|
||||
super(Zone.BATTLEFIELD, new CastOnlyDuringPhaseStepSourceEffect(turnPhase, phaseStep, condition));
|
||||
this.setRuleAtTheTop(true);
|
||||
if (effectText != null) {
|
||||
getEffects().get(0).setText(effectText);
|
||||
}
|
||||
}
|
||||
|
||||
private CastOnlyDuringPhaseStepSourceAbility(final CastOnlyDuringPhaseStepSourceAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CastOnlyDuringPhaseStepSourceAbility copy() {
|
||||
return new CastOnlyDuringPhaseStepSourceAbility(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* This condtion does not check that the turnPhase is combat. You have to check
|
||||
* this if needed on another place.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AfterBlockersAreDeclaredCondition implements Condition {
|
||||
|
||||
private static final AfterBlockersAreDeclaredCondition fInstance = new AfterBlockersAreDeclaredCondition();
|
||||
|
||||
public static Condition getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return !(game.getStep().getType().equals(PhaseStep.BEGIN_COMBAT)
|
||||
|| game.getStep().getType().equals(PhaseStep.DECLARE_ATTACKERS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "after blockers are declared";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AfterUpkeepStepCondtion implements Condition {
|
||||
|
||||
private static final AfterUpkeepStepCondtion fInstance = new AfterUpkeepStepCondtion();
|
||||
|
||||
public static Condition getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return !(game.getStep().getType().equals(PhaseStep.UNTAP)
|
||||
|| game.getStep().getType().equals(PhaseStep.UPKEEP));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "after upkeep step";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class BeforeAttackersAreDeclaredCondition implements Condition {
|
||||
|
||||
private static final BeforeAttackersAreDeclaredCondition fInstance = new BeforeAttackersAreDeclaredCondition();
|
||||
|
||||
public static Condition getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return !game.getTurn().isDeclareAttackersStepStarted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "before attackers are declared";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* This condtion does not check that the turnPhase is combat. You have to check
|
||||
* this if needed on another place.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class BeforeBlockersAreDeclaredCondition implements Condition {
|
||||
|
||||
private static final BeforeBlockersAreDeclaredCondition fInstance = new BeforeBlockersAreDeclaredCondition();
|
||||
|
||||
public static Condition getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return !(game.getStep().getType().equals(PhaseStep.DECLARE_BLOCKERS)
|
||||
|| game.getStep().getType().equals(PhaseStep.FIRST_COMBAT_DAMAGE)
|
||||
|| game.getStep().getType().equals(PhaseStep.COMBAT_DAMAGE)
|
||||
|| game.getStep().getType().equals(PhaseStep.END_COMBAT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "before blockers are declared";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class OnOpponentsTurnCondition implements Condition {
|
||||
|
||||
private static final OnOpponentsTurnCondition fInstance = new OnOpponentsTurnCondition();
|
||||
|
||||
public static Condition getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return !game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "on an opponent's turn";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common.ruleModifying;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CastOnlyDuringPhaseStepSourceEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
private final TurnPhase turnPhase;
|
||||
private final PhaseStep phaseStep;
|
||||
private final Condition condition;
|
||||
|
||||
public CastOnlyDuringPhaseStepSourceEffect(TurnPhase turnPhase, PhaseStep phaseStep, Condition condition) {
|
||||
super(Duration.EndOfGame, Outcome.Detriment);
|
||||
this.turnPhase = turnPhase;
|
||||
this.phaseStep = phaseStep;
|
||||
this.condition = condition;
|
||||
setText();
|
||||
}
|
||||
|
||||
private CastOnlyDuringPhaseStepSourceEffect(final CastOnlyDuringPhaseStepSourceEffect effect) {
|
||||
super(effect);
|
||||
this.turnPhase = effect.turnPhase;
|
||||
this.phaseStep = effect.phaseStep;
|
||||
this.condition = effect.condition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return GameEvent.EventType.CAST_SPELL.equals(event.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
return (turnPhase == null || !game.getPhase().getType().equals(turnPhase))
|
||||
&& (phaseStep == null || !game.getTurn().getStepType().equals(phaseStep))
|
||||
&& (condition == null || !condition.apply(game, source));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CastOnlyDuringPhaseStepSourceEffect copy() {
|
||||
return new CastOnlyDuringPhaseStepSourceEffect(this);
|
||||
}
|
||||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("cast {this} only during ");
|
||||
if (turnPhase != null) {
|
||||
sb.append(turnPhase.toString());
|
||||
}
|
||||
if (phaseStep != null) {
|
||||
sb.append("the ").append(phaseStep.getStepText());
|
||||
}
|
||||
if (condition != null) {
|
||||
sb.append(" ").append(condition.toString());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue