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;
}
Aggregations