Search in sources :

Example 1 with ElephantToken

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

the class TerastodonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Map<UUID, Integer> destroyedPermanents = new HashMap<>();
    for (UUID targetID : this.targetPointer.getTargets(game, source)) {
        Permanent permanent = game.getPermanent(targetID);
        if (permanent != null) {
            if (permanent.destroy(source, game, false)) {
                if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) {
                    int numberPermanents = destroyedPermanents.getOrDefault(permanent.getControllerId(), 0);
                    destroyedPermanents.put(permanent.getControllerId(), numberPermanents + 1);
                }
            }
        }
    }
    game.getState().processAction(game);
    ElephantToken elephantToken = new ElephantToken();
    for (Entry<UUID, Integer> entry : destroyedPermanents.entrySet()) {
        elephantToken.putOntoBattlefield(entry.getValue(), game, source, entry.getKey());
    }
    return true;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) HashMap(java.util.HashMap) ElephantToken(mage.game.permanent.token.ElephantToken) UUID(java.util.UUID)

Example 2 with ElephantToken

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

the class GenerousGiftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent == null) {
        return false;
    }
    Player player = game.getPlayer(permanent.getControllerId());
    permanent.destroy(source, game, false);
    if (player == null) {
        return false;
    }
    Effect effect = new CreateTokenTargetEffect(new ElephantToken());
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) ElephantToken(mage.game.permanent.token.ElephantToken) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect)

Aggregations

Permanent (mage.game.permanent.Permanent)2 ElephantToken (mage.game.permanent.token.ElephantToken)2 TargetPermanent (mage.target.TargetPermanent)2 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 CreateTokenTargetEffect (mage.abilities.effects.common.CreateTokenTargetEffect)1 FilterPermanent (mage.filter.FilterPermanent)1 Player (mage.players.Player)1 FixedTarget (mage.target.targetpointer.FixedTarget)1