Search in sources :

Example 1 with SaprolingBurstToken

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

the class SaprolingBurstDestroyEffect method apply.

@Override
@SuppressWarnings("unchecked")
public boolean apply(Game game, Ability source) {
    Token token = new SaprolingBurstToken(new MageObjectReference(source.getSourceObject(game), game));
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent != null) {
        Object object = game.getState().getValue(CardUtil.getCardZoneString("_tokensCreated", source.getSourceId(), game));
        Set<UUID> tokensCreated;
        if (object != null) {
            tokensCreated = (Set<UUID>) object;
        } else {
            tokensCreated = new HashSet<>();
        }
        for (UUID tokenId : token.getLastAddedTokenIds()) {
            tokensCreated.add(tokenId);
        }
        game.getState().setValue(CardUtil.getCardZoneString("_tokensCreated", source.getSourceId(), game), tokensCreated);
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) SaprolingBurstToken(mage.game.permanent.token.SaprolingBurstToken) Token(mage.game.permanent.token.Token) UUID(java.util.UUID) SaprolingBurstToken(mage.game.permanent.token.SaprolingBurstToken) MageObjectReference(mage.MageObjectReference)

Aggregations

UUID (java.util.UUID)1 MageObjectReference (mage.MageObjectReference)1 Permanent (mage.game.permanent.Permanent)1 SaprolingBurstToken (mage.game.permanent.token.SaprolingBurstToken)1 Token (mage.game.permanent.token.Token)1