Search in sources :

Example 1 with TriggeredManaAbility

use of mage.abilities.mana.TriggeredManaAbility 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);
    }
}
Also used : SagaAbility(mage.abilities.common.SagaAbility) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) AttachableToRestrictedAbility(mage.abilities.common.AttachableToRestrictedAbility) TriggeredManaAbility(mage.abilities.mana.TriggeredManaAbility) DelayedTriggeredManaAbility(mage.abilities.mana.DelayedTriggeredManaAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) CantHaveMoreThanAmountCountersSourceAbility(mage.abilities.common.CantHaveMoreThanAmountCountersSourceAbility) MageObject(mage.MageObject) TriggeredManaAbility(mage.abilities.mana.TriggeredManaAbility) DelayedTriggeredManaAbility(mage.abilities.mana.DelayedTriggeredManaAbility) DelayedTriggeredManaAbility(mage.abilities.mana.DelayedTriggeredManaAbility) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility)

Aggregations

MageObject (mage.MageObject)1 AttachableToRestrictedAbility (mage.abilities.common.AttachableToRestrictedAbility)1 CantHaveMoreThanAmountCountersSourceAbility (mage.abilities.common.CantHaveMoreThanAmountCountersSourceAbility)1 SagaAbility (mage.abilities.common.SagaAbility)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)1 DelayedTriggeredManaAbility (mage.abilities.mana.DelayedTriggeredManaAbility)1 TriggeredManaAbility (mage.abilities.mana.TriggeredManaAbility)1