fixed UI for announce.

Announced cost for cards with XX like entreat the angels are paid correctly
This commit is contained in:
Maxmtg
2013-03-31 21:31:46 +00:00
parent 1aaf6c5a08
commit 05f3ef372d
8 changed files with 34 additions and 35 deletions

View File

@@ -221,11 +221,17 @@ public class CostPartMana extends CostPart {
return false; return false;
} }
if (this.getAmountOfX() > 0) { if (this.getAmountOfX() > 0) {
if( !"X".equals(ability.getParam("Announce")) ) {
source.setXManaCostPaid(0); source.setXManaCostPaid(0);
InputPayment inpPayment = new InputPayManaX(ability, this.getAmountOfX(), this.canXbe0()); InputPayment inpPayment = new InputPayManaX(ability, this.getAmountOfX(), this.canXbe0());
FThreads.setInputAndWait(inpPayment); FThreads.setInputAndWait(inpPayment);
if(!inpPayment.isPaid()) if(!inpPayment.isPaid())
return false; return false;
} else {
String xVar = ability.getSVar("X");
String xVal = xVar.split("\\$")[1];
source.setXManaCostPaid(Integer.parseInt(xVal));
}
} }
return true; return true;

View File

@@ -20,7 +20,6 @@ package forge.card.spellability;
import java.util.ArrayList; import java.util.ArrayList;
import forge.Card; import forge.Card;
import forge.Singletons;
import forge.card.cost.Cost; import forge.card.cost.Cost;
import forge.card.cost.CostPayment; import forge.card.cost.CostPayment;
import forge.card.staticability.StaticAbility; import forge.card.staticability.StaticAbility;

View File

