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:
@@ -18,14 +18,13 @@
|
|||||||
package forge.game.cost;
|
package forge.game.cost;
|
||||||
|
|
||||||
import forge.game.ability.effects.FlipCoinEffect;
|
import forge.game.ability.effects.FlipCoinEffect;
|
||||||
import forge.game.card.Card;
|
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is for the "FlipCoin" Cost
|
* This is for the "FlipCoin" Cost
|
||||||
*/
|
*/
|
||||||
public class CostFlipCoin extends CostPartWithList {
|
public class CostFlipCoin extends CostPart {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializables need a version ID.
|
* Serializables need a version ID.
|
||||||
@@ -42,18 +41,6 @@ public class CostFlipCoin extends CostPartWithList {
|
|||||||
this.setAmount(amount);
|
this.setAmount(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.card.cost.CostPartWithList#getHashForList()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getHashForLKIList() {
|
|
||||||
return "Flipped";
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getHashForCardList() {
|
|
||||||
return "FlippedCards";
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
@@ -71,15 +58,13 @@ public class CostFlipCoin extends CostPartWithList {
|
|||||||
return Cost.convertAmountTypeToWords(this.convertAmount(), this.getAmount(), "Coin");
|
return Cost.convertAmountTypeToWords(this.convertAmount(), this.getAmount(), "Coin");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.card.cost.CostPartWithList#executePayment(forge.card.spellability.SpellAbility, forge.Card)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Card doPayment(SpellAbility ability, Card targetCard) {
|
public boolean payAsDecided(Player payer, PaymentDecision pd, SpellAbility sa) {
|
||||||
final Player activator = ability.getActivatingPlayer();
|
int m = FlipCoinEffect.getFilpMultiplier(payer);
|
||||||
int i = FlipCoinEffect.getFilpMultiplier(activator);
|
for (int i = 0; i < pd.c; i++) {
|
||||||
FlipCoinEffect.flipCoinCall(activator, ability, i);
|
FlipCoinEffect.flipCoinCall(payer, sa, m);
|
||||||
return targetCard;
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T accept(ICostVisitor<T> visitor) {
|
public <T> T accept(ICostVisitor<T> visitor) {
|
||||||
|
|||||||
@@ -132,12 +132,8 @@ public abstract class CostPartWithList extends CostPart {
|
|||||||
}
|
}
|
||||||
cardList.addAll(doListPayment(ability, targetCards));
|
cardList.addAll(doListPayment(ability, targetCards));
|
||||||
} else {
|
} else {
|
||||||
if (targetCards.isEmpty() && this instanceof CostFlipCoin) {
|
for (Card c : targetCards) {
|
||||||
doPayment(ability, null); // TODO: generalize for other cost types if necessary
|
executePayment(ability, c);
|
||||||
} else {
|
|
||||||
for (Card c : targetCards) {
|
|
||||||
executePayment(ability, c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleChangeZoneTrigger(payer, ability, targetCards);
|
handleChangeZoneTrigger(payer, ability, targetCards);
|
||||||
|
|||||||
@@ -1658,8 +1658,8 @@ lblOr=oder
|
|||||||
lblDoYouWantPay=Möchtest du bezahlen:
|
lblDoYouWantPay=Möchtest du bezahlen:
|
||||||
lblDoYouWantPayNLife=Möchtest du {0} Leben bezahlen?
|
lblDoYouWantPayNLife=Möchtest du {0} Leben bezahlen?
|
||||||
lblDoyouWantTo=Möchtest du
|
lblDoyouWantTo=Möchtest du
|
||||||
lblDoYouWantMillNCardsOrDoAction=Möchtest du {0} Karte(n) von der Bibliothek auf den Friedhof legen?
|
lblDoYouWantMillNCardsOrDoAction=Möchtest du {0} Karte(n) von der Bibliothek auf den Friedhof legen? {1}
|
||||||
lblDoYouWantFlipNCoinOrDoAction=Möchtest du {0} Münze(n) werfen? {1}
|
lblDoYouWantFlipNCoinAction=Möchtest du {0} Münze(n) werfen?
|
||||||
lblDoYouWantRemoveNTargetTypeCounterFromCard=Möchtest du {0} {1}-Marken von {2} entfernen?
|
lblDoYouWantRemoveNTargetTypeCounterFromCard=Möchtest du {0} {1}-Marken von {2} entfernen?
|
||||||
lblDoYouWantRemoveCountersFromCard=Möchtest du Marken von {0} entfernen?
|
lblDoYouWantRemoveCountersFromCard=Möchtest du Marken von {0} entfernen?
|
||||||
lblDoYouWantExileNCardsFromYourLibrary=Möchtest du {0} Karte(n) von deiner Bibliothek ins Exil schicken?
|
lblDoYouWantExileNCardsFromYourLibrary=Möchtest du {0} Karte(n) von deiner Bibliothek ins Exil schicken?
|
||||||
|
|||||||
@@ -1659,7 +1659,7 @@ lblDoYouWantPay=Do you want to pay
|
|||||||
lblDoYouWantPayNLife=Do you want to pay {0} life?
|
lblDoYouWantPayNLife=Do you want to pay {0} life?
|
||||||
lblDoyouWantTo=Do you want to
|
lblDoyouWantTo=Do you want to
|
||||||
lblDoYouWantMillNCardsOrDoAction=Do you want to mill {0} card(s)? {1}
|
lblDoYouWantMillNCardsOrDoAction=Do you want to mill {0} card(s)? {1}
|
||||||
lblDoYouWantFlipNCoinOrDoAction=Do you want to flip {0} coin(s)? {1}
|
lblDoYouWantFlipNCoinAction=Do you want to flip {0} coin(s)?
|
||||||
lblDoYouWantRemoveNTargetTypeCounterFromCard=Do you want to remove {0} {1} counter from {2}?
|
lblDoYouWantRemoveNTargetTypeCounterFromCard=Do you want to remove {0} {1} counter from {2}?
|
||||||
lblDoYouWantRemoveCountersFromCard=Do you want to remove counters from {0}?
|
lblDoYouWantRemoveCountersFromCard=Do you want to remove counters from {0}?
|
||||||
lblDoYouWantExileNCardsFromYourLibrary=Do you want to exile {0} card(s) from your library?
|
lblDoYouWantExileNCardsFromYourLibrary=Do you want to exile {0} card(s) from your library?
|
||||||
|
|||||||
@@ -1659,7 +1659,7 @@ lblDoYouWantPay=¿Quieres pagar
|
|||||||
lblDoYouWantPayNLife=¿Quieres pagar {0} de vida?
|
lblDoYouWantPayNLife=¿Quieres pagar {0} de vida?
|
||||||
lblDoyouWantTo=¿Quieres
|
lblDoyouWantTo=¿Quieres
|
||||||
lblDoYouWantMillNCardsOrDoAction=¿Quieres moler {0} carta(s)? {1}
|
lblDoYouWantMillNCardsOrDoAction=¿Quieres moler {0} carta(s)? {1}
|
||||||
lblDoYouWantFlipNCoinOrDoAction=¿Quieres lanzar {0} moneda(s)? {1}
|
lblDoYouWantFlipNCoinAction=¿Quieres lanzar {0} moneda(s)?
|
||||||
lblDoYouWantRemoveNTargetTypeCounterFromCard=¿Quieres quitar el contador {0} {1} de {2}?
|
lblDoYouWantRemoveNTargetTypeCounterFromCard=¿Quieres quitar el contador {0} {1} de {2}?
|
||||||
lblDoYouWantRemoveCountersFromCard=¿Quieres quitar los contadores de {0}?
|
lblDoYouWantRemoveCountersFromCard=¿Quieres quitar los contadores de {0}?
|
||||||
lblDoYouWantExileNCardsFromYourLibrary=¿Quieres exiliar {0} carta(s) de tu biblioteca?
|
lblDoYouWantExileNCardsFromYourLibrary=¿Quieres exiliar {0} carta(s) de tu biblioteca?
|
||||||
|
|||||||
@@ -1659,7 +1659,7 @@ lblDoYouWantPay=Do you want to pay
|
|||||||
lblDoYouWantPayNLife=Do you want to pay {0} life?
|
lblDoYouWantPayNLife=Do you want to pay {0} life?
|
||||||
lblDoyouWantTo=Do you want to
|
lblDoyouWantTo=Do you want to
|
||||||
lblDoYouWantMillNCardsOrDoAction=Do you want to mill {0} card(s)? {1}
|
lblDoYouWantMillNCardsOrDoAction=Do you want to mill {0} card(s)? {1}
|
||||||
lblDoYouWantFlipNCoinOrDoAction=Do you want to flip {0} coin(s)? {1}
|
lblDoYouWantFlipNCoinAction=Do you want to flip {0} coin(s)?
|
||||||
lblDoYouWantRemoveNTargetTypeCounterFromCard=Do you want to remove {0} {1} counter from {2}?
|
lblDoYouWantRemoveNTargetTypeCounterFromCard=Do you want to remove {0} {1} counter from {2}?
|
||||||
lblDoYouWantRemoveCountersFromCard=Do you want to remove counters from {0}?
|
lblDoYouWantRemoveCountersFromCard=Do you want to remove counters from {0}?
|
||||||
lblDoYouWantExileNCardsFromYourLibrary=Do you want to exile {0} card(s) from your library?
|
lblDoYouWantExileNCardsFromYourLibrary=Do you want to exile {0} card(s) from your library?
|
||||||
|
|||||||
@@ -1659,7 +1659,7 @@ lblDoYouWantPay=你想要支付
|
|||||||
lblDoYouWantPayNLife=你想要支付{0}点生命吗?
|
lblDoYouWantPayNLife=你想要支付{0}点生命吗?
|
||||||
lblDoyouWantTo=你想要
|
lblDoyouWantTo=你想要
|
||||||
lblDoYouWantMillNCardsOrDoAction=你想要磨{0}张牌吗? {1}
|
lblDoYouWantMillNCardsOrDoAction=你想要磨{0}张牌吗? {1}
|
||||||
lblDoYouWantFlipNCoinOrDoAction=你想要抛{0}个硬币吗? {1}
|
lblDoYouWantFlipNCoinAction=你想要抛{0}个硬币吗?
|
||||||
lblDoYouWantRemoveNTargetTypeCounterFromCard=你想要从{2}移除{0}个{1}指示物吗?
|
lblDoYouWantRemoveNTargetTypeCounterFromCard=你想要从{2}移除{0}个{1}指示物吗?
|
||||||
lblDoYouWantRemoveCountersFromCard=你想要从{0}删除指示物吗?
|
lblDoYouWantRemoveCountersFromCard=你想要从{0}删除指示物吗?
|
||||||
lblDoYouWantExileNCardsFromYourLibrary=你想要从你的牌库放逐{0}张牌吗?
|
lblDoYouWantExileNCardsFromYourLibrary=你想要从你的牌库放逐{0}张牌吗?
|
||||||
|
|||||||
@@ -525,14 +525,13 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
Integer c = cost.convertAmount();
|
Integer c = cost.convertAmount();
|
||||||
|
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
final String sVar = ability.getSVar(amount);
|
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||||
// Generalize this
|
|
||||||
if (sVar.equals("XChoice")) {
|
|
||||||
c = chooseXValue(cost.getLKIList().size());
|
|
||||||
} else {
|
|
||||||
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);
|
return PaymentDecision.number(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import forge.game.GameEntityViewMap;
|
|||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.ability.ApiType;
|
import forge.game.ability.ApiType;
|
||||||
import forge.game.ability.effects.CharmEffect;
|
import forge.game.ability.effects.CharmEffect;
|
||||||
import forge.game.ability.effects.FlipCoinEffect;
|
|
||||||
import forge.game.card.*;
|
import forge.game.card.*;
|
||||||
import forge.game.card.CardPredicates.Presets;
|
import forge.game.card.CardPredicates.Presets;
|
||||||
import forge.game.cost.*;
|
import forge.game.cost.*;
|
||||||
@@ -322,16 +321,22 @@ public class HumanPlay {
|
|||||||
((CostMill) part).payAsDecided(p, PaymentDecision.card(listmill), sourceAbility);
|
((CostMill) part).payAsDecided(p, PaymentDecision.card(listmill), sourceAbility);
|
||||||
}
|
}
|
||||||
else if (part instanceof CostFlipCoin) {
|
else if (part instanceof CostFlipCoin) {
|
||||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
if (!part.canPay(sourceAbility, p)) {
|
||||||
if (!p.getController().confirmPayment(part, Localizer.getInstance().getMessage("lblDoYouWantFlipNCoinOrDoAction", String.valueOf(amount), orString), sourceAbility)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int n = FlipCoinEffect.getFilpMultiplier(p);
|
|
||||||
for (int i = 0; i < amount; i++) {
|
PaymentDecision pd = part.accept(hcd);
|
||||||
FlipCoinEffect.flipCoinCall(p, sourceAbility, n);
|
|
||||||
}
|
if (pd == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
part.payAsDecided(p, pd, sourceAbility);
|
||||||
}
|
}
|
||||||
else if (part instanceof CostDamage) {
|
else if (part instanceof CostDamage) {
|
||||||
|
if (!part.canPay(sourceAbility, p)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// not a pay life but damage!
|
// not a pay life but damage!
|
||||||
PaymentDecision pd = part.accept(hcd);
|
PaymentDecision pd = part.accept(hcd);
|
||||||
|
|
||||||
@@ -341,6 +346,10 @@ public class HumanPlay {
|
|||||||
part.payAsDecided(p, pd, sourceAbility);
|
part.payAsDecided(p, pd, sourceAbility);
|
||||||
}
|
}
|
||||||
else if (part instanceof CostPutCounter) {
|
else if (part instanceof CostPutCounter) {
|
||||||
|
if (!part.canPay(sourceAbility, p)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
PaymentDecision pd = part.accept(hcd);
|
PaymentDecision pd = part.accept(hcd);
|
||||||
|
|
||||||
if (pd == null)
|
if (pd == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user