Search in sources :

Example 11 with CommandObject

use of mage.game.command.CommandObject in project mage by magefree.

the class SystemUtil method putPlaneToGame.

public static boolean putPlaneToGame(Game game, Player player, String planeClassName) {
    // remove the last plane and set its effects to discarded
    for (CommandObject comObject : game.getState().getCommand()) {
        if (comObject instanceof Plane) {
            if (comObject.getAbilities() != null) {
                for (Ability ability : comObject.getAbilities()) {
                    for (Effect effect : ability.getEffects()) {
                        if (effect instanceof ContinuousEffect) {
                            ((ContinuousEffect) effect).discard();
                        }
                    }
                }
            }
            game.getState().removeTriggersOfSourceId(comObject.getId());
            game.getState().getCommand().remove(comObject);
            break;
        }
    }
    // put new plane to game
    Planes planeType = Planes.fromClassName(planeClassName);
    Plane plane = Plane.createPlane(planeType);
    if (plane != null) {
        plane.setControllerId(player.getId());
        game.addPlane(plane, null, player.getId());
        return true;
    }
    return false;
}
Also used : CommandObject(mage.game.command.CommandObject) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) ActivatedAbility(mage.abilities.ActivatedAbility) Ability(mage.abilities.Ability) Planes(mage.constants.Planes) Plane(mage.game.command.Plane) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) InfoEffect(mage.abilities.effects.common.InfoEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Aggregations

CommandObject (mage.game.command.CommandObject)11 StackObject (mage.game.stack.StackObject)6 Spell (mage.game.stack.Spell)5 Player (mage.players.Player)5 MageObject (mage.MageObject)4 Card (mage.cards.Card)4 Permanent (mage.game.permanent.Permanent)4 Ability (mage.abilities.Ability)3 TargetCard (mage.target.TargetCard)3 UUID (java.util.UUID)2 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 Effect (mage.abilities.effects.Effect)2 FilterCard (mage.filter.FilterCard)2 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)2 Commander (mage.game.command.Commander)2 Plane (mage.game.command.Plane)2 MatchPlayer (mage.game.match.MatchPlayer)2 PermanentCard (mage.game.permanent.PermanentCard)2 SquirrelToken (mage.game.permanent.token.SquirrelToken)2 List (java.util.List)1