use of mage.abilities.common.PlayLandAsCommanderAbility in project mage by magefree.
the class PlayerImpl method activateAbility.
@Override
public boolean activateAbility(ActivatedAbility ability, Game game) {
if (ability == null) {
return false;
}
boolean result;
if (ability instanceof PassAbility) {
pass(game);
return true;
}
Card card = game.getCard(ability.getSourceId());
if (ability instanceof PlayLandAsCommanderAbility) {
// LAND as commander: play land with cost, but without stack
ActivationStatus activationStatus = ability.canActivate(this.playerId, game);
if (!activationStatus.canActivate() || !this.canPlayLand()) {
return false;
}
if (card == null) {
return false;
}
// as copy, tries to applie cost effects and pays
Ability activatingAbility = ability.copy();
if (activatingAbility.activate(game, false)) {
result = playLand(card, game, false);
} else {
result = false;
}
} else if (ability instanceof PlayLandAbility) {
// LAND as normal card: without cost and stack
result = playLand(card, game, false);
} else {
// ABILITY
ActivationStatus activationStatus = ability.canActivate(this.playerId, game);
if (!activationStatus.canActivate()) {
return false;
}
switch(ability.getAbilityType()) {
case SPECIAL_ACTION:
result = specialAction((SpecialAction) ability.copy(), game);
break;
case SPECIAL_MANA_PAYMENT:
result = specialManaPayment((SpecialAction) ability.copy(), game);
break;
case MANA:
result = playManaAbility((ActivatedManaAbilityImpl) ability.copy(), game);
break;
case SPELL:
result = cast((SpellAbility) ability, game, false, activationStatus.getApprovingObject());
break;
default:
result = playAbility(ability.copy(), game);
break;
}
}
// if player has taken an action then reset all player passed flags
justActivatedType = null;
if (result) {
if (isHuman() && (ability.getAbilityType() == AbilityType.SPELL || ability.getAbilityType() == AbilityType.ACTIVATED)) {
if (ability.isUsesStack()) {
// if the ability does not use the stack (e.g. Suspend) auto pass would go to next phase unintended
setJustActivatedType(ability.getAbilityType());
}
}
game.getPlayers().resetPassed();
}
return result;
}
Aggregations