mirror of
https://github.com/correl/mage.git
synced 2024-11-24 19:19:56 +00:00
Added a button to attack with all available cratures.
This commit is contained in:
parent
dbfeea6ea2
commit
3eb1fd4047
5 changed files with 79 additions and 36 deletions
|
@ -47,6 +47,7 @@ import mage.client.components.MageTextArea;
|
||||||
import mage.client.dialog.MageDialog;
|
import mage.client.dialog.MageDialog;
|
||||||
import mage.client.util.audio.AudioManager;
|
import mage.client.util.audio.AudioManager;
|
||||||
import mage.client.util.gui.ArrowBuilder;
|
import mage.client.util.gui.ArrowBuilder;
|
||||||
|
import mage.constants.Constants;
|
||||||
import mage.constants.PlayerAction;
|
import mage.constants.PlayerAction;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -140,6 +141,12 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
endWithTimeout();
|
endWithTimeout();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (options != null && options.containsKey(Constants.Option.SPECIAL_BUTTON)) {
|
||||||
|
String specialText = (String) options.get(Constants.Option.SPECIAL_BUTTON);
|
||||||
|
this.btnSpecial.setVisible(true);
|
||||||
|
this.btnSpecial.setText(specialText);
|
||||||
|
this.helper.setSpecial(specialText, true);
|
||||||
|
} else {
|
||||||
this.btnSpecial.setVisible(special);
|
this.btnSpecial.setVisible(special);
|
||||||
this.btnSpecial.setText("Special");
|
this.btnSpecial.setText("Special");
|
||||||
this.helper.setSpecial("Special", special);
|
this.helper.setSpecial("Special", special);
|
||||||
|
@ -149,6 +156,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
this.btnSpecial.setText("Pay 2 life");
|
this.btnSpecial.setText("Pay 2 life");
|
||||||
this.helper.setSpecial("Pay 2 life", true);
|
this.helper.setSpecial("Pay 2 life", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
requestFocusIfPossible();
|
requestFocusIfPossible();
|
||||||
handleOptions(options);
|
handleOptions(options);
|
||||||
|
|
|
@ -1020,6 +1020,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
Map<String, Serializable> panelOptions = new HashMap<>();
|
Map<String, Serializable> panelOptions = new HashMap<>();
|
||||||
|
if (options != null) {
|
||||||
|
panelOptions.putAll(options);
|
||||||
|
}
|
||||||
panelOptions.put("your_turn", true);
|
panelOptions.put("your_turn", true);
|
||||||
String activePlayerText;
|
String activePlayerText;
|
||||||
if (gameView.getActivePlayerId().equals(playerId)) {
|
if (gameView.getActivePlayerId().equals(playerId)) {
|
||||||
|
|
|
@ -200,6 +200,7 @@ public class HelperPanel extends JPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// sets a darker background and higher simiss time fpr tooltip in the feedback / helper panel
|
||||||
textArea.addMouseListener(new MouseAdapter() {
|
textArea.addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,15 +25,14 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.constants;
|
package mage.constants;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
|
|
||||||
private Constants() {
|
private Constants() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
@ -74,13 +73,16 @@ public final class Constants {
|
||||||
public static final int PRIORITY_TIME_SEC = 1200;
|
public static final int PRIORITY_TIME_SEC = 1200;
|
||||||
|
|
||||||
public enum SessionState {
|
public enum SessionState {
|
||||||
|
|
||||||
DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_STARTING;
|
DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_STARTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Option {
|
public enum Option {
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
public static final String POSSIBLE_ATTACKERS = "possibleAttackers";
|
public static final String POSSIBLE_ATTACKERS = "possibleAttackers";
|
||||||
|
public static final String SPECIAL_BUTTON = "specialButton";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.combat.CombatGroup;
|
import mage.game.combat.CombatGroup;
|
||||||
import mage.game.draft.Draft;
|
import mage.game.draft.Draft;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.match.Match;
|
import mage.game.match.Match;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.tournament.Tournament;
|
import mage.game.tournament.Tournament;
|
||||||
|
@ -785,10 +786,29 @@ public class HumanPlayer extends PlayerImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options.put(Constants.Option.POSSIBLE_ATTACKERS, (Serializable) possibleAttackers);
|
options.put(Constants.Option.POSSIBLE_ATTACKERS, (Serializable) possibleAttackers);
|
||||||
|
if (possibleAttackers.size() > 0) {
|
||||||
|
options.put(Constants.Option.SPECIAL_BUTTON, (Serializable) "All attack");
|
||||||
|
}
|
||||||
|
|
||||||
game.fireSelectEvent(playerId, "Select attackers", options);
|
game.fireSelectEvent(playerId, "Select attackers", options);
|
||||||
waitForResponse(game);
|
waitForResponse(game);
|
||||||
if (response.getBoolean() != null) {
|
if (response.getString() != null && response.getString().equals("special")) {
|
||||||
|
setStoredBookmark(game.bookmarkState());
|
||||||
|
UUID attackedDefender = null;
|
||||||
|
if (game.getCombat().getDefenders().size() > 1) {
|
||||||
|
attackedDefender = selectDefenderForAllAttack(game.getCombat().getDefenders(), game);
|
||||||
|
} else if (game.getCombat().getDefenders().size() == 1) {
|
||||||
|
attackedDefender = game.getCombat().getDefenders().iterator().next();
|
||||||
|
}
|
||||||
|
for (Permanent attacker : game.getBattlefield().getAllActivePermanents(filterCreatureForCombat, getId(), game)) {
|
||||||
|
if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
|
||||||
|
GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER,
|
||||||
|
attackedDefender, attacker.getId(), attacker.getControllerId()), game)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
declareAttacker(attacker.getId(), attackedDefender, game, true);
|
||||||
|
}
|
||||||
|
} else if (response.getBoolean() != null) {
|
||||||
// check if enough attackers are declared
|
// check if enough attackers are declared
|
||||||
if (!game.getCombat().getCreaturesForcedToAttack().isEmpty()) {
|
if (!game.getCombat().getCreaturesForcedToAttack().isEmpty()) {
|
||||||
if (!game.getCombat().getAttackers().containsAll(game.getCombat().getCreaturesForcedToAttack().keySet())) {
|
if (!game.getCombat().getAttackers().containsAll(game.getCombat().getCreaturesForcedToAttack().keySet())) {
|
||||||
|
@ -891,6 +911,15 @@ public class HumanPlayer extends PlayerImpl {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected UUID selectDefenderForAllAttack(Set<UUID> defenders, Game game) {
|
||||||
|
TargetDefender target = new TargetDefender(defenders, null);
|
||||||
|
target.setNotTarget(true); // player or planswalker hexproof does not prevent attacking a player
|
||||||
|
if (chooseTarget(Outcome.Damage, target, null, game)) {
|
||||||
|
response.getUUID();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectBlockers(Game game, UUID defendingPlayerId) {
|
public void selectBlockers(Game game, UUID defendingPlayerId) {
|
||||||
updateGameStatePriority("selectBlockers", game);
|
updateGameStatePriority("selectBlockers", game);
|
||||||
|
|
Loading…
Reference in a new issue