Search in sources :

Example 1 with GenericManaCost

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

the class SimulatedPlayerMCTS method getAction.

private Ability getAction(Game game) {
    List<ActivatedAbility> playables = getPlayableAbilities(game);
    Ability ability;
    while (true) {
        if (playables.size() == 1) {
            ability = playables.get(0);
        } else {
            ability = playables.get(RandomUtil.nextInt(playables.size()));
        }
        List<Ability> options = getPlayableOptions(ability, game);
        if (!options.isEmpty()) {
            if (options.size() == 1) {
                ability = options.get(0);
            } else {
                ability = options.get(RandomUtil.nextInt(options.size()));
            }
        }
        if (!ability.getManaCosts().getVariableCosts().isEmpty()) {
            int amount = getAvailableManaProducers(game).size() - ability.getManaCosts().manaValue();
            if (amount > 0) {
                ability = ability.copy();
                ability.getManaCostsToPay().add(new GenericManaCost(RandomUtil.nextInt(amount)));
            }
        }
        // else {
        break;
    // }
    }
    return ability;
}
Also used : PassAbility(mage.abilities.common.PassAbility) StackAbility(mage.game.stack.StackAbility) GenericManaCost(mage.abilities.costs.mana.GenericManaCost)

Example 2 with GenericManaCost

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

the class DiffusionSliverTriggeredAbility method checkTrigger.

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

Example 3 with GenericManaCost

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

the class RemnantOfTheRisingStarEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}");
    if (player == null || !player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", source, game)) {
        return false;
    }
    int xValue = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
    cost.add(new GenericManaCost(xValue));
    if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
        return false;
    }
    Permanent permanent = (Permanent) getValue("permanentEnteringBattlefield");
    if (permanent == null) {
        return false;
    }
    game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance(xValue)).setTargetPointer(new FixedTarget(permanent, game)), false), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ManaCost(mage.abilities.costs.mana.ManaCost) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) Hint(mage.abilities.hint.Hint) ValueHint(mage.abilities.hint.ValueHint)

Example 4 with GenericManaCost

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

the class ValentinDeanOfTheVeinEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ((ZoneChangeEvent) event).setToZone(Zone.EXILED);
    game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new DoIfCostPaid(new CreateTokenEffect(new Pest11GainLifeToken()), new GenericManaCost(2)), false, "you may pay {2}. If you do, create a 1/1 black and green " + "Pest creature token with \"When this creature dies, you gain 1 life.\""), source);
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) DoIfCostPaid(mage.abilities.effects.common.DoIfCostPaid) Pest11GainLifeToken(mage.game.permanent.token.Pest11GainLifeToken) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 5 with GenericManaCost

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

the class BrineSeerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
    if (!cost.pay(source, game, source, source.getControllerId(), true)) {
        return false;
    }
    int xValue = cost.getNumberRevealedCards();
    return new CounterUnlessPaysEffect(new GenericManaCost(xValue)).apply(game, source);
}
Also used : CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) RevealTargetFromHandCost(mage.abilities.costs.common.RevealTargetFromHandCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) TargetCardInHand(mage.target.common.TargetCardInHand)

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