@@ -165,13 +165,9 @@ public class SpellAbilityRequirements {
String announce = ability.getParam("Announce"); String announce = ability.getParam("Announce");
if (announce != null) { if (announce != null) {
for(String aVar : announce.split(",")) { for(String aVar : announce.split(",")) {
String value = ability.getActivatingPlayer().getController().announceRequirements(ability, aVar); Integer value = ability.getActivatingPlayer().getController().announceRequirements(ability, aVar, ability.getPayCosts().getCostMana().canXbe0());
if (value == null || !StringUtils.isNumeric(value)) { if ( null == value )
return false; return false;
} else if (ability.getPayCosts().getCostMana() != null && !ability.getPayCosts().getCostMana().canXbe0()
&& Integer.parseInt(value) == 0) {
return false;
}
ability.setSVar(aVar, "Number$" + value); ability.setSVar(aVar, "Number$" + value);
ability.getSourceCard().setSVar(aVar, "Number$" + value); ability.getSourceCard().setSVar(aVar, "Number$" + value);
} }

View File

@@ -214,9 +214,9 @@ public class TargetSelection {
} }
} }
private Target target = null; private final Target target;
private SpellAbility ability = null; private final SpellAbility ability;
private Card card = null;
private TargetSelection subSelection = null; private TargetSelection subSelection = null;
/** /**
@@ -249,7 +249,7 @@ public class TargetSelection {
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public final Card getCard() { public final Card getCard() {
return this.card; return this.ability.getSourceCard();
} }
private SpellAbilityRequirements req = null; private SpellAbilityRequirements req = null;
@@ -314,7 +314,6 @@ public class TargetSelection {
public TargetSelection(final Target tgt, final SpellAbility sa) { public TargetSelection(final Target tgt, final SpellAbility sa) {
this.target = tgt; this.target = tgt;
this.ability = sa; this.ability = sa;
this.card = sa.getSourceCard();
} }
/** /**
@@ -352,14 +351,14 @@ public class TargetSelection {
*/ */
public final boolean chooseTargets() { public final boolean chooseTargets() {
// if not enough targets chosen, reset and cancel Ability // if not enough targets chosen, reset and cancel Ability
if (this.bCancel || (this.bTargetingDone && !this.target.isMinTargetsChosen(this.card, this.ability))) { if (this.bCancel || (this.bTargetingDone && !this.target.isMinTargetsChosen(this.getCard(), this.ability))) {
this.bCancel = true; this.bCancel = true;
return false; return false;
} }
if (!this.doesTarget() if (!this.doesTarget()
|| this.bTargetingDone && this.target.isMinTargetsChosen(this.card, this.ability) || this.bTargetingDone && this.target.isMinTargetsChosen(this.getCard(), this.ability)
|| this.target.isMaxTargetsChosen(this.card, this.ability) || this.target.isMaxTargetsChosen(this.getCard(), this.ability)
|| this.target.isDividedAsYouChoose() && this.target.getStillToDivide() == 0) { || this.target.isDividedAsYouChoose() && this.target.getStillToDivide() == 0) {
final AbilitySub abSub = this.ability.getSubAbility(); final AbilitySub abSub = this.ability.getSubAbility();
@@ -375,7 +374,7 @@ public class TargetSelection {
} }
} }
if (!this.target.hasCandidates(this.ability, true) && !this.target.isMinTargetsChosen(this.card, this.ability)) { if (!this.target.hasCandidates(this.ability, true) && !this.target.isMinTargetsChosen(this.getCard(), this.ability)) {
// Cancel ability if there aren't any valid Candidates // Cancel ability if there aren't any valid Candidates
this.bCancel = true; this.bCancel = true;
return false; return false;
@@ -505,7 +504,7 @@ public class TargetSelection {
} }
// If the cards must have a specific controller // If the cards must have a specific controller
if (tgt.getDefinedController() != null) { if (tgt.getDefinedController() != null) {
List<Player> pl = AbilityUtils.getDefinedPlayers(card, tgt.getDefinedController(), this.ability); List<Player> pl = AbilityUtils.getDefinedPlayers(getCard(), tgt.getDefinedController(), this.ability);
if (pl != null && !pl.isEmpty()) { if (pl != null && !pl.isEmpty()) {
Player controller = pl.get(0); Player controller = pl.get(0);
choices = CardLists.filterControlledBy(choices, controller); choices = CardLists.filterControlledBy(choices, controller);

View File

@@ -1384,7 +1384,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
this.numDrawnThisDrawStep++; this.numDrawnThisDrawStep++;
// Miracle draws // Miracle draws
if (this.numDrawnThisTurn == 1 && game.getPhaseHandler().getTurn() != 0) { if (this.numDrawnThisTurn == 1 && game.getPhaseHandler().getTurn() != 1) {
drawMiracle(c); drawMiracle(c);
} }

View File

@@ -94,7 +94,7 @@ public abstract class PlayerController {
public abstract Map<Card, Integer> assignCombatDamage(Card attacker, List<Card> blockers, int damageDealt, GameEntity defender); public abstract Map<Card, Integer> assignCombatDamage(Card attacker, List<Card> blockers, int damageDealt, GameEntity defender);
public abstract String announceRequirements(SpellAbility ability, String announce); public abstract Integer announceRequirements(SpellAbility ability, String announce, boolean allowZero);
public abstract List<Card> choosePermanentsToSacrifice(List<Card> validTargets, int amount, SpellAbility sa, boolean destroy, boolean isOptional); public abstract List<Card> choosePermanentsToSacrifice(List<Card> validTargets, int amount, SpellAbility sa, boolean destroy, boolean isOptional);

View File

@@ -149,9 +149,9 @@ public class PlayerControllerAi extends PlayerController {
} }
@Override @Override
public String announceRequirements(SpellAbility ability, String announce) { public Integer announceRequirements(SpellAbility ability, String announce, boolean allowZero) {
// For now, these "announcements" are made within the AI classes of the appropriate SA effects // For now, these "announcements" are made within the AI classes of the appropriate SA effects
return null; return null; // return incorrect value to indicate that
} }
@Override @Override

View File

@@ -211,12 +211,11 @@ public class PlayerControllerHuman extends PlayerController {
* @see forge.game.player.PlayerController#announceRequirements(java.lang.String) * @see forge.game.player.PlayerController#announceRequirements(java.lang.String)
*/ */
@Override @Override
public String announceRequirements(SpellAbility ability, String announce) { public Integer announceRequirements(SpellAbility ability, String announce, boolean canChooseZero) {
StringBuilder sb = new StringBuilder(ability.getSourceCard().getName()); List<Integer> options = new ArrayList<Integer>();
sb.append(" - How much will you announce for "); for(int i = canChooseZero ? 0 : 1; i < 100; i++)
sb.append(announce); options.add(Integer.valueOf(i));
sb.append("?"); return GuiChoose.oneOrNone(String.format("%s - How much will you announce for %s?", ability.getSourceCard().getName(), announce), options);
return JOptionPane.showInputDialog(sb.toString());
} }
/* (non-Javadoc) /* (non-Javadoc)