* Commander - added logic that AI can cast the commander.

This commit is contained in:
LevelX2 2013-12-12 19:45:14 +01:00
parent 7bcae07277
commit cc35bbcf52

View file

@ -93,6 +93,7 @@ import mage.game.ExileZone;
import mage.game.Game;
import mage.game.Table;
import mage.game.combat.CombatGroup;
import mage.game.command.Commander;
import mage.game.events.DamagePlayerEvent;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
@ -1804,6 +1805,20 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
}
}
}
// get cast commander if available
if (!(this.getCommanderId() == null)) {
Zone zone = game.getState().getZone(this.getCommanderId());
if (zone != null && zone.equals(Zone.COMMAND)) {
MageObject object = game.getObject(this.getCommanderId());
if (object != null) {
for (ActivatedAbility ability : ((Commander) object).getAbilities().getActivatedAbilities(Zone.COMMAND)) {
if (canPlay(ability, available, game)) {
playableActivated.put(ability.toString(), ability);
}
}
}
}
}
playable.addAll(playableActivated.values());
return playable;
}