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