Search in sources :

Example 26 with GenericManaCost

use of mage.abilities.costs.mana.GenericManaCost in project mage by magefree.

the class UnsettledMarinerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!game.getOpponents(getControllerId()).contains(event.getPlayerId())) {
        return false;
    }
    Permanent permanent = game.getPermanent(event.getTargetId());
    if ((permanent == null || !permanent.getControllerId().equals(getControllerId())) && !event.getTargetId().equals(getControllerId())) {
        return false;
    }
    Effect effect = new CounterUnlessPaysEffect(new GenericManaCost(1));
    effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
    this.getEffects().clear();
    this.addEffect(effect);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) Permanent(mage.game.permanent.Permanent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) Effect(mage.abilities.effects.Effect) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect)

Example 27 with GenericManaCost

use of mage.abilities.costs.mana.GenericManaCost in project mage by magefree.

the class WellOfLostDreamsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int amount = (Integer) getValue("gainedLife");
        if (amount > 0) {
            int xValue = controller.announceXMana(0, amount, "Announce X Value", game, source);
            if (xValue > 0) {
                if (new GenericManaCost(xValue).pay(source, game, source, controller.getId(), false)) {
                    game.informPlayers(controller.getLogName() + " payed {" + xValue + '}');
                    controller.drawCards(xValue, source, game);
                } else {
                    return false;
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost)

Example 28 with GenericManaCost

use of mage.abilities.costs.mana.GenericManaCost in project mage by magefree.

the class SimulatedPlayer method simulateVariableCosts.

// protected void simulateAction(Game game, SimulatedAction previousActions, Ability action) {
// List<Ability> actions = new ArrayList<Ability>(previousActions.getAbilities());
// actions.add(action);
// Game sim = game.copy();
// if (sim.getPlayer(playerId).activateAbility((ActivatedAbility) action.copy(), sim)) {
// sim.applyEffects();
// sim.getPlayers().resetPassed();
// allActions.add(new SimulatedAction(sim, actions));
// }
// }
// add a generic mana cost for each amount possible
protected void simulateVariableCosts(Ability ability, Game game) {
    int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().manaValue();
    int start = 0;
    if (!(ability instanceof SpellAbility)) {
        // only use x=0 on spell abilities
        if (numAvailable == 0)
            return;
        else
            start = 1;
    }
    for (int i = start; i < numAvailable; i++) {
        Ability newAbility = ability.copy();
        newAbility.getManaCostsToPay().add(new GenericManaCost(i));
        allActions.add(newAbility);
    }
}
Also used : PassAbility(mage.abilities.common.PassAbility) StackAbility(mage.game.stack.StackAbility) TriggeredAbility(mage.abilities.TriggeredAbility) SpellAbility(mage.abilities.SpellAbility) ActivatedAbility(mage.abilities.ActivatedAbility) Ability(mage.abilities.Ability) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) SpellAbility(mage.abilities.SpellAbility)

Example 29 with GenericManaCost

use of mage.abilities.costs.mana.GenericManaCost in project mage by magefree.

the class MCTSPlayer method simulateVariableCosts.

protected void simulateVariableCosts(Ability ability, List<Ability> options, Game game) {
    int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().manaValue();
    int start = 0;
    if (!(ability instanceof SpellAbility)) {
        // only use x=0 on spell abilities
        if (numAvailable == 0)
            return;
        else
            start = 1;
    }
    for (int i = start; i < numAvailable; i++) {
        Ability newAbility = ability.copy();
        newAbility.getManaCostsToPay().add(new GenericManaCost(i));
        options.add(newAbility);
    }
}
Also used : SpellAbility(mage.abilities.SpellAbility) PassAbility(mage.abilities.common.PassAbility) ActivatedAbility(mage.abilities.ActivatedAbility) Ability(mage.abilities.Ability) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) SpellAbility(mage.abilities.SpellAbility)

Example 30 with GenericManaCost

use of mage.abilities.costs.mana.GenericManaCost in project mage by magefree.

the class CowedByWisdomayCostToAttackBlockEffect method getManaCostToPay.

@Override
public ManaCosts getManaCostToPay(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && !controller.getHand().isEmpty()) {
        ManaCosts manaCosts = new ManaCostsImpl();
        manaCosts.add(new GenericManaCost(controller.getHand().size()));
        return manaCosts;
    }
    return null;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

GenericManaCost (mage.abilities.costs.mana.GenericManaCost)31 Player (mage.players.Player)15 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)12 Permanent (mage.game.permanent.Permanent)10 ManaCosts (mage.abilities.costs.mana.ManaCosts)7 Ability (mage.abilities.Ability)6 CounterUnlessPaysEffect (mage.abilities.effects.common.CounterUnlessPaysEffect)6 FixedTarget (mage.target.targetpointer.FixedTarget)5 SpellAbility (mage.abilities.SpellAbility)4 PassAbility (mage.abilities.common.PassAbility)4 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)4 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)4 ManaCost (mage.abilities.costs.mana.ManaCost)4 Effect (mage.abilities.effects.Effect)3 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)3 StackAbility (mage.game.stack.StackAbility)3 ActivatedAbility (mage.abilities.ActivatedAbility)2 RevealTargetFromHandCost (mage.abilities.costs.common.RevealTargetFromHandCost)2 TapSourceCost (mage.abilities.costs.common.TapSourceCost)2 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)2