Added possibility to check kind of cost to pay for conditional mana use.

This commit is contained in:
LevelX2 2016-01-10 12:01:58 +01:00
parent d63f6d7d27
commit c8f82b49ff
208 changed files with 770 additions and 571 deletions

View file

@ -1195,7 +1195,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
// pay phyrexian life costs
if (cost instanceof PhyrexianManaCost) {
if (cost.pay(null, game, null, playerId, false) || spendAnyMana) {
if (cost.pay(null, game, null, playerId, false, null) || spendAnyMana) {
return true;
}
}

View file

@ -805,7 +805,7 @@ public class HumanPlayer extends PlayerImpl {
if (cost instanceof PhyrexianManaCost) {
PhyrexianManaCost ph = (PhyrexianManaCost) cost;
if (ph.canPay(null, null, playerId, game)) {
((PhyrexianManaCost) cost).pay(null, game, null, playerId, false);
((PhyrexianManaCost) cost).pay(null, game, null, playerId, false, null);
}
break;
}

View file

@ -105,7 +105,7 @@ class VectisDominatorEffect extends OneShotEffect {
cost.clearPaid();
final StringBuilder sb = new StringBuilder("Pay 2 life? (Otherwise ").append(targetCreature.getName()).append(" will be tapped)");
if (player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
cost.pay(source, game, targetCreature.getControllerId(), targetCreature.getControllerId(), true);
cost.pay(source, game, targetCreature.getControllerId(), targetCreature.getControllerId(), true, null);
}
if (!cost.isPaid()) {
return targetCreature.tap(game);

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.effects.common.BasicManaEffect;
import mage.abilities.mana.SimpleManaAbility;
@ -83,7 +84,7 @@ class ExileSourceFromHandCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Card card = game.getCard(sourceId);
Player player = game.getPlayer(controllerId);
if (player != null && player.getHand().contains(sourceId) && card != null) {

View file

@ -160,7 +160,7 @@ class ExileTopCardLibraryCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
card = controller.getLibrary().getFromTop(game);

View file

@ -36,6 +36,7 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
@ -136,7 +137,7 @@ class CavernOfSoulsManaCondition extends CreatureCastManaCondition {
}
@Override
public boolean apply(Game game, Ability source, UUID manaProducer) {
public boolean apply(Game game, Ability source, UUID originalId, Cost costToPay) {
// check: ... to cast a creature spell
if (super.apply(game, source)) {
// check: ... of the chosen type

View file

@ -95,7 +95,7 @@ class GrovetenderDruidsEffect extends OneShotEffect {
if(player != null) {
if(player.chooseUse(Outcome.BoostCreature, "Do you want to to pay {1}?", source, game)) {
Cost cost = new ManaCostsImpl("{1}");
if(cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if(cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
new CreateTokenEffect(new GrovetenderDruidsPlantToken()).apply(game, source);
}
return true;

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
@ -92,7 +93,7 @@ class BlindingPowderUnattachCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null) {
for (UUID attachmentId : permanent.getAttachments()) {

View file

@ -100,7 +100,7 @@ class OgreMarauderEffect extends OneShotEffect {
Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent());
if (cost.canPay(source, source.getSourceId(), defendingPlayerId, game) &&
defender.chooseUse(Outcome.LoseAbility, "Sacrifice a creature to prevent that " + sourceObject.getLogName() + " can't be blocked?", source, game)) {
if (!cost.pay(source, game, source.getSourceId(), defendingPlayerId, false)) {
if (!cost.pay(source, game, source.getSourceId(), defendingPlayerId, false, null)) {
// cost was not payed - so source can't be blocked
ContinuousEffect effect = new CantBeBlockedSourceEffect(Duration.EndOfTurn);
game.addEffect(effect, source);

View file

@ -138,7 +138,7 @@ class ShurikenUnattachCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null) {
for (UUID attachmentId :permanent.getAttachments()) {

View file

@ -109,7 +109,7 @@ class FloodtideSerpentReplacementEffect extends ReplacementEffectImpl {
ReturnToHandChosenControlledPermanentCost attackCost = new ReturnToHandChosenControlledPermanentCost(new TargetControlledPermanent(filter));
if (attackCost.canPay(source, source.getSourceId(), event.getPlayerId(), game)
&& player.chooseUse(Outcome.Neutral, "Return an enchantment you control to hand to attack?", source, game)) {
if (attackCost.pay(source, game, source.getSourceId(), event.getPlayerId(), true)) {
if (attackCost.pay(source, game, source.getSourceId(), event.getPlayerId(), true, null)) {
return false;
}
}

View file

@ -98,7 +98,7 @@ class HeroOfLeinaTowerEffect extends OneShotEffect {
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)) {
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);

View file

@ -130,7 +130,7 @@ class DoUnlessTargetPaysCost extends OneShotEffect {
message = CardUtil.replaceSourceName(message, mageObject.getLogName());
cost.clearPaid();
if (cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(executingEffect.getOutcome(), message, source, game)) {
cost.pay(source, game, source.getSourceId(), player.getId(), false);
cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
}
if (!cost.isPaid()) {
executingEffect.setTargetPointer(this.targetPointer);

View file

@ -98,7 +98,7 @@ class CutTheTethersEffect extends OneShotEffect {
boolean paid = false;
if (player.chooseUse(outcome, new StringBuilder("Pay {3} to keep ").append(creature.getName()).append(" on the battlefield?").toString(), source, game)) {
Cost cost = new GenericManaCost(3);
if (!cost.pay(source, game, source.getSourceId(), creature.getControllerId(), false)) {
if (!cost.pay(source, game, source.getSourceId(), creature.getControllerId(), false, null)) {
paid = true;
}
if (!paid) {

View file

@ -36,6 +36,7 @@ import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
@ -184,7 +185,7 @@ class HankyuCountersSourceCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent equipment = game.getPermanent(this.effectGivingEquipmentId);
if (equipment != null ) {
this.removedCounters = equipment.getCounters().getCount(CounterType.AIM);

View file

@ -36,6 +36,7 @@ import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
@ -98,7 +99,7 @@ class HisokaMinamoSenseiDiscardTargetCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) {
Player player = game.getPlayer(controllerId);
for (UUID targetId: targets.get(0).getTargets()) {

View file

@ -35,6 +35,7 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.mana.ConditionalColorlessManaAbility;
@ -62,7 +63,7 @@ public class UntaidakeTheCloudKeeper extends CardImpl {
Ability ability = new ConditionalColorlessManaAbility(new TapSourceCost(), 2, new LegendarySpellManaBuilder());
ability.addCost(new PayLifeCost(2));
this.addAbility(ability);
}
public UntaidakeTheCloudKeeper(final UntaidakeTheCloudKeeper card) {
@ -76,6 +77,7 @@ public class UntaidakeTheCloudKeeper extends CardImpl {
}
class LegendarySpellManaBuilder extends ConditionalManaBuilder {
@Override
public ConditionalMana build(Object... options) {
return new LegendaryCastConditionalMana(this.mana);
@ -97,6 +99,7 @@ class LegendaryCastConditionalMana extends ConditionalMana {
}
class LegendaryCastManaCondition extends ManaCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
if (source instanceof SpellAbility) {
@ -109,7 +112,7 @@ class LegendaryCastManaCondition extends ManaCondition implements Condition {
}
@Override
public boolean apply(Game game, Ability source, UUID originalId) {
public boolean apply(Game game, Ability source, UUID originalId, Cost costsToPay) {
return apply(game, source);
}
}
}

View file

@ -30,6 +30,7 @@ package mage.sets.coldsnap;
import java.util.UUID;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.keyword.CumulativeUpkeepAbility;
import mage.cards.CardImpl;
@ -73,7 +74,7 @@ class BraidOfFireCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Player player = game.getPlayer(controllerId);
player.getManaPool().addMana(Mana.RedMana(1), game, ability);
paid = true;

View file

@ -30,6 +30,7 @@ package mage.sets.coldsnap;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.keyword.CumulativeUpkeepAbility;
import mage.cards.Card;
@ -84,7 +85,7 @@ class JotunGruntCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
if (targets.choose(Outcome.Removal, controllerId, sourceId, game)) {

View file

@ -30,6 +30,7 @@ package mage.sets.coldsnap;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.keyword.CumulativeUpkeepAbility;
import mage.abilities.keyword.TrampleAbility;
@ -89,7 +90,7 @@ class ShelteringAncientCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
Target target = new TargetCreaturePermanent(1, 1, filter, true);

View file

@ -121,7 +121,7 @@ class AllianceOfArmsEffect extends OneShotEffect {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}

View file

@ -147,7 +147,7 @@ class ChorusOfTheConclaveReplacementEffect extends ReplacementEffectImpl {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}

View file

@ -130,7 +130,7 @@ class CollectiveVoyageEffect extends OneShotEffect {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}

View file

@ -100,7 +100,7 @@ class ManaChargedDragonEffect extends OneShotEffect {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}

View file

@ -119,7 +119,7 @@ class MindsAglowEffect extends OneShotEffect {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}

View file

@ -120,7 +120,7 @@ class SharedTraumaEffect extends OneShotEffect {
xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
} else {
payed = true;
}

View file

@ -120,7 +120,7 @@ class VishKalBloodArbiterCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null) {
this.amount = permanent.getCounters().getCount(name);

View file

@ -57,6 +57,7 @@ import mage.target.common.TargetCreatureOrPlayer;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
import mage.abilities.costs.Cost;
/**
*
@ -200,7 +201,7 @@ class MarathWillOfTheWildRemoveCountersCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
int amount = new ManacostVariableValue().calculate(game, ability, null);
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null && permanent.getCounters().getCount(CounterType.P1P1) >= amount) {

View file

@ -90,7 +90,7 @@ class VictimizeEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature")));
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)).getCards(game),
Zone.BATTLEFIELD, source, game, true, false, false, null);
}

View file

@ -145,7 +145,7 @@ class JarOfEyeballsCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(ability.getSourceId());
if (permanent != null) {
this.removedCounters = permanent.getCounters().getCount(CounterType.EYEBALL);

View file

@ -33,6 +33,7 @@ import mage.constants.*;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
@ -90,7 +91,7 @@ class UnattachCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null) {
Permanent attachment = game.getPermanent(attachmentid);

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
@ -104,7 +105,7 @@ class SurestrikeTridentUnattachCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null) {
for (UUID attachmentId : permanent.getAttachments()) {

View file

@ -33,6 +33,7 @@ import mage.MageObject;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -120,7 +121,7 @@ class HavenOfTheSpiritConditionalMana extends ConditionalMana {
class HavenOfTheSpiritManaCondition extends CreatureCastManaCondition {
@Override
public boolean apply(Game game, Ability source, UUID manaProducer) {
public boolean apply(Game game, Ability source, UUID manaProducer, Cost costToPay) {
if (super.apply(game, source)) {
MageObject object = game.getObject(source.getSourceId());
if (object.hasSubtype("Dragon")

View file

@ -95,7 +95,7 @@ class MysticMeditationEffect extends OneShotEffect {
&& controller.chooseUse(Outcome.Discard, "Do you want to discard a creature card? If you don't, you must discard 2 cards", source, game)) {
Cost cost = new DiscardTargetCost(new TargetCardInHand(filter));
if (cost.canPay(source, source.getSourceId(), controller.getId(), game)) {
if (cost.pay(source, game, source.getSourceId(), controller.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), controller.getId(), false, null)) {
return true;
}
}

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -101,7 +102,7 @@ class HatchetBullyCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(ability.getTargets().get(1).getFirstTarget());
if (permanent != null) {
permanent.addCounters(CounterType.M1M1.createInstance(), game);

View file

@ -34,6 +34,7 @@ import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -111,7 +112,7 @@ class ImpelledGiantCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
if (target.choose(Outcome.Tap, controllerId, sourceId, game)) {
for (UUID targetId: (List<UUID>)target.getTargets()) {
Permanent permanent = game.getPermanent(targetId);

View file

@ -119,7 +119,7 @@ class RiseOfTheHobgoblinsEffect extends OneShotEffect {
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)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
Token token = new GoblinSoldierToken();
return token.putOntoBattlefield(costX, game, source.getSourceId(), source.getControllerId());
}

View file

@ -103,7 +103,7 @@ class ErraticPortalEffect extends OneShotEffect {
if (player != null) {
cost.clearPaid();
if (player.chooseUse(Outcome.Benefit, "Pay {1}? (Otherwise " + targetCreature.getLogName() +" will be returned to its owner's hand)", source, game)) {
cost.pay(source, game, targetCreature.getControllerId(), targetCreature.getControllerId(), false);
cost.pay(source, game, targetCreature.getControllerId(), targetCreature.getControllerId(), false, null);
}
if (!cost.isPaid()) {
controller.moveCards(targetCreature, Zone.BATTLEFIELD, Zone.HAND, source, game);

View file

@ -35,6 +35,7 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.SourceHasCounterCondition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.dynamicvalue.common.CountersCount;
@ -127,7 +128,7 @@ class TidalInfluenceCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
this.paid = true;
return paid;
}

View file

@ -112,7 +112,7 @@ class DisruptionAuraEffect extends OneShotEffect {
Cost cost = permanent.getManaCost().copy();
if (player.chooseUse(Outcome.Benefit, message, source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
return true;
}
}

View file

@ -148,7 +148,7 @@ class PlungeIntoDarknessSearchEffect extends OneShotEffect {
if (player != null) {
VariableCost cost = new PayVariableLifeCost();
int xValue = cost.announceXValue(source, game);
cost.getFixedCostsFromAnnouncedValue(xValue).pay(source, game, source.getSourceId(), source.getControllerId(), false);
cost.getFixedCostsFromAnnouncedValue(xValue).pay(source, game, source.getSourceId(), source.getControllerId(), false, null);
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), xValue);

View file

@ -130,11 +130,11 @@ class PossessedPortalEffect extends OneShotEffect {
Cost discardCost = new DiscardCardCost();
if (discardCost.canPay(source, source.getSourceId(), playerId, game)
&& player.chooseUse(Outcome.Discard, "Discard a card? (Otherwise sacrifice a permanent)", source, game)) {
discardCost.pay(source, game, source.getSourceId(), playerId, true);
discardCost.pay(source, game, source.getSourceId(), playerId, true, null);
}
else {
Cost sacrificeCost = new SacrificeTargetCost(new TargetControlledPermanent());
sacrificeCost.pay(source, game, source.getSourceId(), playerId, true);
sacrificeCost.pay(source, game, source.getSourceId(), playerId, true, null);
}
}
return true;

View file

@ -97,7 +97,7 @@ class ForceOfNatureEffect extends OneShotEffect {
Cost cost = new ManaCostsImpl("{G}{G}{G}{G}");
String message = "Would you like to pay {G}{G}{G}{G} to prevent taking 8 damage from {this}?";
if (!(controller.chooseUse(Outcome.Benefit, message, source, game)
&& cost.pay(source, game, source.getSourceId(), controller.getId(), false))) {
&& cost.pay(source, game, source.getSourceId(), controller.getId(), false, null))) {
controller.damage(8, source.getSourceId(), game, false, true);
}
return true;

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.BasicManaEffect;
@ -114,7 +115,7 @@ class FilterPermanentCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
this.paid = true;
return paid;
}

View file

@ -92,7 +92,7 @@ class LeylineOfLightningEffect extends DamageTargetEffect {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Cost cost = new GenericManaCost(1);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
super.apply(game, source);
}
return true;

View file

@ -145,7 +145,7 @@ class MysticRemoraTriggeredAbility extends TriggeredAbilityImpl {
if (controller != null && opponent != null && sourceObject != null) {
Cost cost = new GenericManaCost(4);
String message = "Would you like to pay {4} to prevent the opponent to draw a card?";
if (!(opponent.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source.getSourceId(), opponent.getId(), false))) {
if (!(opponent.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null))) {
if(controller.chooseUse(Outcome.DrawCard, "Draw a card (" + sourceObject.getLogName() +")", source, game)) {
controller.drawCards(1, game);
}

View file

@ -109,7 +109,7 @@ class SeizuresEffect extends OneShotEffect {
if(cost.canPay(source, source.getSourceId(), player.getId(), game)
&& player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + " to avoid damage?", source, game)) {
cost.clearPaid();
if(cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
if(cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
return true;
}
}

View file

@ -30,6 +30,7 @@ package mage.sets.innistrad;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.PutTokenOntoBattlefieldCopyTargetEffect;
@ -97,7 +98,7 @@ class BackFromTheBrinkCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {

View file

@ -95,7 +95,7 @@ class FrightfulDelusionEffect extends OneShotEffect {
game.getPlayer(spell.getControllerId()).discard(
1, false, source, game);
if (!cost.pay(source, game, spell.getControllerId(),
spell.getControllerId(), false)) {
spell.getControllerId(), false, null)) {
return game.getStack().counter(source.getFirstTarget(),
source.getSourceId(), game);
}

View file

@ -133,7 +133,7 @@ class ScreechingBatTransformSourceEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Cost cost = new ManaCostsImpl("{2}{B}{B}");
if (cost.pay(source, game, permanent.getControllerId(), permanent.getControllerId(), false)) {
if (cost.pay(source, game, permanent.getControllerId(), permanent.getControllerId(), false, null)) {
if (permanent.canTransform()) {
permanent.setTransformed(!permanent.isTransformed());
}

View file

@ -131,7 +131,7 @@ class AthreosGodOfPassageReturnEffect extends OneShotEffect {
Cost cost = new PayLifeCost(3);
if (cost.canPay(source, source.getSourceId(), opponent.getId(), game)
&& opponent.chooseUse(outcome, new StringBuilder("Pay 3 live to prevent that ").append(creature.getLogName()).append(" returns to ").append(controller.getLogName()).append("'s hand?").toString(), source, game)) {
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null)) {
paid = true;
}
}

View file

@ -105,7 +105,7 @@ class DiscipleOfDeceitEffect extends OneShotEffect {
String message = "Discard a nonland card to search your library?";
if (cost.canPay(source, source.getSourceId(), source.getControllerId(), game)
&& player.chooseUse(Outcome.Detriment, message, source, game)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
Card card = game.getCard(cost.getTargets().getFirstTarget());
if (card == null) {
return false;

View file

@ -101,7 +101,7 @@ class SageOfHoursCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(ability.getSourceId());
if (permanent != null) {
this.removedCounters = permanent.getCounters().getCount(CounterType.P1P1);

View file

@ -33,6 +33,7 @@ import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
@ -103,7 +104,7 @@ class WormfangDrakeExileCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
MageObject sourceObject = ability.getSourceObject(game);
if (controller != null && sourceObject != null) {

View file

@ -105,7 +105,7 @@ class ChainLightningEffect extends OneShotEffect {
if (affectedPlayer != null) {
if (affectedPlayer.chooseUse(Outcome.Copy, "Pay {R}{R} to copy the spell?", source, game)) {
Cost cost = new ManaCostsImpl("{R}{R}");
if (cost.pay(source, game, source.getSourceId(), affectedPlayer.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), affectedPlayer.getId(), false, null)) {
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
Spell copy = spell.copySpell();

View file

@ -100,7 +100,7 @@ class CosmicHorrorEffect extends OneShotEffect {
}
if (controller.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
return true;
}
}

View file

@ -91,7 +91,7 @@ class DestroySourceUnlessPaysEffect extends OneShotEffect {
if (player != null && permanent != null) {
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + "?", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
return true;
}
}

View file

@ -111,7 +111,7 @@ class DemonicHordesEffect extends OneShotEffect {
}
if (controller.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
return true;
}
}

View file

@ -120,7 +120,7 @@ class BrokenAmbitionsEffect extends OneShotEffect {
message = costToPay.getText() + " to prevent counter effect?";
}
costToPay.clearPaid();
if (!(controller.chooseUse(Outcome.Benefit, message, source, game) && costToPay.pay(source, game, spell.getSourceId(), spell.getControllerId(), false))) {
if (!(controller.chooseUse(Outcome.Benefit, message, source, game) && costToPay.pay(source, game, spell.getSourceId(), spell.getControllerId(), false, null))) {
game.getStack().counter(spell.getId(), source.getSourceId(), game);
}
if (ClashEffect.getInstance().apply(game, source)) {

View file

@ -131,7 +131,7 @@ class RingsOfBrighthearthEffect extends OneShotEffect {
ManaCostsImpl cost = new ManaCostsImpl("{2}");
if (player != null) {
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + "? If you do, copy that ability. You may choose new targets for the copy.", source, game)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
Ability ability = (Ability) getValue("stackAbility");
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
@ -96,7 +97,7 @@ class SilvergillAdeptCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Player player = game.getPlayer(controllerId);
if (player == null) {

View file

@ -36,6 +36,7 @@ import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.mana.ColoredManaCost;
import mage.abilities.effects.common.DamageTargetEffect;
@ -137,7 +138,7 @@ class AncientHellkiteCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
this.paid = true;
return paid;
}

View file

@ -102,14 +102,14 @@ class IndulgentTormentorEffect extends OneShotEffect {
Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent());
if (cost.canPay(source, source.getSourceId(), opponent.getId(), game)
&& opponent.chooseUse(outcome, "Sacrifice a creature to prevent the card draw?", source, game)) {
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null)) {
return true;
}
}
cost = new PayLifeCost(3);
if (cost.canPay(source, source.getSourceId(), opponent.getId(), game)
&& opponent.chooseUse(outcome, "Pay 3 life to prevent the card draw?", source, game)) {
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null)) {
return true;
}
}

View file

@ -30,6 +30,7 @@ package mage.sets.magic2015;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
@ -92,7 +93,7 @@ class NecromancersStockpileDiscardTargetCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) {
Player player = game.getPlayer(controllerId);
for (UUID targetId : targets.get(0).getTargets()) {

View file

@ -29,11 +29,11 @@ package mage.sets.magic2015;
import java.util.UUID;
import mage.ConditionalMana;
import mage.MageInt;
import mage.MageObject;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.decorator.ConditionalActivatedAbility;
@ -124,7 +124,7 @@ class SliverHiveConditionalMana extends ConditionalMana {
class SliverHiveManaCondition extends CreatureCastManaCondition {
@Override
public boolean apply(Game game, Ability source, UUID manaProducer) {
public boolean apply(Game game, Ability source, UUID manaProducer, Cost costToPay) {
if (super.apply(game, source)) {
MageObject object = game.getObject(source.getSourceId());
if (object.hasSubtype("Sliver")) {

View file

@ -117,7 +117,7 @@ class ForgottenLoreEffect extends OneShotEffect {
if(!done) {
if(cost.canPay(source, source.getSourceId(), you.getId(), game) && you.chooseUse(Outcome.Benefit, "Pay {G} to choose a different card ?", source, game)) {
cost.clearPaid();
if(!cost.pay(source, game, source.getSourceId(), you.getId(), false)) {
if(!cost.pay(source, game, source.getSourceId(), you.getId(), false, null)) {
done = true;
}
}

View file

@ -113,7 +113,7 @@ class CounterSourceEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if(controller.chooseUse(Outcome.Detriment, "Sacrifice a land to not counter " + spell.getName() + "?", source, game)){
SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent()));
if(cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)){
if(cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)){
game.informPlayers(controller.getLogName() + " sacrifices a land to not counter " + spell.getName() + ".");
return true;
}

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -124,7 +125,7 @@ class WanderingMageCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(ability.getTargets().get(1).getFirstTarget());
if (permanent != null) {
permanent.addCounters(CounterType.M1M1.createInstance(), game);

View file

@ -92,7 +92,7 @@ class HasranOgressEffect extends OneShotEffect {
Cost cost = new ManaCostsImpl("{2}");
String message = "Would you like to pay {2} to prevent taking 3 damage from Hasran Ogress?";
if (!(controller.chooseUse(Outcome.Benefit, message, source, game)
&& cost.pay(source, game, source.getSourceId(), controller.getId(), false))) {
&& cost.pay(source, game, source.getSourceId(), controller.getId(), false, null))) {
controller.damage(3, source.getSourceId(), game, false, true);
}
return true;

View file

@ -34,6 +34,7 @@ import mage.MageObject;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.mana.ConditionalColorlessManaAbility;
import mage.abilities.mana.builder.ConditionalManaBuilder;
@ -109,7 +110,7 @@ class ArtifactAbilityManaCondition extends ManaCondition implements Condition {
}
@Override
public boolean apply(Game game, Ability source, UUID originalId) {
public boolean apply(Game game, Ability source, UUID originalId, Cost costsToPay) {
return apply(game, source);
}
}

View file

@ -94,7 +94,7 @@ class HornOfPlentyEffect extends OneShotEffect {
if (caster != null) {
if (caster.chooseUse(Outcome.DrawCard, "Pay {1} to draw a card at the beginning of the next end step?", source, game)) {
Cost cost = new ManaCostsImpl("{1}");
if (cost.pay(source, game, source.getSourceId(), caster.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), caster.getId(), false, null)) {
Effect effect = new DrawCardTargetEffect(1);
effect.setTargetPointer(new FixedTarget(caster.getId()));
return new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY)).apply(game, source);

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
import mage.cards.CardImpl;
@ -105,7 +106,7 @@ class LandGrantReavealCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Player player = game.getPlayer(controllerId);
if (player != null) {
player.revealCards("Land Grant", player.getHand(), game);

View file

@ -105,7 +105,7 @@ class FlashEffect extends OneShotEffect {
StringBuilder sb = new StringBuilder("Pay ").append(reducedCost.getText()).append("?");
if (player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
reducedCost.clearPaid();
if (reducedCost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (reducedCost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
return true;
}
}

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.abilities.keyword.TrampleAbility;
@ -94,7 +95,7 @@ class PhyrexianDreadnoughtSacrificeCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
int sumPower = 0;
if (targets.choose(Outcome.Sacrifice, controllerId, sourceId, game)) {
for (UUID targetId: targets.get(0).getTargets()) {

View file

@ -98,7 +98,7 @@ class VaporousDjinnEffect extends OneShotEffect {
Cost cost = new ManaCostsImpl("{U}{U}");
String message = "Would you like to pay {U}{U} to prevent {this} from phasing out?";
if (!(controller.chooseUse(Outcome.Benefit, message, source, game)
&& cost.pay(source, game, source.getSourceId(), controller.getId(), false))) {
&& cost.pay(source, game, source.getSourceId(), controller.getId(), false, null))) {
permanent.phaseOut(game);
}
return true;

View file

@ -107,7 +107,7 @@ class CrystalShardEffect extends OneShotEffect {
cost.clearPaid();
final StringBuilder sb = new StringBuilder("Pay {1}? (Otherwise ").append(targetCreature.getName()).append(" will be returned to its owner's hand)");
if (player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
cost.pay(source, game, targetCreature.getControllerId(), targetCreature.getControllerId(), false);
cost.pay(source, game, targetCreature.getControllerId(), targetCreature.getControllerId(), false, null);
}
if (!cost.isPaid()) {
controller.moveCards(targetCreature, Zone.BATTLEFIELD, Zone.HAND, source, game);

View file

@ -97,7 +97,7 @@ class TajNarSwordsmithEffect extends OneShotEffect {
if (player != null && player.chooseUse(Outcome.BoostCreature, "Do you want to to pay {X}?", source, game)) {
int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
Cost cost = new GenericManaCost(costX);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
FilterCard filter = new FilterCard("Equipment card with converted mana cost " + costX + " or less");
filter.add(new SubtypePredicate("Equipment"));
filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, costX + 1));

View file

@ -35,6 +35,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.RemoveCounterCost;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -141,7 +142,7 @@ class RemoveCounterFromCardCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
paid = false;
Player controller = game.getPlayer(controllerId);
if (target.choose(Outcome.UnboostCreature, controllerId, sourceId, game)) {

View file

@ -99,7 +99,7 @@ class RootwaterThiefEffect extends OneShotEffect {
}
String message = "Pay {2} to exile a card from damaged player's library?";
Cost cost = new ManaCostsImpl("{2}");
if(controller.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source.getSourceId(), controller.getId(), false))
if(controller.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source.getSourceId(), controller.getId(), false, null))
{
TargetCardInLibrary target = new TargetCardInLibrary();
if (controller.searchLibrary(target, game, damagedPlayer.getId())) {

View file

@ -35,6 +35,7 @@ import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
@ -102,7 +103,7 @@ class GreenhiltTraineeCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
this.paid = true;
return paid;
}

View file

@ -40,6 +40,8 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.target.common.TargetCreaturePermanent;
/**
@ -48,6 +50,12 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class GravityNegator extends CardImpl {
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("another target creature");
static {
filter.add(new AnotherPredicate());
}
public GravityNegator(UUID ownerId) {
super(ownerId, 45, "Gravity Negator", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{3}{U}");
this.expansionSetCode = "OGW";
@ -65,7 +73,7 @@ public class GravityNegator extends CardImpl {
// Whenenever Gravity Negator attacks, you may pay {C}. If you do, another target creature gains flying until end of turn.
Ability ability = new AttacksTriggeredAbility(new DoIfCostPaid(new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), new ManaCostsImpl("{C}")), false,
"Whenever {this} attacks you may pay {C}. If you do, another target creature gains flying until end of turn.");
ability.addTarget(new TargetCreaturePermanent());
ability.addTarget(new TargetCreaturePermanent(filter));
this.addAbility(ability);
}

View file

@ -34,6 +34,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.condition.common.CardsInHandCondition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
@ -133,7 +134,7 @@ class KozilekDiscardCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Spell targetSpell = game.getStack().getSpell(ability.getFirstTarget());
if (targetSpell == null) {
return false;

View file

@ -175,7 +175,7 @@ class DecayingSoilEffect extends OneShotEffect {
if (player != null) {
if (player.chooseUse(Outcome.Benefit, " - Pay " + cost.getText() + "?", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
UUID target = this.getTargetPointer().getFirst(game, source);
if (target != null) {
Card card = game.getCard(target);

View file

@ -139,7 +139,7 @@ class DelayingShieldUpkeepEffect extends OneShotEffect {
for (int i = numCounters; i > 0; i--) {
if (controller.chooseUse(Outcome.Benefit, "Pay {1}{W}? (" + i + " counters left to pay)", source, game)) {
Cost cost = new ManaCostsImpl<>("{1}{W}");
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
continue;
}
}

View file

@ -92,7 +92,7 @@ class DivertEffect extends OneShotEffect {
if (player != null) {
cost.clearPaid();
if (!cost.pay(source, game, spell.getControllerId(),
spell.getControllerId(), false)) {
spell.getControllerId(), false, null)) {
return spell.chooseNewTargets(game, source.getControllerId(), true, true, null);
}
}

View file

@ -95,7 +95,7 @@ class UnifyingTheoryEffect extends OneShotEffect {
if (caster != null) {
if (caster.chooseUse(Outcome.DrawCard, "Pay {2} to draw a card?", source, game)) {
Cost cost = new ManaCostsImpl("{2}");
if (cost.pay(source, game, source.getSourceId(), caster.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), caster.getId(), false, null)) {
caster.drawCards(1, game);
}
}

View file

@ -101,7 +101,7 @@ class BrainGorgersCounterSourceEffect extends OneShotEffect {
Player player = game.getPlayer(playerId);
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
&& player.chooseUse(outcome, "Sacrifice a creature to counter " + sourceObject.getIdName() + "?", source, game)) {
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
game.informPlayers(player.getLogName() + " sacrifices a creature to counter " + sourceObject.getIdName() + ".");
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {

View file

@ -97,7 +97,7 @@ class DashHopesCounterSourceEffect extends OneShotEffect {
cost.clearPaid();
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
&& player.chooseUse(outcome, "Pay 5 life to counter " + sourceObject.getIdName() + "?", source, game)) {
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
game.informPlayers(player.getLogName() + " pays 5 life to counter " + sourceObject.getIdName() + ".");
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {

View file

@ -103,7 +103,7 @@ class CounterSourceEffect extends OneShotEffect {
cost.clearPaid();
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
&& player.chooseUse(outcome, "Discard three cards to counter " + sourceObject.getIdName() + "?", source, game)) {
if (cost.pay(source, game, source.getSourceId(), playerId, false)) {
if (cost.pay(source, game, source.getSourceId(), playerId, false, null)) {
game.informPlayers(player.getLogName() + " discards 3 cards to counter " + sourceObject.getIdName() + ".");
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {

View file

@ -101,7 +101,7 @@ class ShivanWumpusEffect extends PutOnLibrarySourceEffect {
if (player != null
&& cost.canPay(source, source.getSourceId(), playerId, game)
&& player.chooseUse(Outcome.Sacrifice, "Sacrifice a land?", source, game)
&& cost.pay(source, game, source.getSourceId(), playerId, true)) {
&& cost.pay(source, game, source.getSourceId(), playerId, true, null)) {
costPaid = true;
}
}

View file

@ -118,7 +118,7 @@ class ShroudedLoreEffect extends OneShotEffect {
if(!done) {
if(cost.canPay(source, source.getSourceId(), you.getId(), game) && you.chooseUse(Outcome.Benefit, "Pay {B} to choose a different card ?", source, game)) {
cost.clearPaid();
if(!cost.pay(source, game, source.getSourceId(), you.getId(), false)) {
if(!cost.pay(source, game, source.getSourceId(), you.getId(), false, null)) {
done = true;
}
}

View file

@ -34,6 +34,7 @@ import mage.constants.Rarity;
import mage.MageInt;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.effects.common.BasicManaEffect;
import mage.abilities.mana.SimpleManaAbility;
@ -84,7 +85,7 @@ class ExileSourceFromHandCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Card card = game.getCard(sourceId);
Player player = game.getPlayer(controllerId);
if (player != null && player.getHand().contains(sourceId) && card != null) {

View file

@ -96,7 +96,7 @@ class ThirstforKnowledgeEffect extends OneShotEffect {
&& you.chooseUse(Outcome.Discard, "Do you want to discard an artifact? If you don't, you must discard 2 cards", source, game)) {
Cost cost = new DiscardTargetCost(new TargetCardInHand(filter));
if (cost.canPay(source, source.getSourceId(), you.getId(), game)) {
if (cost.pay(source, game, source.getSourceId(), you.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), you.getId(), false, null)) {
return true;
}
}

View file

@ -127,7 +127,7 @@ class PhyrexianTyrannyEffect extends OneShotEffect {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
Cost cost = new GenericManaCost(2);
if (!cost.pay(source, game, player.getId(), player.getId(), false)) {
if (!cost.pay(source, game, player.getId(), player.getId(), false, null)) {
player.damage(2, source.getSourceId(), game, false, true);
}
return true;

View file

@ -92,7 +92,7 @@ class RhysticStudyDrawEffect extends OneShotEffect {
if (controller != null && opponent != null && sourceObject != null) {
Cost cost = new GenericManaCost(1);
String message = "Would you like to pay {1} to prevent the opponent to draw a card?";
if (!(opponent.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source.getSourceId(), opponent.getId(), false))) {
if (!(opponent.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null))) {
if(controller.chooseUse(Outcome.DrawCard, "Draw a card (" + sourceObject.getLogName() +")", source, game)) {
controller.drawCards(1, game);
}

View file

@ -32,6 +32,7 @@ import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -149,7 +150,7 @@ class UnattachSourceCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent attachment = game.getPermanent(sourceId);
Permanent permanent = game.getPermanent(attachment.getAttachedTo());
if (permanent != null) {

View file

@ -111,7 +111,7 @@ class SoulTitheEffect extends OneShotEffect {
int cmc = permanent.getManaCost().convertedManaCost();
if (player.chooseUse(Outcome.Benefit, "Pay {" + cmc + "} for " + permanent.getName() + "? (otherwise you sacrifice it)", source, game)) {
Cost cost = new GenericManaCost(cmc);
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
return true;
}
}

View file

@ -35,6 +35,7 @@ import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -93,7 +94,7 @@ class SacrificeAllLandCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
for(Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), ability.getControllerId(), game)){
paid |= permanent.sacrifice(sourceId, game);
}

View file

@ -34,6 +34,7 @@ import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.DamageTargetEffect;
@ -100,7 +101,7 @@ class BloodshotTraineeCost extends CostImpl {
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
this.paid = true;
return paid;
}

View file

@ -88,7 +88,7 @@ class EmbersmithEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Cost cost = new GenericManaCost(1);
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.damage(1, source.getSourceId(), game, false, true);

Some files were not shown because too many files have changed in this diff Show more