mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
- payManaOptional will now pass on the spellability to payCostDuringAbilityResolve.
- Added support for CostGainLife in payCostDuringAbilityResolve.
This commit is contained in:
@@ -533,7 +533,7 @@ public class GameAction {
|
||||
final Ability recoverAbility = new Ability(recoverable, ManaCost.ZERO) {
|
||||
@Override
|
||||
public void resolve() {
|
||||
boolean hasPaid = recoverable.getController().getController().payManaOptional(recoverable, cost, sb.toString(), ManaPaymentPurpose.Recover);
|
||||
boolean hasPaid = recoverable.getController().getController().payManaOptional(recoverable, cost, this, sb.toString(), ManaPaymentPurpose.Recover);
|
||||
|
||||
if (hasPaid)
|
||||
moveToHand(recoverable);
|
||||
|
||||
@@ -979,7 +979,7 @@ public class CombatUtil {
|
||||
}
|
||||
|
||||
boolean isFree = attackCost.getTotalMana().isZero() && attackCost.isOnlyManaCost(); // true if needless to pay
|
||||
return isFree || c.getController().getController().payManaOptional(c, attackCost, "Pay additional cost to declare " + c + " an attacker", ManaPaymentPurpose.DeclareAttacker);
|
||||
return isFree || c.getController().getController().payManaOptional(c, attackCost, null, "Pay additional cost to declare " + c + " an attacker", ManaPaymentPurpose.DeclareAttacker);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -595,7 +595,7 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
|
||||
boolean hasPaid = blockCost.getTotalMana().isZero() && blockCost.isOnlyManaCost(); // true if needless to pay
|
||||
if (!hasPaid) {
|
||||
hasPaid = blocker.getController().getController().payManaOptional(blocker, blockCost, "Pay cost to declare " + blocker + " a blocker", ManaPaymentPurpose.DeclareBlocker);
|
||||
hasPaid = blocker.getController().getController().payManaOptional(blocker, blockCost, null, "Pay cost to declare " + blocker + " a blocker", ManaPaymentPurpose.DeclareBlocker);
|
||||
}
|
||||
return hasPaid;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ public class Upkeep extends Phase {
|
||||
@Override
|
||||
public void resolve() {
|
||||
Cost cost = c.getEchoCost();
|
||||
boolean hasPaid = c.getController().getController().payManaOptional(c, cost, "Echo for " + c, ManaPaymentPurpose.Echo);
|
||||
boolean hasPaid = c.getController().getController().payManaOptional(c, cost, this, "Echo for " + c, ManaPaymentPurpose.Echo);
|
||||
|
||||
if (!hasPaid)
|
||||
game.getAction().sacrifice(c, this);;
|
||||
@@ -262,7 +262,7 @@ public class Upkeep extends Phase {
|
||||
final Ability upkeepAbility = new Ability(c, ManaCost.ZERO) {
|
||||
@Override
|
||||
public void resolve() {
|
||||
boolean isPaid = controller.getController().payManaOptional(c, upkeepCost, "Cumulative upkeep for " + c, ManaPaymentPurpose.CumulativeUpkeep);
|
||||
boolean isPaid = controller.getController().payManaOptional(c, upkeepCost, this, "Cumulative upkeep for " + c, ManaPaymentPurpose.CumulativeUpkeep);
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
runParams.put("CumulativeUpkeepPaid", (Boolean) isPaid);
|
||||
runParams.put("Card", this.getSourceCard());
|
||||
|
||||
@@ -25,6 +25,7 @@ import forge.card.cost.CostDamage;
|
||||
import forge.card.cost.CostDiscard;
|
||||
import forge.card.cost.CostDraw;
|
||||
import forge.card.cost.CostExile;
|
||||
import forge.card.cost.CostGainLife;
|
||||
import forge.card.cost.CostMill;
|
||||
import forge.card.cost.CostPart;
|
||||
import forge.card.cost.CostPartMana;
|
||||
@@ -303,7 +304,7 @@ public class HumanPlay {
|
||||
if (!parts.isEmpty()) {
|
||||
costPart = parts.get(0);
|
||||
}
|
||||
final String orString = sourceAbility == null ? "" : " (or: " + sourceAbility.getStackDescription() + ")";
|
||||
final String orString = prompt != null ? "" : " (or: " + sourceAbility.getStackDescription() + ")";
|
||||
|
||||
if (parts.isEmpty() || costPart.getAmount().equals("0")) {
|
||||
return GuiDialog.confirm(source, "Do you want to pay 0?" + orString);
|
||||
@@ -342,7 +343,7 @@ public class HumanPlay {
|
||||
|
||||
sb.append("Do you want to ");
|
||||
sb.append(res.contains(p) ? "" : "let that player ");
|
||||
sb.append(amount);
|
||||
sb.append("draw " + amount);
|
||||
sb.append(" card(s)?" + orString);
|
||||
|
||||
if (!GuiDialog.confirm(source, sb.toString())) {
|
||||
@@ -354,6 +355,12 @@ public class HumanPlay {
|
||||
}
|
||||
}
|
||||
|
||||
else if (part instanceof CostGainLife) {
|
||||
if (!part.payHuman(sourceAbility, p.getGame())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
else if (part instanceof CostMill) {
|
||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
||||
final List<Card> list = p.getCardsIn(ZoneType.Library);
|
||||
|
||||
@@ -140,7 +140,7 @@ public abstract class PlayerController {
|
||||
public abstract void takePriority();
|
||||
|
||||
public abstract List<Card> chooseCardsToDiscardToMaximumHandSize(int numDiscard);
|
||||
public abstract boolean payManaOptional(Card card, Cost cost, String prompt, ManaPaymentPurpose purpose);
|
||||
public abstract boolean payManaOptional(Card card, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose);
|
||||
|
||||
public abstract int chooseNumber(SpellAbility sa, String title, int min, int max);
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean payManaOptional(Card c, Cost cost, String prompt, ManaPaymentPurpose purpose) {
|
||||
public boolean payManaOptional(Card c, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose) {
|
||||
final Ability ability = new AbilityStatic(c, cost, null) { @Override public void resolve() {} };
|
||||
ability.setActivatingPlayer(c.getController());
|
||||
|
||||
|
||||
@@ -585,8 +585,8 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
* @see forge.game.player.PlayerController#payManaOptional(forge.Card, forge.card.cost.Cost)
|
||||
*/
|
||||
@Override
|
||||
public boolean payManaOptional(Card c, Cost cost, String prompt, ManaPaymentPurpose purpose) {
|
||||
return HumanPlay.payCostDuringAbilityResolve(player, c, cost, null, prompt);
|
||||
public boolean payManaOptional(Card c, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose) {
|
||||
return HumanPlay.payCostDuringAbilityResolve(player, c, cost, sa, prompt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
do {
|
||||
int mkMagnitude = sp.getSourceCard().getKickerMagnitude();
|
||||
String prompt = String.format("Multikicker for %s\r\nTimes Kicked: %d\r\n", sp.getSourceCard(), mkMagnitude );
|
||||
hasPaid = activating.getController().payManaOptional(sp.getSourceCard(), costMultikicker, prompt, ManaPaymentPurpose.Multikicker);
|
||||
hasPaid = activating.getController().payManaOptional(sp.getSourceCard(), costMultikicker, sp, prompt, ManaPaymentPurpose.Multikicker);
|
||||
if( hasPaid )
|
||||
sp.getSourceCard().addMultiKickerMagnitude(1);
|
||||
} while( hasPaid );
|
||||
@@ -348,12 +348,12 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
// doesn't happen here
|
||||
|
||||
final Player activating = sp.getActivatingPlayer();
|
||||
final Cost costMultikicker = new Cost(sp.getPayCosts().getTotalMana(), false);
|
||||
final Cost costReplicate = new Cost(sp.getPayCosts().getTotalMana(), false);
|
||||
boolean hasPaid = false;
|
||||
|
||||
do {
|
||||
String prompt = String.format("Replicate for %s\r\nTimes Replicated: %d\r\n", sp.getSourceCard(), magnitude);
|
||||
hasPaid = activating.getController().payManaOptional(sp.getSourceCard(), costMultikicker, prompt, ManaPaymentPurpose.Replicate);
|
||||
hasPaid = activating.getController().payManaOptional(sp.getSourceCard(), costReplicate, sp, prompt, ManaPaymentPurpose.Replicate);
|
||||
if( hasPaid )
|
||||
magnitude++;
|
||||
} while( hasPaid );
|
||||
|
||||
Reference in New Issue
Block a user