Search in sources :

Example 1 with Planes

use of mage.constants.Planes in project mage by magefree.

the class Plane method createRandomPlane.

public static Plane createRandomPlane() {
    int pick = RandomUtil.nextInt(Planes.values().length);
    Planes planeType = Planes.values()[pick];
    return createPlane(planeType);
}
Also used : Planes(mage.constants.Planes)

Example 2 with Planes

use of mage.constants.Planes 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

Planes (mage.constants.Planes)2 Ability (mage.abilities.Ability)1 ActivatedAbility (mage.abilities.ActivatedAbility)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 Effect (mage.abilities.effects.Effect)1 InfoEffect (mage.abilities.effects.common.InfoEffect)1 CommandObject (mage.game.command.CommandObject)1 Plane (mage.game.command.Plane)1