Search in sources :

Example 56 with Token

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

the class DivineVisitationEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    if (event instanceof CreateTokenEvent) {
        int amount = 0;
        CreateTokenEvent tokenEvent = (CreateTokenEvent) event;
        Iterator<Map.Entry<Token, Integer>> it = tokenEvent.getTokens().entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<Token, Integer> entry = it.next();
            if (entry.getKey().isCreature(game)) {
                amount += entry.getValue();
                it.remove();
            }
        }
        if (amount > 0) {
            tokenEvent.getTokens().put(new AngelVigilanceToken(), amount);
        }
    }
    return false;
}
Also used : Token(mage.game.permanent.token.Token) AngelVigilanceToken(mage.game.permanent.token.AngelVigilanceToken) AngelVigilanceToken(mage.game.permanent.token.AngelVigilanceToken) Map(java.util.Map) CreateTokenEvent(mage.game.events.CreateTokenEvent)

Example 57 with Token

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

the class EiganjoUprisingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int amount = source.getManaCostsToPay().getX();
    if (amount < 1) {
        return false;
    }
    Token token = new SamuraiToken();
    token.putOntoBattlefield(amount, game, source);
    game.addEffect(new GainAbilityTargetEffect(new MenaceAbility(false)).setTargetPointer(new FixedTargets(token, game)), source);
    game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance()).setTargetPointer(new FixedTargets(token, game)), source);
    if (amount < 2) {
        return true;
    }
    for (UUID opponentId : game.getOpponents(source.getControllerId())) {
        token.putOntoBattlefield(amount - 1, game, source, opponentId);
    }
    return true;
}
Also used : MenaceAbility(mage.abilities.keyword.MenaceAbility) FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) SamuraiToken(mage.game.permanent.token.SamuraiToken) Token(mage.game.permanent.token.Token) SamuraiToken(mage.game.permanent.token.SamuraiToken) UUID(java.util.UUID)

Example 58 with Token

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

the class SpyMasterGoblinCreateTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    if (player != null) {
        Token token = new SpyMasterGoblinToken();
        token.putOntoBattlefield(1, game, source, player.getId());
    }
    return true;
}
Also used : Player(mage.players.Player) Token(mage.game.permanent.token.Token) SpyMasterGoblinToken(mage.game.permanent.token.SpyMasterGoblinToken) SpyMasterGoblinToken(mage.game.permanent.token.SpyMasterGoblinToken)

Example 59 with Token

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

the class PurphorossInterventionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new PurphorossInterventionToken(source.getManaCostsToPay().getX());
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    token.getLastAddedTokenIds().stream().forEach(uuid -> game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeTargetEffect().setText("sacrifice this creature").setTargetPointer(new FixedTarget(uuid, game))), source));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) PurphorossInterventionToken(mage.game.permanent.token.PurphorossInterventionToken) PurphorossInterventionToken(mage.game.permanent.token.PurphorossInterventionToken) Token(mage.game.permanent.token.Token) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect)

Example 60 with Token

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

the class RebellionOfTheFlamekinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token token = new ElementalShamanToken("LRW");
    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() && (boolean) this.getValue("clash")) {
        game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(new FixedTargets(permanents, game)), source);
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ElementalShamanToken(mage.game.permanent.token.ElementalShamanToken) Token(mage.game.permanent.token.Token) ElementalShamanToken(mage.game.permanent.token.ElementalShamanToken)

Aggregations

Token (mage.game.permanent.token.Token)68 Permanent (mage.game.permanent.Permanent)30 Player (mage.players.Player)29 UUID (java.util.UUID)28 FixedTargets (mage.target.targetpointer.FixedTargets)9 Map (java.util.Map)7 Effect (mage.abilities.effects.Effect)6 OneShotEffect (mage.abilities.effects.OneShotEffect)6 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)6 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)6 FixedTarget (mage.target.targetpointer.FixedTarget)6 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)5 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)5 TargetPermanent (mage.target.TargetPermanent)5 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5 FilterPermanent (mage.filter.FilterPermanent)4 CreateTokenEvent (mage.game.events.CreateTokenEvent)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Objects (java.util.Objects)3