public static void increaseCost(SpellAbility spellAbility, ManaCosts<ManaCost> manaCostsToIncrease) { ManaCosts<ManaCost> increasedCost = spellAbility.getManaCostsToPay().copy(); for (ManaCost manaCost : manaCostsToIncrease) { increasedCost.add(manaCost.copy()); } spellAbility.getManaCostsToPay().clear(); spellAbility.getManaCostsToPay().addAll(increasedCost); }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; spellAbility.getManaCostsToPay().add(new GenericManaCost(1)); return true; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; spellAbility.getManaCostsToPay().add(new GenericManaCost(3)); return true; }
@Override public ManaCosts<T> getUnpaid() { ManaCosts<T> unpaid = new ManaCostsImpl<>(); for (T cost : this) { if (!(cost instanceof VariableManaCost) && !cost.isPaid()) { unpaid.add((T) cost.getUnpaid()); } } return unpaid; }
@Override public ManaCosts<T> getUnpaidVariableCosts() { ManaCosts<T> unpaid = new ManaCostsImpl<>(); for (ManaCost cost : this) { if (cost instanceof VariableManaCost && !cost.isPaid()) { unpaid.add((T) cost.getUnpaid()); } } return unpaid; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { for (Target target : abilityToModify.getTargets()) { if (target.getMaxNumberOfTargets() == Integer.MAX_VALUE) { int additionalTargets = target.getTargets().size() - 1; StringBuilder sb = new StringBuilder(); for (int i = 0; i < additionalTargets; i++) { // Build up a string of strive costs for each target sb.append(striveCosts.getText()); } String finalCost = ManaUtil.condenseManaCostString(sb.toString()); abilityToModify.getManaCostsToPay().add(new ManaCostsImpl(finalCost)); return true; } } return false; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { Integer castCount = (Integer) game.getState().getValue(commanderId + "_castCount"); if (castCount > 0) { abilityToModify.getManaCostsToPay().add(new GenericManaCost(2 * castCount)); } return true; }
protected void simulateVariableCosts(Ability ability, List<Ability> options, Game game) { int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost(); 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); } }
protected void simulateVariableCosts(Ability ability, Game game) { int numAvailable = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost(); 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); } }
@Override public void addOptionalAdditionalModeCosts(Ability ability, Game game) { if (additionalCost.isActivated()) { for (Iterator it = ((Costs) additionalCost).iterator(); it.hasNext();) { Cost cost = (Cost) it.next(); if (cost instanceof ManaCostsImpl) { ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy()); } else { ability.getCosts().add(cost.copy()); } } } }
@Override public void adjustCosts(Ability ability, Game game) { int numTargets = ability.getTargets().isEmpty() ? 0 : ability.getTargets().get(0).getTargets().size(); if (numTargets > 1) { ability.getManaCostsToPay().add(new GenericManaCost(numTargets - 1)); } } }
@Override public void adjustCosts(Ability ability, Game game) { Permanent card = game.getPermanent(ability.getSourceId()); if (card != null) { if (!card.getImprinted().isEmpty()) { Card imprinted = game.getCard(card.getImprinted().get(0)); if (imprinted != null) { ability.getManaCostsToPay().add(0, new GenericManaCost(imprinted.getConvertedManaCost())); } } } // no {X} anymore as we already have imprinted the card with defined manacost for (ManaCost cost : ability.getManaCostsToPay()) { if (cost instanceof VariableCost) { cost.setPaid(); } } }
@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; }
@Override public void adjustCosts(Ability ability, Game game) { if (ability instanceof SimpleActivatedAbility) { Permanent sourcePermanent = game.getPermanent(ability.getSourceId()); if (sourcePermanent != null) { int pin = sourcePermanent.getCounters(game).getCount(CounterType.PIN); ability.getManaCostsToPay().clear(); ability.getManaCostsToPay().add(0, new GenericManaCost(pin * 2)); } } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}"); int xValue = controller.announceXMana(0, Integer.MAX_VALUE, "Choose the amount of mana to pay", game, source); cost.add(new GenericManaCost(xValue)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false) && xValue > 0) { new RevealLibraryPutIntoHandEffect(xValue, filter, Zone.LIBRARY, false).apply(game, source); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); // use target pointer here, so it's the same card that triggered the event (not gone back to library e.g.) Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (controller != null && card != null) { SpellAbility abilityToCast = card.getSpellAbility().copy(); ManaCosts<ManaCost> costRef = abilityToCast.getManaCostsToPay(); // replace with the new cost costRef.clear(); costRef.add(miracleCosts); controller.cast(abilityToCast, game, false, new MageObjectReference(source.getSourceObject(game), game)); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}"); if (you != null && you.chooseUse(Outcome.Neutral, "Do you want to to pay {X}?", source, game)) { int costX = you.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source); cost.add(new GenericManaCost(costX)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { Token token = new GoblinSoldierToken(); return token.putOntoBattlefield(costX, game, source.getSourceId(), source.getControllerId()); } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { ManaCosts cost = new ManaCostsImpl("{X}{W}{U}{U}"); if (controller.chooseUse(Outcome.Damage, "Pay " + cost.getText() + "? If you do, you gain X life and draw X cards.", source, game)) { int costX = controller.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source); cost.add(new GenericManaCost(costX)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { controller.resetStoredBookmark(game); // otherwise you can undo the payment controller.gainLife(costX, game, source); controller.drawCards(costX, game); return true; } } } return false; }
@Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); ManaCosts cost = new ManaCostsImpl("{X}"); if (you != null && you.chooseUse(Outcome.BoostCreature, "Do you want to to pay {X}?", source, game)) { int costX = you.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source); cost.add(new GenericManaCost(costX)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null) { return new AddCountersSourceEffect(CounterType.P1P1.createInstance(costX), true).apply(game, source); } } } return false; } }