@Override public boolean apply(Game game, Ability source) { if (condition.apply(game, source)) { effect.setTargetPointer(this.targetPointer); return effect.apply(game, source); } else if (otherwiseEffect == null) { return true; // nothing to do - no problem } otherwiseEffect.setTargetPointer(this.targetPointer); return otherwiseEffect.apply(game, source); }
public ConditionalOneShotEffect(OneShotEffect effect, OneShotEffect otherwiseEffect, Condition condition, String text) { super(effect.getOutcome()); this.effect = effect; this.otherwiseEffect = otherwiseEffect; this.condition = condition; this.staticText = text; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); MageObject mageObject = game.getObject(source.getSourceId()); if (player != null && mageObject != null) { String message = userMessage; if (message == null) { message = getCostText() + " to prevent " + executingEffect.getText(source.getModes().getMode()) + '?'; } message = CardUtil.replaceSourceName(message, mageObject.getLogName()); cost.clearPaid(); if (cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(executingEffect.getOutcome(), message, source, game)) { cost.pay(source, game, source.getSourceId(), player.getId(), false, null); } if (!cost.isPaid()) { executingEffect.setTargetPointer(this.targetPointer); return executingEffect.apply(game, source); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent krovikanVampire = game.getPermanent(source.getSourceId()); creaturesAffected = (Set<UUID>) game.getState().getValue(source.getSourceId() + "creatureToGainControl"); if (creaturesAffected != null && controller != null && krovikanVampire != null) { for (UUID creatureId : creaturesAffected) { controller.moveCards(game.getCard(creatureId), Zone.BATTLEFIELD, source, game, false, false, false, null); OneShotEffect effect = new SacrificeTargetEffect(); effect.setText("Sacrifice this if Krovikan Vampire leaves the battlefield or its current controller loses control of it."); effect.setTargetPointer(new FixedTarget(creatureId)); KrovikanVampireDelayedTriggeredAbility dTA = new KrovikanVampireDelayedTriggeredAbility(effect, krovikanVampire.getId()); game.addDelayedTriggeredAbility(dTA, source); } creaturesAffected.clear(); return true; } return false; }
@Override public String getText(Mode mode) { if (staticText != null && !staticText.isEmpty()) { return staticText; } if (otherwiseEffect == null) { return "if " + condition.toString() + ", " + effect.getText(mode); } return effect.getText(mode) + ". If " + condition.toString() + ", " + otherwiseEffect.getText(mode); }
public EnshroudingMist(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{W}"); // Target creature gets +1/+1 until end of turn. Prevent all damage that would dealt to it this turn. If it's renowned, untap it. this.getSpellAbility().addEffect(new BoostTargetEffect(1, 1, Duration.EndOfTurn)); Effect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, Integer.MAX_VALUE); effect.setText("Prevent all damage that would dealt to it this turn"); this.getSpellAbility().addEffect(effect); OneShotEffect effect2 = new UntapTargetEffect(); effect2.setText("untap it"); this.getSpellAbility().addEffect(new ConditionalOneShotEffect(effect2, RenownedTargetCondition.instance)); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Card creatureCard = game.getCard(targetPointer.getFirst(game, source)); if (controller != null && creatureCard != null && game.getState().getZone(creatureCard.getId()) == Zone.GRAVEYARD) { // must be still in the graveyard controller.moveCards(creatureCard, Zone.BATTLEFIELD, source, game, false, false, false, null); OneShotEffect effect = new SacrificeTargetEffect(); effect.setText("Sacrifice this if Seraph leaves the battlefield or its current controller loses control of it."); effect.setTargetPointer(new FixedTarget(creatureCard.getId())); SeraphDelayedTriggeredAbility dTA = new SeraphDelayedTriggeredAbility(effect, source.getSourceId()); game.addDelayedTriggeredAbility(dTA, source); return true; } return false; }
@Override public String getText(Mode mode) { if (!staticText.isEmpty()) { return staticText; } return executingEffect.getText(mode) + "unless they" + getCostText(); }
public MaskedAdmirers(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{G}"); this.subtype.add(SubType.ELF); this.subtype.add(SubType.SHAMAN); this.power = new MageInt(3); this.toughness = new MageInt(2); // When Masked Admirers enters the battlefield, draw a card. this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1), false)); // Whenever you cast a creature spell, you may pay {G}{G}. If you do, return Masked Admirers from your graveyard to your hand. OneShotEffect effect = new ReturnToHandSourceEffect(); effect.setText("return {this} from your graveyard to your hand"); this.addAbility(new SpellCastControllerTriggeredAbility( Zone.GRAVEYARD, new DoIfCostPaid(effect, new ManaCostsImpl("{G}{G}")), StaticFilters.FILTER_SPELL_A_CREATURE, false, false)); }
@Override public String getText(Mode mode) { return new StringBuilder(super.getText(mode)).append(kinshipEffects.getText(mode)).toString(); }
public DoUnlessTargetPaysCost(final DoUnlessTargetPaysCost effect) { super(effect); this.executingEffect = (OneShotEffect) effect.executingEffect.copy(); this.cost = effect.cost.copy(); this.userMessage = effect.userMessage; }
public NumotTheDevastator(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{R}{W}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.DRAGON); this.power = new MageInt(6); this.toughness = new MageInt(6); // Flying this.addAbility(FlyingAbility.getInstance()); // Whenever Numot, the Devastator deals combat damage to a player, you may pay {2}{R}. If you do, destroy up to two target lands. OneShotEffect effect = new DestroyTargetEffect(); effect.setText("destroy up to two target lands"); Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility( new DoIfCostPaid(effect, new ManaCostsImpl("{2}{R}")), false); ability.addTarget(new TargetLandPermanent(0, 2, StaticFilters.FILTER_LANDS, false)); this.addAbility(ability); }