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,20 +244,23 @@ public class InputAttack extends InputSyncronizedBase {
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(card, currentDefender)); GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(card, currentDefender));
} }
private boolean canUndeclareAttacker(Card card) {
return !card.hasKeyword("CARDNAME attacks each turn if able.") &&
!card.hasStartOfKeyword("CARDNAME attacks specific player each combat if able");
}
private boolean undeclareAttacker(Card card) { private boolean undeclareAttacker(Card card) {
if (card.hasKeyword("CARDNAME attacks each turn if able.") || if (canUndeclareAttacker(card)) {
card.hasStartOfKeyword("CARDNAME attacks specific player each combat if able")) { // TODO Is there no way to attacks each turn cards to attack Planeswalkers?
return false; combat.removeFromCombat(card);
GuiBase.getInterface().setUsedToPay(card, false);
// When removing an attacker clear the attacking band
activateBand(null);
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(card, null));
return true;
} }
return false;
// TODO Is there no way to attacks each turn cards to attack Planeswalkers?
combat.removeFromCombat(card);
GuiBase.getInterface().setUsedToPay(card, false);
// When removing an attacker clear the attacking band
activateBand(null);
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(card, null));
return true;
} }
private final void setCurrentDefender(GameEntity def) { private final void setCurrentDefender(GameEntity def) {