use of mage.abilities.effects.mana.ManaEffect in project mage by magefree.
the class DomriChaosBringerTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
ManaEffect manaEffect;
if (player.chooseUse(Outcome.PutManaInPool, "Choose red or green mana", "", "Red", "Green", source, game)) {
manaEffect = new BasicManaEffect(Mana.RedMana(1));
} else {
manaEffect = new BasicManaEffect(Mana.GreenMana(1));
}
game.addDelayedTriggeredAbility(new DomriChaosBringerTriggeredAbility(source.getSourceId(), game.getTurnNum()), source);
return manaEffect.apply(game, source);
}
use of mage.abilities.effects.mana.ManaEffect in project mage by magefree.
the class AbilityImpl method resolveMode.
private boolean resolveMode(Game game) {
boolean result = true;
for (Effect effect : getEffects()) {
if (game.inCheckPlayableState() && !(effect instanceof ManaEffect)) {
// Ignored non mana effects - see GameEvent.TAPPED_FOR_MANA
continue;
}
if (effect instanceof OneShotEffect) {
boolean effectResult = effect.apply(game, this);
result &= effectResult;
if (logger.isDebugEnabled()) {
if (this.getAbilityType() != AbilityType.MANA) {
if (!effectResult) {
if (this.getSourceId() != null) {
MageObject mageObject = game.getObject(this.getSourceId());
if (mageObject != null) {
logger.debug("AbilityImpl.resolve: object: " + mageObject.getName());
}
}
logger.debug("AbilityImpl.resolve: effect returned false -" + effect.getText(this.getModes().getMode()));
}
}
}
} else {
game.addEffect((ContinuousEffect) effect, this);
}
/**
* All restrained trigger events are fired now. To restrain the
* events is mainly neccessary because of the movement of multiple
* object at once. If the event is fired directly as one object
* moved, other objects are not already in the correct zone to check
* for their effects. (e.g. Valakut, the Molten Pinnacle)
*/
game.getState().handleSimultaneousEvent(game);
game.resetShortLivingLKI();
/**
* game.applyEffects() has to be done at least for every effect that
* moves cards/permanent between zones, or changes control of
* objects so Static effects work as intended if dependant from the
* moved objects zone it is in Otherwise for example were static
* abilities with replacement effects deactivated too late Example:
* {@link org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy}
*/
game.applyEffects();
game.getState().getTriggers().checkStateTriggers(game);
}
return result;
}
Aggregations