@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); Permanent targetCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (targetCreature != null && permanent != null) { Permanent blueprintPermanent = game.copyPermanent( Duration.Custom, targetCreature, permanent.getId(), source, new EmptyApplyToPermanent()); blueprintPermanent.addAbility( new EntersBattlefieldAllTriggeredAbility( Zone.BATTLEFIELD, new UnstableShapeshifterEffect(), filterAnotherCreature, false, SetTargetPointer.PERMANENT, ""), game); return true; } return false; }
@java.lang.Override public boolean apply(Game game, Ability source) { Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourceObject != null) { // create cost for sacrificing an artifact Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); // if they can pay the cost, then they must pay if (target.canChoose(source.getSourceId(), controller.getId(), game)) { controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game); Permanent artifactSacrifice = game.getPermanent(target.getFirstTarget()); if (artifactSacrifice != null) { // sacrifice the chosen artifact artifactSacrifice.sacrifice(source.getSourceId(), game); } } else { sourceObject.tap(game); controller.damage(4, source.getSourceId(), game, false, true); } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); Permanent sourceObject = game.getPermanent(source.getSourceId()); if (permanent != null && sourceObject != null) { PutTokenOntoBattlefieldCopyTargetEffect effect = new PutTokenOntoBattlefieldCopyTargetEffect(); effect.setTargetPointer(new FixedTarget(permanent, game)); effect.apply(game, source); game.getState().setValue(source.getSourceId() + "_token", effect.getAddedPermanent()); for (Permanent addedToken : effect.getAddedPermanent()) { Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice Dance of Many"); sacrificeEffect.setTargetPointer(new FixedTarget(sourceObject, game)); LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(sacrificeEffect, false); ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.WhileOnBattlefield); continuousEffect.setTargetPointer(new FixedTarget(addedToken, game)); game.addEffect(continuousEffect, source); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller != null && permanent != null && sourcePermanent != null) { CopyEffect copyEffect = new CopyEffect(Duration.EndOfTurn, permanent, source.getSourceId()); if (controller.moveCardToExileWithInfo( permanent, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) { // Copy exiled permanent game.addEffect(copyEffect, source); // Create delayed triggered ability AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility( new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD, false)); delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setControllerId(source.getControllerId()); delayedAbility.setSourceObject(source.getSourceObject(game), game); game.addDelayedTriggeredAbility(delayedAbility); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player opponent = game.getPlayer(source.getFirstTarget()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller != null && opponent != null && sourcePermanent != null) { opponent.revealCards(sourcePermanent.getName(), opponent.getHand(), game); TargetCard target = new TargetCard(Zone.PICK, new FilterNonlandCard("nonland card to exile")); if (controller.choose(Outcome.Exile, opponent.getHand(), target, game)) { Card card = opponent.getHand().get(target.getFirstTarget(), game); if (card != null) { controller.moveCardToExileWithInfo( card, CardUtil.getCardExileZoneId(game, source), sourcePermanent.getName(), source.getSourceId(), game, Zone.HAND); } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller == null || sourcePermanent == null) { return false; } for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); String playerName = new StringBuilder(player.getLogName()).append("'s").toString(); if (source.getControllerId().equals(player.getId())) { playerName = "your"; } TargetCardInLibrary target = new TargetCardInLibrary( new FilterNonlandCard( new StringBuilder("nonland card from ") .append(playerName) .append(" library") .toString())); if (controller.searchLibrary(target, game, playerId)) { UUID targetId = target.getFirstTarget(); Card card = player.getLibrary().remove(targetId, game); if (card != null) { controller.moveCardToExileWithInfo( card, CardUtil.getCardExileZoneId(game, source), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true); } } player.shuffleLibrary(game); } ExileZone jaceExileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)); if (jaceExileZone == null) { return true; } FilterCard filter = new FilterCard("card to cast without mana costs"); TargetCardInExile target = new TargetCardInExile(filter, source.getSourceId()); while (jaceExileZone.count(filter, game) > 0 && controller.choose(Outcome.PlayForFree, jaceExileZone, target, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { if (controller.cast(card.getSpellAbility(), game, true)) { game.getExile().removeCard(card, game); } } target.clearChosen(); } return true; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (controller != null && permanent != null) { controller.gainLife(permanent.getToughness().getValue(), game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent targetCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (targetCreature != null) { if (targetCreature.getCounters().containsKey(CounterType.P1P1)) { new CreateTokenEffect(new SnakeToken("KTK")).apply(game, source); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { Player controller = game.getPlayer(permanent.getControllerId()); if (controller != null) { int amount = permanent.getPower().getValue(); controller.damage(amount, source.getSourceId(), game, false, true); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller == null || sourcePermanent == null) { return false; } int highCMC = 0; List<Permanent> controlledArtifacts = game.getBattlefield() .getAllActivePermanents(new FilterArtifactPermanent(), controller.getId(), game); for (Permanent permanent : controlledArtifacts) { if (permanent.getSpellAbility() != null) { int cmc = permanent.getSpellAbility().getManaCosts().convertedManaCost(); if (cmc > highCMC) { highCMC = cmc; } } } Cards cards = new CardsImpl(); for (int i = 0; i < highCMC; i++) { Card card = controller.getLibrary().removeFromTop(game); if (card != null) { cards.add(card); } } controller.lookAtCards(sourcePermanent.getIdName(), cards, game); if (!cards.isEmpty()) { TargetCard target = new TargetCard( Zone.LIBRARY, new FilterArtifactCard("artifact card to put onto the battlefield")); if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.Benefit, cards, target, game)) { Card card = cards.get(target.getFirstTarget(), game); if (card != null) { controller.revealCards(sourcePermanent.getIdName(), new CardsImpl(card), game); cards.remove(card); controller.moveCards(card, Zone.BATTLEFIELD, source, game); } } } controller.putCardsOnBottomOfLibrary(cards, game, source, true); return true; }
@Override public boolean apply(Game game, Ability source) { Permanent triggeringCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (triggeringCreature != null) { Permanent sourceCreature = game.getPermanent(source.getSourceId()); if (sourceCreature != null && EvolveAbility.isPowerOrThoughnessGreater(sourceCreature, triggeringCreature)) { game.getState().setValue("EvolveAddCounterActive", Boolean.TRUE); sourceCreature.addCounters(CounterType.P1P1.createInstance(), game); game.getState().setValue("EvolveAddCounterActive", Boolean.FALSE); } return true; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId()); if (sourcePermanent != null && sourcePermanent.getAttachedTo() != null) { Permanent attachedTo = game.getPermanent(sourcePermanent.getAttachedTo()); if (attachedTo != null) { for (Effect effect : getEffects()) { effect.setTargetPointer( new FixedTarget(attachedTo.getId(), attachedTo.getZoneChangeCounter(game))); } } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get("DragonOnTheBattlefieldWhileSpellWasCastWatcher"); if (watcher != null && watcher.castWithConditionTrue(source.getId())) { Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { player.damage(3, source.getSourceId(), game, false, true); } } } return true; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent enchantment = game.getPermanent(sourceId); UUID targetId = event.getTargetId(); if (enchantment != null && enchantment.getAttachedTo() != null && targetId.equals(enchantment.getAttachedTo())) { for (Effect effect : this.getEffects()) { effect.setValue("damage", event.getAmount()); switch (setTargetPointer) { case PERMANENT: effect.setTargetPointer(new FixedTarget(targetId)); break; case PLAYER: effect.setTargetPointer( new FixedTarget(game.getPermanentOrLKIBattlefield(targetId).getControllerId())); break; } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); Permanent eyeOfTheStorm = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (spell != null && eyeOfTheStorm != null) { Player spellController = game.getPlayer(spell.getControllerId()); Card card = spell.getCard(); if (spellController == null || card == null || !instantOrSorceryfilter.match(card, game)) { return false; } UUID exileZoneId = CardUtil.getExileZoneId( game, source.getSourceId(), eyeOfTheStorm.getZoneChangeCounter(game)); if (spellController.moveCardsToExile( spell, source, game, true, exileZoneId, eyeOfTheStorm.getIdName())) { eyeOfTheStorm.imprint(card.getId(), game); if (eyeOfTheStorm.getImprinted() != null && eyeOfTheStorm.getImprinted().size() > 0) { CardsImpl copiedCards = new CardsImpl(); for (UUID uuid : eyeOfTheStorm.getImprinted()) { card = game.getCard(uuid); // Check if owner of card is still in game if (card != null && game.getPlayer(card.getOwnerId()) != null) { if (card.isSplitCard()) { copiedCards.add(((SplitCard) card).getLeftHalfCard()); copiedCards.add(((SplitCard) card).getRightHalfCard()); } else { copiedCards.add(card); } } } boolean continueCasting = true; while (continueCasting) { continueCasting = copiedCards.size() > 1 && spellController.chooseUse( outcome, "Cast one of the copied cards without paying its mana cost?", source, game); Card cardToCopy; if (copiedCards.size() == 1) { cardToCopy = copiedCards.getCards(game).iterator().next(); } else { TargetCard target = new TargetCard(1, Zone.EXILED, new FilterCard("card to copy")); spellController.choose(Outcome.Copy, copiedCards, target, game); cardToCopy = copiedCards.get(target.getFirstTarget(), game); copiedCards.remove(cardToCopy); } if (cardToCopy != null) { Card copy = game.copyCard(cardToCopy, source, source.getControllerId()); if (spellController.chooseUse( outcome, "Cast the copied card without paying mana cost?", source, game)) { spellController.cast(copy.getSpellAbility(), game, true); } } } return true; } } } return false; }