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