mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Reanme Cancel to Call Back for calling back attackers
This commit is contained in:
@@ -97,12 +97,22 @@ public class InputAttack extends InputSyncronizedBase {
|
||||
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() {
|
||||
if (combat.getAttackers().isEmpty()) {
|
||||
ButtonUtil.setButtonText("OK", "Alpha Strike");
|
||||
if (canCallBackAttackers()) {
|
||||
ButtonUtil.setButtonText("OK", "Call Back");
|
||||
}
|
||||
else {
|
||||
ButtonUtil.setButtonText("OK", "Cancel");
|
||||
ButtonUtil.setButtonText("OK", "Alpha Strike");
|
||||
}
|
||||
ButtonUtil.enableAllFocusOk();
|
||||
}
|
||||
@@ -121,7 +131,14 @@ public class InputAttack extends InputSyncronizedBase {
|
||||
@Override
|
||||
protected final void onCancel() {
|
||||
//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
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -234,12 +244,13 @@ public class InputAttack extends InputSyncronizedBase {
|
||||
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(card, currentDefender));
|
||||
}
|
||||
|
||||
private boolean undeclareAttacker(Card card) {
|
||||
if (card.hasKeyword("CARDNAME attacks each turn if able.") ||
|
||||
card.hasStartOfKeyword("CARDNAME attacks specific player each combat if able")) {
|
||||
return false;
|
||||
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) {
|
||||
if (canUndeclareAttacker(card)) {
|
||||
// TODO Is there no way to attacks each turn cards to attack Planeswalkers?
|
||||
combat.removeFromCombat(card);
|
||||
GuiBase.getInterface().setUsedToPay(card, false);
|
||||
@@ -249,6 +260,8 @@ public class InputAttack extends InputSyncronizedBase {
|
||||
GuiBase.getInterface().fireEvent(new UiEventAttackerDeclared(card, null));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private final void setCurrentDefender(GameEntity def) {
|
||||
currentDefender = def;
|
||||
|
||||
Reference in New Issue
Block a user