Search in sources :

Example 36 with Token

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

the class GorMuldrakAmphinologistEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Map<UUID, Integer> creatureMap = new HashMap<>();
    game.getState().getPlayersInRange(source.getControllerId(), game).stream().forEach(uuid -> creatureMap.put(uuid, 0));
    game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game).stream().filter(Objects::nonNull).map(Controllable::getControllerId).forEach(uuid -> creatureMap.compute(uuid, CardUtil::setOrIncrementValue));
    int minValue = creatureMap.values().stream().mapToInt(x -> x).min().orElse(0);
    minValue = Math.max(minValue, 0);
    Token token = new SalamnderWarriorToken();
    for (Map.Entry<UUID, Integer> entry : creatureMap.entrySet()) {
        if (entry.getValue() > minValue) {
            continue;
        }
        token.putOntoBattlefield(1, game, source, entry.getKey());
    }
    return true;
}
Also used : HashMap(java.util.HashMap) SalamnderWarriorToken(mage.game.permanent.token.SalamnderWarriorToken) Objects(java.util.Objects) Token(mage.game.permanent.token.Token) SalamnderWarriorToken(mage.game.permanent.token.SalamnderWarriorToken) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map)

Example 37 with Token

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

the class HourOfNeedExileEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (UUID creatureId : getTargetPointer().getTargets(game, source)) {
            Permanent creature = game.getPermanent(creatureId);
            if (creature != null) {
                controller.moveCardToExileWithInfo(creature, null, null, source, game, Zone.BATTLEFIELD, true);
                Token token = new HourOfNeedSphinxToken();
                token.putOntoBattlefield(1, game, source, creature.getControllerId());
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) HourOfNeedSphinxToken(mage.game.permanent.token.HourOfNeedSphinxToken) HourOfNeedSphinxToken(mage.game.permanent.token.HourOfNeedSphinxToken) Token(mage.game.permanent.token.Token) UUID(java.util.UUID)

Example 38 with Token

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

the class HornetCannonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Token hornetToken = new HornetToken();
    hornetToken.putOntoBattlefield(1, game, source, source.getControllerId());
    for (UUID tokenId : hornetToken.getLastAddedTokenIds()) {
        Permanent tokenPermanent = game.getPermanent(tokenId);
        if (tokenPermanent != null) {
            DestroyTargetEffect destroyEffect = new DestroyTargetEffect(false);
            destroyEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(destroyEffect), source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) HornetToken(mage.game.permanent.token.HornetToken) HornetToken(mage.game.permanent.token.HornetToken) Token(mage.game.permanent.token.Token) UUID(java.util.UUID)

Example 39 with Token

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

the class MercurialTransformationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Token token;
    if (player.chooseUse(outcome, "1/1 Frog or 4/4 Octopus?", null, "Frog", "Octopus", source, game)) {
        token = new CreatureToken(1, 1).withColor("U").withSubType(SubType.FROG);
    } else {
        token = new CreatureToken(4, 4).withColor("U").withSubType(SubType.OCTOPUS);
    }
    game.addEffect(new BecomesCreatureTargetEffect(token, true, false, Duration.EndOfTurn), source);
    return true;
}
Also used : Player(mage.players.Player) BecomesCreatureTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect) CreatureToken(mage.game.permanent.token.custom.CreatureToken) Token(mage.game.permanent.token.Token) CreatureToken(mage.game.permanent.token.custom.CreatureToken)

Example 40 with Token

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

the class NotForgottenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card targetCard = game.getCard(source.getFirstTarget());
    if (controller != null && targetCard != null) {
        boolean onTop = controller.chooseUse(outcome, "Put " + targetCard.getName() + " on top of it's owners library (otherwise on bottom)?", source, game);
        boolean moved = controller.moveCardToLibraryWithInfo(targetCard, source, game, Zone.GRAVEYARD, onTop, true);
        if (moved) {
            Token token = new SpiritWhiteToken();
            token.putOntoBattlefield(1, game, source, source.getControllerId(), false, false);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) SpiritWhiteToken(mage.game.permanent.token.SpiritWhiteToken) SpiritWhiteToken(mage.game.permanent.token.SpiritWhiteToken) Token(mage.game.permanent.token.Token) Card(mage.cards.Card)

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