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