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;
}
if (this.getAmountOfX() > 0) {
source.setXManaCostPaid(0);
InputPayment inpPayment = new InputPayManaX(ability, this.getAmountOfX(), this.canXbe0());
FThreads.setInputAndWait(inpPayment);
if(!inpPayment.isPaid())
return false;
if( !"X".equals(ability.getParam("Announce")) ) {
source.setXManaCostPaid(0);
InputPayment inpPayment = new InputPayManaX(ability, this.getAmountOfX(), this.canXbe0());
FThreads.setInputAndWait(inpPayment);
if(!inpPayment.isPaid())
return false;
} else {
String xVar = ability.getSVar("X");
String xVal = xVar.split("\\$")[1];
source.setXManaCostPaid(Integer.parseInt(xVal));
}
}
return true;

View File

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

View File

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

View File

@@ -214,9 +214,9 @@ public class TargetSelection {
}
}
private Target target = null;
private SpellAbility ability = null;
private Card card = null;
private final Target target;
private final SpellAbility ability;
private TargetSelection subSelection = null;
/**
@@ -249,7 +249,7 @@ public class TargetSelection {
* @return a {@link forge.Card} object.
*/
public final Card getCard() {
return this.card;
return this.ability.getSourceCard();
}
private SpellAbilityRequirements req = null;
@@ -314,7 +314,6 @@ public class TargetSelection {
public TargetSelection(final Target tgt, final SpellAbility sa) {
this.target = tgt;
this.ability = sa;
this.card = sa.getSourceCard();
}
/**
@@ -352,14 +351,14 @@ public class TargetSelection {
*/
public final boolean chooseTargets() {
// 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;
return false;
}
if (!this.doesTarget()
|| this.bTargetingDone && this.target.isMinTargetsChosen(this.card, this.ability)
|| this.target.isMaxTargetsChosen(this.card, this.ability)
|| this.bTargetingDone && this.target.isMinTargetsChosen(this.getCard(), this.ability)
|| this.target.isMaxTargetsChosen(this.getCard(), this.ability)
|| this.target.isDividedAsYouChoose() && this.target.getStillToDivide() == 0) {
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
this.bCancel = true;
return false;
@@ -505,7 +504,7 @@ public class TargetSelection {
}
// If the cards must have a specific controller
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()) {
Player controller = pl.get(0);
choices = CardLists.filterControlledBy(choices, controller);

View File

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

View File

@@ -149,9 +149,9 @@ public class PlayerControllerAi extends PlayerController {
}
@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
return null;
return null; // return incorrect value to indicate that
}
@Override

View File

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