Search in sources :

Example 1 with KaldraToken

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

the class HelmOfKaldraEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (new HelmOfKaldraCondition().apply(game, source)) {
        CreateTokenEffect effect = new CreateTokenEffect(new KaldraToken());
        effect.apply(game, source);
        for (UUID tokenId : effect.getLastAddedTokenIds()) {
            Permanent kaldra = game.getPermanent(tokenId);
            if (kaldra != null) {
                // Attach helm to the token
                for (Permanent kaldrasHelm : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterHelm, source.getControllerId(), game)) {
                    kaldra.addAttachment(kaldrasHelm.getId(), source, game);
                    break;
                }
                // Attach shield to the token
                for (Permanent kaldrasShield : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterShield, source.getControllerId(), game)) {
                    kaldra.addAttachment(kaldrasShield.getId(), source, game);
                    break;
                }
                // Attach sword to the token
                for (Permanent kaldrasSword : game.getBattlefield().getAllActivePermanents(HelmOfKaldra.filterSword, source.getControllerId(), game)) {
                    kaldra.addAttachment(kaldrasSword.getId(), source, game);
                    break;
                }
            }
            return true;
        }
    }
    return false;
}
Also used : KaldraToken(mage.game.permanent.token.KaldraToken) FilterControlledArtifactPermanent(mage.filter.common.FilterControlledArtifactPermanent) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 FilterControlledArtifactPermanent (mage.filter.common.FilterControlledArtifactPermanent)1 Permanent (mage.game.permanent.Permanent)1 KaldraToken (mage.game.permanent.token.KaldraToken)1