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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations