mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Refactor how human pays for FlipCoin part
This commit is contained in:
@@ -525,14 +525,13 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
Integer c = cost.convertAmount();
|
||||
|
||||
if (c == null) {
|
||||
final String sVar = ability.getSVar(amount);
|
||||
// Generalize this
|
||||
if (sVar.equals("XChoice")) {
|
||||
c = chooseXValue(cost.getLKIList().size());
|
||||
} else {
|
||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||
}
|
||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||
}
|
||||
|
||||
if (!player.getController().confirmPayment(cost, Localizer.getInstance().getMessage("lblDoYouWantFlipNCoinAction", String.valueOf(c)), ability)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return PaymentDecision.number(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import forge.game.GameEntityViewMap;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.ability.effects.CharmEffect;
|
||||
import forge.game.ability.effects.FlipCoinEffect;
|
||||
import forge.game.card.*;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.cost.*;
|
||||
@@ -322,16 +321,22 @@ public class HumanPlay {
|
||||
((CostMill) part).payAsDecided(p, PaymentDecision.card(listmill), sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostFlipCoin) {
|
||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
||||
if (!p.getController().confirmPayment(part, Localizer.getInstance().getMessage("lblDoYouWantFlipNCoinOrDoAction", String.valueOf(amount), orString), sourceAbility)) {
|
||||
if (!part.canPay(sourceAbility, p)) {
|
||||
return false;
|
||||
}
|
||||
final int n = FlipCoinEffect.getFilpMultiplier(p);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
FlipCoinEffect.flipCoinCall(p, sourceAbility, n);
|
||||
}
|
||||
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
if (pd == null)
|
||||
return false;
|
||||
else
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostDamage) {
|
||||
if (!part.canPay(sourceAbility, p)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// not a pay life but damage!
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
@@ -341,6 +346,10 @@ public class HumanPlay {
|
||||
part.payAsDecided(p, pd, sourceAbility);
|
||||
}
|
||||
else if (part instanceof CostPutCounter) {
|
||||
if (!part.canPay(sourceAbility, p)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PaymentDecision pd = part.accept(hcd);
|
||||
|
||||
if (pd == null)
|
||||
|
||||
Reference in New Issue
Block a user