Search in sources :

Example 1 with CatSoldierCreatureToken

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

the class BrimazKingOfOreskosEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Token token = new CatSoldierCreatureToken();
        token.putOntoBattlefield(1, game, source, source.getControllerId());
        Permanent attackingCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (attackingCreature != null && game.getState().getCombat() != null) {
            // Possible ruling (see Aetherplasm)
            // The token you created is blocking the attacking creature,
            // even if the block couldn't legally be declared (for example, if that creature
            // enters the battlefield tapped, or it can't block, or the attacking creature
            // has protection from it)
            CombatGroup combatGroup = game.getState().getCombat().findGroup(attackingCreature.getId());
            if (combatGroup != null) {
                for (UUID tokenId : token.getLastAddedTokenIds()) {
                    Permanent catToken = game.getPermanent(tokenId);
                    if (catToken != null) {
                        combatGroup.addBlocker(tokenId, source.getControllerId(), game);
                        game.getCombat().addBlockingGroup(tokenId, attackingCreature.getId(), controller.getId(), game);
                    }
                }
                combatGroup.pickBlockerOrder(attackingCreature.getControllerId(), game);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) Token(mage.game.permanent.token.Token) CatSoldierCreatureToken(mage.game.permanent.token.CatSoldierCreatureToken) UUID(java.util.UUID) CombatGroup(mage.game.combat.CombatGroup) CatSoldierCreatureToken(mage.game.permanent.token.CatSoldierCreatureToken)

Aggregations

UUID (java.util.UUID)1 CombatGroup (mage.game.combat.CombatGroup)1 Permanent (mage.game.permanent.Permanent)1 CatSoldierCreatureToken (mage.game.permanent.token.CatSoldierCreatureToken)1 Token (mage.game.permanent.token.Token)1 Player (mage.players.Player)1