Search in sources :

Example 11 with EmptyToken

use of mage.game.permanent.token.EmptyToken in project mage by magefree.

the class SpittingImageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (permanent == null) {
        permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
    }
    if (permanent != null) {
        EmptyToken token = new EmptyToken();
        CardUtil.copyTo(token).from(permanent, game);
        token.putOntoBattlefield(1, game, source, source.getControllerId());
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) EmptyToken(mage.game.permanent.token.EmptyToken)

Example 12 with EmptyToken

use of mage.game.permanent.token.EmptyToken in project mage by magefree.

the class GodPharaohsGiftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller == null || sourceObject == null) {
        return false;
    }
    TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD, true);
    controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game);
    Card cardChosen = game.getCard(target.getFirstTarget());
    if (cardChosen == null || !controller.moveCards(cardChosen, Zone.EXILED, source, game)) {
        return false;
    }
    // create token and modify all attributes permanently (without game usage)
    EmptyToken token = new EmptyToken();
    CardUtil.copyTo(token).from(cardChosen, game);
    token.removePTCDA();
    token.getPower().modifyBaseValue(4);
    token.getToughness().modifyBaseValue(4);
    token.getColor().setColor(ObjectColor.BLACK);
    token.removeAllCreatureTypes();
    token.addSubType(SubType.ZOMBIE);
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
    if (!permanents.isEmpty()) {
        game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(permanents, game)), source);
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Card(mage.cards.Card) EmptyToken(mage.game.permanent.token.EmptyToken)

Example 13 with EmptyToken

use of mage.game.permanent.token.EmptyToken in project mage by magefree.

the class PhantomSteedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ExileZone exileZone = game.getState().getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    if (exileZone == null || exileZone.isEmpty()) {
        return false;
    }
    for (Card card : exileZone.getCards(game)) {
        EmptyToken token = new EmptyToken();
        CardUtil.copyTo(token).from(card, game);
        token.addSubType(SubType.ILLUSION);
        token.putOntoBattlefield(1, game, source, source.getControllerId(), true, true);
        List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
        game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(new ExileTargetEffect("Sacrifice that token at end of combat").setTargetPointer(new FixedTargets(permanents, game))), source);
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) FixedTargets(mage.target.targetpointer.FixedTargets) ExileZone(mage.game.ExileZone) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) Card(mage.cards.Card) EmptyToken(mage.game.permanent.token.EmptyToken) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Aggregations

EmptyToken (mage.game.permanent.token.EmptyToken)13 Card (mage.cards.Card)9 Permanent (mage.game.permanent.Permanent)8 Player (mage.players.Player)6 MageObject (mage.MageObject)3 TargetPermanent (mage.target.TargetPermanent)3 HashSet (java.util.HashSet)2 UUID (java.util.UUID)2 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)2 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)2 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 FixedTargets (mage.target.targetpointer.FixedTargets)2 CopyApplier (mage.util.functions.CopyApplier)2 EmptyCopyApplier (mage.util.functions.EmptyCopyApplier)2 HashMap (java.util.HashMap)1 MageObjectReference (mage.MageObjectReference)1 Ability (mage.abilities.Ability)1 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)1