use of mage.abilities.mana.DelayedTriggeredManaAbility in project mage by magefree.
the class GameImpl method addTriggeredAbility.
/**
* For internal use only
*
* @param ability
* @param triggeringEvent
*/
@Override
public void addTriggeredAbility(TriggeredAbility ability, GameEvent triggeringEvent) {
if (ability.getControllerId() == null) {
String sourceName = "no sourceId";
if (ability.getSourceId() != null) {
MageObject mageObject = getObject(ability.getSourceId());
if (mageObject != null) {
sourceName = mageObject.getName();
}
}
logger.fatal("Added triggered ability without controller: " + sourceName + " rule: " + ability.getRule());
return;
}
if (ability instanceof TriggeredManaAbility || ability instanceof DelayedTriggeredManaAbility) {
// 20110715 - 605.4
Ability manaAbiltiy = ability.copy();
if (manaAbiltiy.getSourceObjectZoneChangeCounter() == 0) {
manaAbiltiy.setSourceObjectZoneChangeCounter(getState().getZoneChangeCounter(ability.getSourceId()));
}
manaAbiltiy.activate(this, false);
manaAbiltiy.resolve(this);
} else {
TriggeredAbility newAbility = ability.copy();
newAbility.newId();
if (newAbility.getSourceObjectZoneChangeCounter() == 0) {
newAbility.setSourceObjectZoneChangeCounter(getState().getZoneChangeCounter(ability.getSourceId()));
}
if (!(newAbility instanceof DelayedTriggeredAbility)) {
newAbility.setSourcePermanentTransformCount(this);
}
newAbility.setTriggerEvent(triggeringEvent);
state.addTriggeredAbility(newAbility);
}
}
Aggregations