Search in sources :

Example 11 with TappedForManaEvent

use of mage.game.events.TappedForManaEvent in project mage by magefree.

the class HighTideTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent permanent = ((TappedForManaEvent) event).getPermanent();
    if (permanent == null || !permanent.hasSubtype(SubType.ISLAND, game)) {
        return false;
    }
    getEffects().setTargetPointer(new FixedTarget(permanent.getControllerId()));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Example 12 with TappedForManaEvent

use of mage.game.events.TappedForManaEvent in project mage by magefree.

the class NakedSingularityEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    TappedForManaEvent manaEvent = (TappedForManaEvent) event;
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = manaEvent.getPermanent();
    if (controller == null || permanent == null) {
        return false;
    }
    Choice choice = new ChoiceColor(true);
    choice.getChoices().clear();
    choice.setMessage("Pick a color to produce");
    if (permanent.hasSubtype(SubType.PLAINS, game)) {
        choice.getChoices().add("Red");
    }
    if (permanent.hasSubtype(SubType.ISLAND, game)) {
        choice.getChoices().add("Green");
    }
    if (permanent.hasSubtype(SubType.SWAMP, game)) {
        choice.getChoices().add("White");
    }
    if (permanent.hasSubtype(SubType.MOUNTAIN, game)) {
        choice.getChoices().add("Blue");
    }
    if (permanent.hasSubtype(SubType.FOREST, game)) {
        choice.getChoices().add("Black");
    }
    String chosenColor;
    if (choice.getChoices().size() == 1) {
        chosenColor = choice.getChoices().iterator().next();
    } else {
        controller.choose(Outcome.PutManaInPool, choice, game);
        chosenColor = choice.getChoice();
    }
    if (chosenColor == null) {
        return false;
    }
    Mana mana = manaEvent.getMana();
    int amount = mana.count();
    switch(chosenColor) {
        case "White":
            mana.setToMana(Mana.WhiteMana(amount));
            break;
        case "Blue":
            mana.setToMana(Mana.BlueMana(amount));
            break;
        case "Black":
            mana.setToMana(Mana.BlackMana(amount));
            break;
        case "Red":
            mana.setToMana(Mana.RedMana(amount));
            break;
        case "Green":
            mana.setToMana(Mana.GreenMana(amount));
            break;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) ChoiceColor(mage.choices.ChoiceColor) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Example 13 with TappedForManaEvent

use of mage.game.events.TappedForManaEvent in project mage by magefree.

the class ManaOptions method checkManaReplacementAndTriggeredMana.

/**
 * Generates triggered mana and checks replacement of Tapped_For_Mana event.
 * Also generates triggered mana for MANA_ADDED event.
 *
 * @param ability
 * @param game
 * @param mana
 * @return false if mana production was completely replaced
 */
private boolean checkManaReplacementAndTriggeredMana(Ability ability, Game game, Mana mana) {
    if (ability.hasTapCost()) {
        ManaEvent event = new TappedForManaEvent(ability.getSourceId(), ability, ability.getControllerId(), mana, game);
        if (game.replaceEvent(event)) {
            return false;
        }
        game.fireEvent(event);
    }
    ManaEvent manaEvent = new ManaEvent(GameEvent.EventType.MANA_ADDED, ability.getSourceId(), ability, ability.getControllerId(), mana);
    manaEvent.setData(mana.toString());
    game.fireEvent(manaEvent);
    return true;
}
Also used : TappedForManaEvent(mage.game.events.TappedForManaEvent) ManaEvent(mage.game.events.ManaEvent) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Example 14 with TappedForManaEvent

use of mage.game.events.TappedForManaEvent in project mage by magefree.

the class PriceOfGloryAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    // it's non mana triggered ability, so ignore it on checking, see TAPPED_FOR_MANA
    if (game.inCheckPlayableState()) {
        return false;
    }
    Permanent permanent = ((TappedForManaEvent) event).getPermanent();
    if (permanent == null || !permanent.isLand(game) || game.isActivePlayer(event.getPlayerId())) {
        return false;
    }
    getEffects().setTargetPointer(new FixedTarget(permanent, game));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Example 15 with TappedForManaEvent

use of mage.game.events.TappedForManaEvent in project mage by magefree.

the class TreasureNabberEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    // it's non mana triggered ability, so ignore it on checking, see TAPPED_FOR_MANA
    if (game.inCheckPlayableState()) {
        return false;
    }
    if (!game.getOpponents(controllerId).contains(event.getPlayerId())) {
        return false;
    }
    Permanent permanent = ((TappedForManaEvent) event).getPermanent();
    if (permanent == null || !permanent.isArtifact(game)) {
        return false;
    }
    getEffects().setTargetPointer(new FixedTarget(permanent, game));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Aggregations

TappedForManaEvent (mage.game.events.TappedForManaEvent)16 Permanent (mage.game.permanent.Permanent)15 FixedTarget (mage.target.targetpointer.FixedTarget)10 Mana (mage.Mana)4 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 Choice (mage.choices.Choice)2 ChoiceColor (mage.choices.ChoiceColor)2 FilterPermanent (mage.filter.FilterPermanent)2 ManaEvent (mage.game.events.ManaEvent)2 Player (mage.players.Player)2 ObjectColor (mage.ObjectColor)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 AddManaOfAnyTypeProducedEffect (mage.abilities.effects.mana.AddManaOfAnyTypeProducedEffect)1 Card (mage.cards.Card)1 FilterControlledLandPermanent (mage.filter.common.FilterControlledLandPermanent)1 FilterLandPermanent (mage.filter.common.FilterLandPermanent)1 TargetLandPermanent (mage.target.common.TargetLandPermanent)1