mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Simplify implementation of pre-announcing X
This commit is contained in:
@@ -132,14 +132,13 @@ public class CostPayment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean payCost(final CostDecisionMakerBase decisionMaker) {
|
public boolean payCost(final CostDecisionMakerBase decisionMaker) {
|
||||||
|
|
||||||
final List<CostPart> costParts = this.getCost().getCostPartsWithZeroMana();
|
final List<CostPart> costParts = this.getCost().getCostPartsWithZeroMana();
|
||||||
for (final CostPart part : costParts) {
|
for (final CostPart part : costParts) {
|
||||||
PaymentDecision pd = part.accept(decisionMaker);
|
PaymentDecision pd = part.accept(decisionMaker);
|
||||||
|
|
||||||
if ( null == pd || !part.payAsDecided(decisionMaker.getPlayer(), pd, ability))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
if (pd == null || !part.payAsDecided(decisionMaker.getPlayer(), pd, ability)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this.paidCostParts.add(part);
|
this.paidCostParts.add(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,7 @@ public class ManaCostAdjustment {
|
|||||||
|
|
||||||
public static final void adjust(ManaCostBeingPaid cost, final SpellAbility sa, boolean test) {
|
public static final void adjust(ManaCostBeingPaid cost, final SpellAbility sa, boolean test) {
|
||||||
final Game game = sa.getActivatingPlayer().getGame();
|
final Game game = sa.getActivatingPlayer().getGame();
|
||||||
// Beached
|
|
||||||
final Card originalCard = sa.getHostCard();
|
final Card originalCard = sa.getHostCard();
|
||||||
if (sa.isXCost() && !originalCard.isCopiedSpell()) {
|
|
||||||
originalCard.setXManaCostPaid(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sa.isTrigger()) {
|
if (sa.isTrigger()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -696,6 +696,9 @@ public class HumanPlay {
|
|||||||
toPay.setXManaCostPaid(xPaid, ability.getParam("XColor"));
|
toPay.setXManaCostPaid(xPaid, ability.getParam("XColor"));
|
||||||
source.setXManaCostPaid(xPaid);
|
source.setXManaCostPaid(xPaid);
|
||||||
}
|
}
|
||||||
|
else if (source.getXManaCostPaid() > 0) { //ensure pre-announced X value retained
|
||||||
|
toPay.setXManaCostPaid(source.getXManaCostPaid(), ability.getParam("XColor"));
|
||||||
|
}
|
||||||
|
|
||||||
int timesMultikicked = source.getKickerMagnitude();
|
int timesMultikicked = source.getKickerMagnitude();
|
||||||
if (timesMultikicked > 0 && ability.isAnnouncing("Multikicker")) {
|
if (timesMultikicked > 0 && ability.isAnnouncing("Multikicker")) {
|
||||||
@@ -716,7 +719,7 @@ public class HumanPlay {
|
|||||||
if (isActivatedSa) {
|
if (isActivatedSa) {
|
||||||
ManaCostAdjustment.adjust(toPay, ability, false);
|
ManaCostAdjustment.adjust(toPay, ability, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
InputPayMana inpPayment;
|
InputPayMana inpPayment;
|
||||||
if (ability.isOffering() && ability.getSacrificedAsOffering() == null) {
|
if (ability.isOffering() && ability.getSacrificedAsOffering() == null) {
|
||||||
System.out.println("Sacrifice input for Offering cancelled");
|
System.out.println("Sacrifice input for Offering cancelled");
|
||||||
|
|||||||
@@ -229,20 +229,12 @@ public class HumanPlaySpellAbility {
|
|||||||
|
|
||||||
if (needX && manaCost != null && manaCost.getAmountOfX() > 0) {
|
if (needX && manaCost != null && manaCost.getAmountOfX() > 0) {
|
||||||
String sVar = ability.getSVar("X"); //only prompt for new X value if card doesn't determine it another way
|
String sVar = ability.getSVar("X"); //only prompt for new X value if card doesn't determine it another way
|
||||||
if ("Count$xPaid".equals(sVar) || StringUtils.isNumeric(sVar) || sVar.isEmpty()) {
|
if ("Count$xPaid".equals(sVar) || sVar.isEmpty()) {
|
||||||
Integer value = controller.announceRequirements(ability, "X", allowZero && manaCost.canXbe0());
|
Integer value = controller.announceRequirements(ability, "X", allowZero && manaCost.canXbe0());
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
card.setXManaCostPaid(value);
|
||||||
ability.setSVar("X", value.toString());
|
|
||||||
card.setSVar("X", value.toString());
|
|
||||||
|
|
||||||
// announce to sub-abilities
|
|
||||||
SpellAbility sub = ability;
|
|
||||||
while ((sub = sub.getSubAbility()) != null) {
|
|
||||||
sub.setSVar("X", value.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user