Reanme Cancel to Call Back for calling back attackers

This commit is contained in:
drdev
2014-05-31 16:38:44 +00:00
parent 4029d0d452
commit 1687445dbb

View File

@@ -97,12 +97,22 @@ public class InputAttack extends InputSyncronizedBase {
updateMessage(); updateMessage();
} }
//determine whether currently attackers can be called back (undeclared)
private boolean canCallBackAttackers() {
for (Card c : combat.getAttackers()) {
if (canUndeclareAttacker(c)) {
return true;
}
}
return false;
}
private void updatePrompt() { private void updatePrompt() {
if (combat.getAttackers().isEmpty()) { if (canCallBackAttackers()) {
ButtonUtil.setButtonText("OK", "Alpha Strike"); ButtonUtil.setButtonText("OK", "Call Back");
} }
else { else {
ButtonUtil.setButtonText("OK", "Cancel"); ButtonUtil.setButtonText("OK", "Alpha Strike");
} }
ButtonUtil.enableAllFocusOk(); ButtonUtil.enableAllFocusOk();
} }
@@ -121,7 +131,14 @@ public class InputAttack extends InputSyncronizedBase {
@Override @Override
protected final void onCancel() { protected final void onCancel() {
//either alpha strike or undeclare all attackers based on whether any attackers have been declared //either alpha strike or undeclare all attackers based on whether any attackers have been declared
if (combat.getAttackers().isEmpty()) { if (canCallBackAttackers()) {
//undeclare all attackers
List<Card> attackers = new ArrayList<Card>(combat.getAttackers()); //must copy list since it will be modified
for (Card c : attackers) {
undeclareAttacker(c);
}
}
else {
//alpha strike //alpha strike
List<Player> defenders = playerAttacks.getOpponents(); List<Player> defenders = playerAttacks.getOpponents();
@@ -138,13 +155,6 @@ public class InputAttack extends InputSyncronizedBase {
} }
} }
} }
else {
//undeclare all attackers
List<Card> attackers = new ArrayList<Card>(combat.getAttackers()); //must copy list since it will be modified
for (Card c : attackers) {
undeclareAttacker(c);
}
}
updateMessage(); updateMessage();
} }
@@ -234,12 +244,13 @@ public class InputAttack extends InputSyncronizedBase {
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(card, currentDefender)); GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(card, currentDefender));
} }
private boolean undeclareAttacker(Card card) { private boolean canUndeclareAttacker(Card card) {
if (card.hasKeyword("CARDNAME attacks each turn if able.") || return !card.hasKeyword("CARDNAME attacks each turn if able.") &&
card.hasStartOfKeyword("CARDNAME attacks specific player each combat if able")) { !card.hasStartOfKeyword("CARDNAME attacks specific player each combat if able");
return false;
} }
private boolean undeclareAttacker(Card card) {
if (canUndeclareAttacker(card)) {
// TODO Is there no way to attacks each turn cards to attack Planeswalkers? // TODO Is there no way to attacks each turn cards to attack Planeswalkers?
combat.removeFromCombat(card); combat.removeFromCombat(card);
GuiBase.getInterface().setUsedToPay(card, false); GuiBase.getInterface().setUsedToPay(card, false);
@@ -249,6 +260,8 @@ public class InputAttack extends InputSyncronizedBase {
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(card, null)); GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(card, null));
return true; return true;
} }
return false;
}
private final void setCurrentDefender(GameEntity def) { private final void setCurrentDefender(GameEntity def) {
currentDefender = def; currentDefender = def;