mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 11:02:00 -08:00
Added options to gameclient target message.
This commit is contained in:
parent
23c5bf9db0
commit
a1b2127962
16 changed files with 96 additions and 44 deletions
|
|
@ -623,6 +623,7 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
|
|
||||||
private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed
|
private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed
|
||||||
this.tablesPane.setVisible(true);
|
this.tablesPane.setVisible(true);
|
||||||
|
this.tablesPane.toFront();
|
||||||
this.tablesPane.showTables();
|
this.tablesPane.showTables();
|
||||||
}//GEN-LAST:event_btnGamesActionPerformed
|
}//GEN-LAST:event_btnGamesActionPerformed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ import java.awt.EventQueue;
|
||||||
import java.awt.MenuComponent;
|
import java.awt.MenuComponent;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
@ -76,7 +78,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
session = MageFrame.getSession();
|
session = MageFrame.getSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getFeedback(FeedbackMode mode, String message, boolean modal, boolean special) {
|
public void getFeedback(FeedbackMode mode, String message, boolean modal, boolean special, Map<String, Serializable> options) {
|
||||||
this.lblMessage.setText(message);
|
this.lblMessage.setText(message);
|
||||||
this.selected = false;
|
this.selected = false;
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
|
|
@ -115,6 +117,14 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
||||||
startModal();
|
startModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleOptions(Map<String, Serializable> options) {
|
||||||
|
if (options != null) {
|
||||||
|
if (options.containsKey("UI.right.btn.text")) {
|
||||||
|
this.btnRight.setText((String)options.get("UI.right.btn.text"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void doClick() {
|
public void doClick() {
|
||||||
this.btnRight.doClick();
|
this.btnRight.doClick();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ package mage.client.game;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ComponentAdapter;
|
import java.awt.event.ComponentAdapter;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -356,12 +357,12 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public void ask(String question, GameView gameView) {
|
public void ask(String question, GameView gameView) {
|
||||||
updateGame(gameView);
|
updateGame(gameView);
|
||||||
this.feedbackPanel.getFeedback(FeedbackMode.QUESTION, question, true, false);
|
this.feedbackPanel.getFeedback(FeedbackMode.QUESTION, question, true, false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pickTarget(String message, CardsView cardView, GameView gameView, Set<UUID> targets, boolean required) {
|
public void pickTarget(String message, CardsView cardView, GameView gameView, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||||
updateGame(gameView);
|
updateGame(gameView);
|
||||||
this.feedbackPanel.getFeedback(required?FeedbackMode.INFORM:FeedbackMode.CANCEL, message, false, gameView.getSpecial());
|
this.feedbackPanel.getFeedback(required?FeedbackMode.INFORM:FeedbackMode.CANCEL, message, false, gameView.getSpecial(), options);
|
||||||
if (cardView != null && cardView.size() > 0) {
|
if (cardView != null && cardView.size() > 0) {
|
||||||
showCards(message, cardView, required);
|
showCards(message, cardView, required);
|
||||||
}
|
}
|
||||||
|
|
@ -369,7 +370,7 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public void inform(String information, GameView gameView) {
|
public void inform(String information, GameView gameView) {
|
||||||
updateGame(gameView);
|
updateGame(gameView);
|
||||||
this.feedbackPanel.getFeedback(FeedbackMode.INFORM, information, false, gameView.getSpecial());
|
this.feedbackPanel.getFeedback(FeedbackMode.INFORM, information, false, gameView.getSpecial(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void modalMessage(String message) {
|
public void modalMessage(String message) {
|
||||||
|
|
@ -386,7 +387,7 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public void select(String message, GameView gameView) {
|
public void select(String message, GameView gameView) {
|
||||||
updateGame(gameView);
|
updateGame(gameView);
|
||||||
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, message, false, gameView.getSpecial());
|
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, message, false, gameView.getSpecial(), null);
|
||||||
if (PhaseManager.getInstance().isSkip(gameView, message)) {
|
if (PhaseManager.getInstance().isSkip(gameView, message)) {
|
||||||
this.feedbackPanel.doClick();
|
this.feedbackPanel.doClick();
|
||||||
}
|
}
|
||||||
|
|
@ -394,12 +395,12 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public void playMana(String message, GameView gameView) {
|
public void playMana(String message, GameView gameView) {
|
||||||
updateGame(gameView);
|
updateGame(gameView);
|
||||||
this.feedbackPanel.getFeedback(FeedbackMode.CANCEL, message, false, gameView.getSpecial());
|
this.feedbackPanel.getFeedback(FeedbackMode.CANCEL, message, false, gameView.getSpecial(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playXMana(String message, GameView gameView) {
|
public void playXMana(String message, GameView gameView) {
|
||||||
updateGame(gameView);
|
updateGame(gameView);
|
||||||
this.feedbackPanel.getFeedback(FeedbackMode.CONFIRM, message, false, gameView.getSpecial());
|
this.feedbackPanel.getFeedback(FeedbackMode.CONFIRM, message, false, gameView.getSpecial(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replayMessage(String message) {
|
public void replayMessage(String message) {
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ public class Client implements CallbackClient {
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameTarget")) {
|
else if (callback.getMethod().equals("gameTarget")) {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
session.getGame().pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(), message.getTargets(), message.isFlag());
|
session.getGame().pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(), message.getTargets(), message.isFlag(), message.getOptions());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameSelect")) {
|
else if (callback.getMethod().equals("gameSelect")) {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ public class TablesPane extends MagePane {
|
||||||
tablesPanel.showTables(roomId);
|
tablesPanel.showTables(roomId);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideTables() {
|
public void hideTables() {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
package mage.view;
|
package mage.view;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
@ -48,6 +49,7 @@ public class GameClientMessage implements Serializable {
|
||||||
private Set<UUID> targets;
|
private Set<UUID> targets;
|
||||||
private int min;
|
private int min;
|
||||||
private int max;
|
private int max;
|
||||||
|
private Map<String, Serializable> options;
|
||||||
|
|
||||||
public GameClientMessage(GameView gameView) {
|
public GameClientMessage(GameView gameView) {
|
||||||
this.gameView = gameView;
|
this.gameView = gameView;
|
||||||
|
|
@ -58,7 +60,7 @@ public class GameClientMessage implements Serializable {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameClientMessage(GameView gameView, String question, CardsView cardView, Set<UUID> targets, boolean required) {
|
private GameClientMessage(GameView gameView, String question, CardsView cardView, Set<UUID> targets, boolean required) {
|
||||||
this.gameView = gameView;
|
this.gameView = gameView;
|
||||||
this.message = question;
|
this.message = question;
|
||||||
this.cardsView = cardView;
|
this.cardsView = cardView;
|
||||||
|
|
@ -66,6 +68,11 @@ public class GameClientMessage implements Serializable {
|
||||||
this.flag = required;
|
this.flag = required;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameClientMessage(GameView gameView, String question, CardsView cardView, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||||
|
this(gameView, question, cardView, targets, required);
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
public GameClientMessage(String[] choices, String message) {
|
public GameClientMessage(String[] choices, String message) {
|
||||||
this.strings = choices;
|
this.strings = choices;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
|
@ -118,4 +125,7 @@ public class GameClientMessage implements Serializable {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Serializable> getOptions() {
|
||||||
|
return options;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ package mage.player.ai;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
@ -138,6 +139,11 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean choose(Outcome outcome, Target target, Game game) {
|
public boolean choose(Outcome outcome, Target target, Game game) {
|
||||||
|
return choose(outcome, target, game, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean choose(Outcome outcome, Target target, Game game, Map<String, Serializable> options) {
|
||||||
if (logger.isLoggable(Level.FINE))
|
if (logger.isLoggable(Level.FINE))
|
||||||
logger.fine("chooseTarget: " + outcome.toString() + ":" + target.toString());
|
logger.fine("chooseTarget: " + outcome.toString() + ":" + target.toString());
|
||||||
UUID opponentId = game.getOpponents(playerId).iterator().next();
|
UUID opponentId = game.getOpponents(playerId).iterator().next();
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
package mage.player.human;
|
package mage.player.human;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import mage.abilities.TriggeredAbilities;
|
import mage.abilities.TriggeredAbilities;
|
||||||
import mage.abilities.TriggeredAbility;
|
import mage.abilities.TriggeredAbility;
|
||||||
|
|
@ -182,8 +183,13 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean choose(Outcome outcome, Target target, Game game) {
|
public boolean choose(Outcome outcome, Target target, Game game) {
|
||||||
|
return choose(outcome, target, game, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean choose(Outcome outcome, Target target, Game game, Map<String, Serializable> options) {
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage(), target.possibleTargets(null, playerId, game), target.isRequired());
|
game.fireSelectTargetEvent(playerId, target.getMessage(), target.possibleTargets(null, playerId, game), target.isRequired(), options);
|
||||||
waitForResponse();
|
waitForResponse();
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (target instanceof TargetPermanent) {
|
if (target instanceof TargetPermanent) {
|
||||||
|
|
@ -206,7 +212,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
@Override
|
@Override
|
||||||
public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
|
public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage(), target.possibleTargets(source==null?null:source.getId(), playerId, game), target.isRequired());
|
game.fireSelectTargetEvent(playerId, target.getMessage(), target.possibleTargets(source==null?null:source.getId(), playerId, game), target.isRequired(), null);
|
||||||
waitForResponse();
|
waitForResponse();
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (target instanceof TargetPermanent) {
|
if (target instanceof TargetPermanent) {
|
||||||
|
|
@ -263,7 +269,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
@Override
|
@Override
|
||||||
public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) {
|
public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) {
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage() + "\n Amount remaining:" + target.getAmountRemaining(), target.possibleTargets(source==null?null:source.getId(), playerId, game), target.isRequired());
|
game.fireSelectTargetEvent(playerId, target.getMessage() + "\n Amount remaining:" + target.getAmountRemaining(), target.possibleTargets(source==null?null:source.getId(), playerId, game), target.isRequired(), null);
|
||||||
waitForResponse();
|
waitForResponse();
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (target.canTarget(response.getUUID(), source, game)) {
|
if (target.canTarget(response.getUUID(), source, game)) {
|
||||||
|
|
@ -434,7 +440,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
|
|
||||||
protected void selectCombatGroup(UUID blockerId, Game game) {
|
protected void selectCombatGroup(UUID blockerId, Game game) {
|
||||||
TargetAttackingCreature target = new TargetAttackingCreature();
|
TargetAttackingCreature target = new TargetAttackingCreature();
|
||||||
game.fireSelectTargetEvent(playerId, "Select attacker to block", target.possibleTargets(null, playerId, game), target.isRequired());
|
game.fireSelectTargetEvent(playerId, "Select attacker to block", target.possibleTargets(null, playerId, game), target.isRequired(), null);
|
||||||
waitForResponse();
|
waitForResponse();
|
||||||
if (response.getBoolean() != null) {
|
if (response.getBoolean() != null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,8 @@
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.io.Serializable;
|
||||||
import java.util.HashSet;
|
import java.util.*;
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
@ -126,10 +123,10 @@ public class GameController implements GameCallback {
|
||||||
ask(event.getPlayerId(), event.getMessage());
|
ask(event.getPlayerId(), event.getMessage());
|
||||||
break;
|
break;
|
||||||
case PICK_TARGET:
|
case PICK_TARGET:
|
||||||
target(event.getPlayerId(), event.getMessage(), event.getCards(), event.getTargets(), event.isRequired());
|
target(event.getPlayerId(), event.getMessage(), event.getCards(), event.getTargets(), event.isRequired(), event.getOptions());
|
||||||
break;
|
break;
|
||||||
case PICK_ABILITY:
|
case PICK_ABILITY:
|
||||||
target(event.getPlayerId(), event.getMessage(), event.getAbilities(), event.isRequired());
|
target(event.getPlayerId(), event.getMessage(), event.getAbilities(), event.isRequired(), event.getOptions());
|
||||||
break;
|
break;
|
||||||
case SELECT:
|
case SELECT:
|
||||||
select(event.getPlayerId(), event.getMessage());
|
select(event.getPlayerId(), event.getMessage());
|
||||||
|
|
@ -332,19 +329,19 @@ public class GameController implements GameCallback {
|
||||||
informOthers(playerId);
|
informOthers(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void target(UUID playerId, String question, Cards cards, Set<UUID> targets, boolean required) {
|
private synchronized void target(UUID playerId, String question, Cards cards, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||||
if (gameSessions.containsKey(playerId)) {
|
if (gameSessions.containsKey(playerId)) {
|
||||||
if (cards != null)
|
if (cards != null)
|
||||||
gameSessions.get(playerId).target(question, new CardsView(cards.getCards(game)), targets, required, getGameView(playerId));
|
gameSessions.get(playerId).target(question, new CardsView(cards.getCards(game)), targets, required, getGameView(playerId), options);
|
||||||
else
|
else
|
||||||
gameSessions.get(playerId).target(question, new CardsView(), targets, required, getGameView(playerId));
|
gameSessions.get(playerId).target(question, new CardsView(), targets, required, getGameView(playerId), options);
|
||||||
}
|
}
|
||||||
informOthers(playerId);
|
informOthers(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void target(UUID playerId, String question, Collection<? extends Ability> abilities, boolean required) {
|
private synchronized void target(UUID playerId, String question, Collection<? extends Ability> abilities, boolean required, Map<String, Serializable> options) {
|
||||||
if (gameSessions.containsKey(playerId))
|
if (gameSessions.containsKey(playerId))
|
||||||
gameSessions.get(playerId).target(question, new CardsView(abilities, game), null, required, getGameView(playerId));
|
gameSessions.get(playerId).target(question, new CardsView(abilities, game), null, required, getGameView(playerId), options);
|
||||||
informOthers(playerId);
|
informOthers(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
@ -71,12 +73,12 @@ public class GameSession extends GameWatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void target(final String question, final CardsView cardView, final Set<UUID> targets, final boolean required, final GameView gameView) {
|
public void target(final String question, final CardsView cardView, final Set<UUID> targets, final boolean required, final GameView gameView, final Map<String, Serializable> options) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
setupTimeout();
|
setupTimeout();
|
||||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||||
if (session != null)
|
if (session != null)
|
||||||
session.fireCallback(new ClientCallback("gameTarget", new GameClientMessage(gameView, question, cardView, targets, required)));
|
session.fireCallback(new ClientCallback("gameTarget", new GameClientMessage(gameView, question, cardView, targets, required, options)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,8 @@ import mage.players.Player;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.common.TargetPermanentOrPlayerWithCounter;
|
import mage.target.common.TargetPermanentOrPlayerWithCounter;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.io.Serializable;
|
||||||
import java.util.Set;
|
import java.util.*;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
|
|
@ -65,8 +64,10 @@ public class ProliferateEffect extends OneShotEffect<ProliferateEffect> {
|
||||||
//had, if thats the case this ability should fizzle.
|
//had, if thats the case this ability should fizzle.
|
||||||
if (target.canChoose(controller.getId(), game)) {
|
if (target.canChoose(controller.getId(), game)) {
|
||||||
boolean abilityApplied = false;
|
boolean abilityApplied = false;
|
||||||
|
Map<String, Serializable> options = new HashMap<String, Serializable>();
|
||||||
|
options.put("UI.right.btn.text", "Done");
|
||||||
while (target.canChoose(controller.getId(), game)) {
|
while (target.canChoose(controller.getId(), game)) {
|
||||||
if (!controller.choose(Outcome.Benefit, target, game)) {
|
if (!controller.choose(Outcome.Benefit, target, game, options)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import mage.game.stack.SpellStack;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.MultiplayerAttackOption;
|
import mage.Constants.MultiplayerAttackOption;
|
||||||
|
|
@ -115,7 +116,7 @@ public interface Game extends MageItem, Serializable {
|
||||||
public void addPlayerQueryEventListener(Listener<PlayerQueryEvent> listener);
|
public void addPlayerQueryEventListener(Listener<PlayerQueryEvent> listener);
|
||||||
public void fireAskPlayerEvent(UUID playerId, String message);
|
public void fireAskPlayerEvent(UUID playerId, String message);
|
||||||
public void fireChooseEvent(UUID playerId, Choice choice);
|
public void fireChooseEvent(UUID playerId, Choice choice);
|
||||||
public void fireSelectTargetEvent(UUID playerId, String message, Set<UUID> targets, boolean required);
|
public void fireSelectTargetEvent(UUID playerId, String message, Set<UUID> targets, boolean required, Map<String, Serializable> options);
|
||||||
public void fireSelectTargetEvent(UUID playerId, String message, Cards cards, boolean required);
|
public void fireSelectTargetEvent(UUID playerId, String message, Cards cards, boolean required);
|
||||||
public void fireSelectTargetEvent(UUID playerId, String message, TriggeredAbilities abilities, boolean required);
|
public void fireSelectTargetEvent(UUID playerId, String message, TriggeredAbilities abilities, boolean required);
|
||||||
// public void fireRevealCardsEvent(String message, Cards cards);
|
// public void fireRevealCardsEvent(String message, Cards cards);
|
||||||
|
|
|
||||||
|
|
@ -759,8 +759,8 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireSelectTargetEvent(UUID playerId, String message, Set<UUID> targets, boolean required) {
|
public void fireSelectTargetEvent(UUID playerId, String message, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||||
playerQueryEventSource.target(playerId, message, targets, required);
|
playerQueryEventSource.target(playerId, message, targets, required, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,8 @@
|
||||||
package mage.game.events;
|
package mage.game.events;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.EventObject;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.ActivatedAbility;
|
import mage.abilities.ActivatedAbility;
|
||||||
import mage.abilities.TriggeredAbilities;
|
import mage.abilities.TriggeredAbilities;
|
||||||
|
|
@ -61,6 +58,12 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
||||||
private boolean required;
|
private boolean required;
|
||||||
private int min;
|
private int min;
|
||||||
private int max;
|
private int max;
|
||||||
|
private Map<String, Serializable> options;
|
||||||
|
|
||||||
|
private PlayerQueryEvent(UUID playerId, String message, Collection<? extends Ability> abilities, Set<String> choices, Set<UUID> targets, Cards cards, QueryType queryType, int min, int max, boolean required, Map<String, Serializable> options) {
|
||||||
|
this(playerId, message, abilities, choices, targets, cards, queryType, min, max, required);
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
private PlayerQueryEvent(UUID playerId, String message, Collection<? extends Ability> abilities, Set<String> choices, Set<UUID> targets, Cards cards, QueryType queryType, int min, int max, boolean required) {
|
private PlayerQueryEvent(UUID playerId, String message, Collection<? extends Ability> abilities, Set<String> choices, Set<UUID> targets, Cards cards, QueryType queryType, int min, int max, boolean required) {
|
||||||
super(playerId);
|
super(playerId);
|
||||||
|
|
@ -100,6 +103,10 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
||||||
return new PlayerQueryEvent(playerId, message, null, null, targets, null, QueryType.PICK_TARGET, 0, 0, required);
|
return new PlayerQueryEvent(playerId, message, null, null, targets, null, QueryType.PICK_TARGET, 0, 0, required);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlayerQueryEvent targetEvent(UUID playerId, String message, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||||
|
return new PlayerQueryEvent(playerId, message, null, null, targets, null, QueryType.PICK_TARGET, 0, 0, required, options);
|
||||||
|
}
|
||||||
|
|
||||||
public static PlayerQueryEvent targetEvent(UUID playerId, String message, Cards cards, boolean required) {
|
public static PlayerQueryEvent targetEvent(UUID playerId, String message, Cards cards, boolean required) {
|
||||||
return new PlayerQueryEvent(playerId, message, null, null, null, cards, QueryType.PICK_TARGET, 0, 0, required);
|
return new PlayerQueryEvent(playerId, message, null, null, null, cards, QueryType.PICK_TARGET, 0, 0, required);
|
||||||
}
|
}
|
||||||
|
|
@ -175,4 +182,8 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
||||||
public int getMax() {
|
public int getMax() {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Serializable> getOptions() {
|
||||||
|
return options;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,8 @@
|
||||||
package mage.game.events;
|
package mage.game.events;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.ActivatedAbility;
|
import mage.abilities.ActivatedAbility;
|
||||||
import mage.abilities.TriggeredAbilities;
|
import mage.abilities.TriggeredAbilities;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
|
@ -67,6 +65,10 @@ public class PlayerQueryEventSource implements EventSource<PlayerQueryEvent>, Se
|
||||||
dispatcher.fireEvent(PlayerQueryEvent.targetEvent(playerId, message, targets, required));
|
dispatcher.fireEvent(PlayerQueryEvent.targetEvent(playerId, message, targets, required));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void target(UUID playerId, String message, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||||
|
dispatcher.fireEvent(PlayerQueryEvent.targetEvent(playerId, message, targets, required, options));
|
||||||
|
}
|
||||||
|
|
||||||
public void target(UUID playerId, String message, Cards cards, boolean required) {
|
public void target(UUID playerId, String message, Cards cards, boolean required) {
|
||||||
dispatcher.fireEvent(PlayerQueryEvent.targetEvent(playerId, message, cards, required));
|
dispatcher.fireEvent(PlayerQueryEvent.targetEvent(playerId, message, cards, required));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,9 @@
|
||||||
|
|
||||||
package mage.players;
|
package mage.players;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
|
|
@ -135,6 +137,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
|
|
||||||
public abstract void priority(Game game);
|
public abstract void priority(Game game);
|
||||||
public abstract boolean choose(Outcome outcome, Target target, Game game);
|
public abstract boolean choose(Outcome outcome, Target target, Game game);
|
||||||
|
public abstract boolean choose(Outcome outcome, Target target, Game game, Map<String, Serializable> options);
|
||||||
public abstract boolean choose(Cards cards, TargetCard target, Game game);
|
public abstract boolean choose(Cards cards, TargetCard target, Game game);
|
||||||
public abstract boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game);
|
public abstract boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game);
|
||||||
public abstract boolean chooseTarget(Cards cards, TargetCard target, Ability source, Game game);
|
public abstract boolean chooseTarget(Cards cards, TargetCard target, Ability source, Game game);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue