mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Added F5 button to skip priority until end step of opponent. Added PlayerAction handling.
This commit is contained in:
parent
ebd21eab1d
commit
aa842efacc
17 changed files with 185 additions and 327 deletions
|
@ -48,6 +48,7 @@ import mage.client.components.MageTextArea;
|
|||
import mage.client.dialog.MageDialog;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.remote.Session;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
@ -304,7 +305,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
}//GEN-LAST:event_btnSpecialActionPerformed
|
||||
|
||||
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
session.undo(gameId);
|
||||
session.sendPlayerAction(PlayerAction.UNDO, gameId);
|
||||
}
|
||||
|
||||
public void setHelperPanel(HelperPanel helper) {
|
||||
|
|
|
@ -66,6 +66,7 @@ import java.util.*;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import mage.constants.PlayerAction;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -942,6 +943,15 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
ks = KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0);
|
||||
this.getInputMap(c).put(ks, "F5_PRESS");
|
||||
this.getActionMap().put("F5_PRESS", new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
btnUntilEndOfTurnActionPerformed(null);
|
||||
}
|
||||
});
|
||||
|
||||
KeyStroke ks9 = KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0);
|
||||
this.getInputMap(c).put(ks9, "F9_PRESS");
|
||||
this.getActionMap().put("F9_PRESS", new AbstractAction() {
|
||||
|
@ -1345,25 +1355,31 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
private void btnConcedeActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (modalQuestion("Are you sure you want to concede?", "Confirm concede") == JOptionPane.YES_OPTION) {
|
||||
session.concedeGame(gameId);
|
||||
session.sendPlayerAction(PlayerAction.CONCEDE, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (feedbackPanel != null && FeedbackMode.SELECT.equals(feedbackPanel.getMode())) {
|
||||
session.passTurnPriority(gameId);
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (feedbackPanel != null && FeedbackMode.SELECT.equals(feedbackPanel.getMode())) {
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_OPPONENTS_TURN_END_STEP, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (feedbackPanel != null && FeedbackMode.SELECT.equals(feedbackPanel.getMode())) {
|
||||
session.passPriorityUntilNextYourTurn(gameId);
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (feedbackPanel != null) {
|
||||
session.restorePriority(gameId);
|
||||
session.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ import javax.swing.event.ChangeListener;
|
|||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.view.PlayerView;
|
||||
|
||||
/**
|
||||
|
@ -149,7 +150,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().restorePriority(gameId);
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -162,7 +163,18 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().passTurnPriority(gameId);
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId);
|
||||
}
|
||||
});
|
||||
|
||||
menuItem = new JMenuItem("F5 - Skip phases until opponent's end step (stop on stack/attack/block)");
|
||||
popupMenu.add(menuItem);
|
||||
|
||||
// Skip to next end step of turn (F5)
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_OPPONENTS_TURN_END_STEP, gameId);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -173,7 +185,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().passPriorityUntilNextYourTurn(gameId);
|
||||
gamePanel.getSession().sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -190,7 +202,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
public void actionPerformed(ActionEvent e) {
|
||||
boolean manaPoolAutomatic = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||
gamePanel.setMenuStates(manaPoolAutomatic);
|
||||
gamePanel.getSession().setManaPoolMode(manaPoolAutomatic, gameId);
|
||||
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON: PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -204,7 +216,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the game?", "Confirm concede game", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
MageFrame.getSession().concedeGame(gameId);
|
||||
MageFrame.getSession().sendPlayerAction(PlayerAction.CONCEDE, gameId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -374,8 +374,9 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
.append("<br/>Turn mousewheel down (ALT-s) - enlarge original/alternate image of card the mousepointer hovers over")
|
||||
.append("<br/><b>F2</b> - Confirm \"Ok\", \"Yes\" or \"Done\" button")
|
||||
.append("<br/><b>F4</b> - Skip current turn but stop on declare attackers/blockers and something on the stack")
|
||||
.append("<br/><b>F5</b> - Skip to next end step of opponent's turn but stop on declare attackers/blockers and something on the stack")
|
||||
.append("<br/><b>F9</b> - Skip everything until your next turn")
|
||||
.append("<br/><b>F3</b> - Undo F4/F9").toString(),
|
||||
.append("<br/><b>F3</b> - Undo F4/F5/F9").toString(),
|
||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.ORANGE);
|
||||
break;
|
||||
case TOURNAMENT:
|
||||
|
|
|
@ -63,7 +63,7 @@ public class PhaseManager {
|
|||
|
||||
private static final Preferences prefs = MageFrame.getPreferences();
|
||||
|
||||
private static Map<String, String> mapYou = new HashMap<String, String>() {{
|
||||
private static final Map<String, String> mapYou = new HashMap<String, String>() {{
|
||||
put("Upkeep - play instants and activated abilities.", UPKEEP_YOU);
|
||||
put("Draw - play instants and activated abilities.", DRAW_YOU);
|
||||
put("Precombat Main - play spells and abilities.", MAIN_YOU);
|
||||
|
@ -73,7 +73,7 @@ public class PhaseManager {
|
|||
put("End Turn - play instants and activated abilities.", END_OF_TURN_YOU);
|
||||
}};
|
||||
|
||||
private static Map<String, String> mapOthers = new HashMap<String, String>() {{
|
||||
private static final Map<String, String> mapOthers = new HashMap<String, String>() {{
|
||||
put("Upkeep - play instants and activated abilities.", UPKEEP_OTHERS);
|
||||
put("Draw - play instants and activated abilities.", DRAW_OTHERS);
|
||||
put("Precombat Main - play instants and activated abilities.", MAIN_OTHERS);
|
||||
|
|
|
@ -35,6 +35,7 @@ import mage.cards.decks.DeckCardLists;
|
|||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.game.GameException;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
|
@ -115,16 +116,10 @@ public interface MageServer {
|
|||
void sendPlayerBoolean(UUID gameId, String sessionId, Boolean data) throws MageException;
|
||||
void sendPlayerInteger(UUID gameId, String sessionId, Integer data) throws MageException;
|
||||
void sendPlayerManaType(UUID gameId, UUID playerId, String sessionId, ManaType data) throws MageException;
|
||||
void concedeGame(UUID gameId, String sessionId) throws MageException;
|
||||
void quitMatch(UUID gameId, String sessionId) throws MageException;
|
||||
void undo(UUID gameId, String sessionId) throws MageException;
|
||||
void setManaPoolMode(UUID gameId, String sessionId, boolean autoPayment) throws MageException;
|
||||
GameView getGameView(UUID gameId, String sessionId, UUID playerId) throws MageException;
|
||||
|
||||
//priority methods
|
||||
void passPriorityUntilNextYourTurn(UUID gameId, String sessionId) throws MageException;
|
||||
void passTurnPriority(UUID gameId, String sessionId) throws MageException;
|
||||
void restorePriority(UUID gameId, String sessionId) throws MageException;
|
||||
// priority, undo, concede, mana pool
|
||||
void sendPlayerAction(PlayerAction playerAction, UUID gameId, String sessionId) throws MageException;
|
||||
|
||||
//tournament methods
|
||||
boolean startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
|
|
|
@ -51,6 +51,7 @@ import mage.cards.repository.ExpansionInfo;
|
|||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.constants.Constants.SessionState;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.game.GameException;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
|
@ -1054,21 +1055,6 @@ public class SessionImpl implements Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean concedeGame(UUID gameId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.concedeGame(gameId, sessionId);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean quitMatch(UUID gameId) {
|
||||
try {
|
||||
|
@ -1113,10 +1099,10 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean undo(UUID gameId) {
|
||||
public boolean sendPlayerAction(PlayerAction passPriorityAction, UUID gameId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.undo(gameId, sessionId);
|
||||
server.sendPlayerAction(passPriorityAction, gameId, sessionId);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
|
@ -1126,52 +1112,7 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passPriorityUntilNextYourTurn(UUID gameId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.passPriorityUntilNextYourTurn(gameId, sessionId);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passTurnPriority(UUID gameId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.passTurnPriority(gameId, sessionId);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restorePriority(UUID gameId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.restorePriority(gameId, sessionId);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stopWatching(UUID gameId) {
|
||||
try {
|
||||
|
@ -1262,21 +1203,6 @@ public class SessionImpl implements Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setManaPoolMode(boolean autoPayment, UUID gameId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.setManaPoolMode(gameId, sessionId, autoPayment);
|
||||
return true;
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cheat(UUID gameId, UUID playerId, DeckCardLists deckList) {
|
||||
try {
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.remote.interfaces;
|
|||
import java.util.UUID;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.view.DraftPickView;
|
||||
|
||||
/**
|
||||
|
@ -53,8 +54,6 @@ public interface GamePlay {
|
|||
|
||||
boolean sendPlayerManaType(UUID gameId, UUID playerId, ManaType data);
|
||||
|
||||
boolean concedeGame(UUID gameId);
|
||||
|
||||
boolean quitMatch(UUID gameId);
|
||||
|
||||
boolean quitTournament(UUID tournamentId);
|
||||
|
@ -67,47 +66,18 @@ public interface GamePlay {
|
|||
|
||||
DraftPickView sendCardPick(UUID draftId, UUID cardId);
|
||||
|
||||
boolean undo(UUID gameId);
|
||||
|
||||
/*** Separate methods for priority handling ***/
|
||||
/**
|
||||
* magenoxx:
|
||||
* it should be done separately as sendPlayer* methods calls are injected into the game flow
|
||||
* - this is similar to concedeGame method
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pass priority until next your turn.
|
||||
* Don't stop at all even if something happens.
|
||||
*
|
||||
* @param gameId
|
||||
* @return
|
||||
*/
|
||||
boolean passPriorityUntilNextYourTurn(UUID gameId);
|
||||
|
||||
/**
|
||||
* Passes current turn but stop on pre combat phase.
|
||||
*
|
||||
* @param gameId
|
||||
* @return
|
||||
*/
|
||||
boolean passTurnPriority(UUID gameId);
|
||||
|
||||
/**
|
||||
* This method cancels all other calls made before.
|
||||
*
|
||||
* @param gameId
|
||||
* @return
|
||||
*/
|
||||
boolean restorePriority(UUID gameId);
|
||||
|
||||
/**
|
||||
* This method toggles usage of mana pool
|
||||
*
|
||||
* @param automatic true mana in pool will be used automatically
|
||||
* This method sends player actions for a game
|
||||
* priority handling, undo
|
||||
*
|
||||
* @param passPriorityAction
|
||||
* @param gameId
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
boolean setManaPoolMode(boolean automatic, UUID gameId);
|
||||
boolean sendPlayerAction(PlayerAction passPriorityAction, UUID gameId);
|
||||
|
||||
}
|
||||
|
|
|
@ -444,6 +444,11 @@ public class HumanPlayer extends PlayerImpl {
|
|||
pass(game);
|
||||
return false;
|
||||
}
|
||||
if (passedUntilEndOfTurn && game.getStack().isEmpty() &&
|
||||
(!game.getTurn().getStepType().equals(PhaseStep.END_TURN) || playerId.equals(game.getActivePlayerId()))) {
|
||||
pass(game);
|
||||
return false;
|
||||
}
|
||||
updateGameStatePriority("priority", game);
|
||||
game.firePriorityEvent(playerId);
|
||||
waitForResponse(game);
|
||||
|
|
|
@ -66,6 +66,7 @@ import java.util.Locale;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.constants.TableState;
|
||||
|
||||
/**
|
||||
|
@ -663,32 +664,6 @@ public class MageServerImpl implements MageServer {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManaPoolMode(final UUID gameId, final String sessionId, final boolean autoPayment) throws MageException {
|
||||
execute("setManaPoolMode", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
GameManager.getInstance().setManaPoolMode(gameId, userId, autoPayment);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void concedeGame(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("concedeGame", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
GameManager.getInstance().concedeGame(gameId, session.getUserId());
|
||||
} else{
|
||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" +gameId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitMatch(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("quitMatch", sessionId, new Action() {
|
||||
|
@ -740,8 +715,8 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void undo(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("undo", sessionId, new Action() {
|
||||
public void sendPlayerAction(final PlayerAction playerAction, final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("setdPlayerAction", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
|
@ -749,57 +724,11 @@ public class MageServerImpl implements MageServer {
|
|||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" + gameId);
|
||||
return;
|
||||
}
|
||||
GameManager.getInstance().undo(gameId, session.getUserId());
|
||||
GameManager.getInstance().sendPlayerAction(playerAction, gameId, session.getUserId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passPriorityUntilNextYourTurn(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("passPriorityUntilNextYourTurn", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session == null) {
|
||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" + gameId);
|
||||
return;
|
||||
}
|
||||
GameManager.getInstance().passPriorityUntilNextYourTurn(gameId, session.getUserId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passTurnPriority(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("passTurnPriority", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session == null) {
|
||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" + gameId);
|
||||
return;
|
||||
}
|
||||
GameManager.getInstance().passTurnPriority(gameId, session.getUserId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restorePriority(final UUID gameId, final String sessionId) throws MageException {
|
||||
execute("restorePriority", sessionId, new Action() {
|
||||
@Override
|
||||
public void execute() {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session == null) {
|
||||
logger.error("Session not found sessionId: "+ sessionId + " gameId:" + gameId);
|
||||
return;
|
||||
}
|
||||
GameManager.getInstance().restorePriority(gameId, session.getUserId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean watchTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
||||
|
|
|
@ -65,6 +65,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import mage.constants.PlayerAction;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -359,14 +360,6 @@ public class GameController implements GameCallback {
|
|||
}
|
||||
}
|
||||
|
||||
public void concede(UUID userId) {
|
||||
game.concede(getPlayerId(userId));
|
||||
}
|
||||
|
||||
public void setManaPoolMode(UUID userId, boolean autoPayment) {
|
||||
game.setManaPoolMode(getPlayerId(userId), autoPayment);
|
||||
}
|
||||
|
||||
// public void removeUser(UUID userId) {
|
||||
// UUID playerId = userPlayerMap.get(userId);
|
||||
// if (playerId != null) {
|
||||
|
@ -389,22 +382,25 @@ public class GameController implements GameCallback {
|
|||
game.quit(getPlayerId(userId));
|
||||
}
|
||||
|
||||
public void undo(UUID userId) {
|
||||
game.undo(getPlayerId(userId));
|
||||
public void sendPlayerAction(PlayerAction playerAction, UUID userId) {
|
||||
switch(playerAction) {
|
||||
case UNDO:
|
||||
game.undo(getPlayerId(userId));
|
||||
break;
|
||||
case CONCEDE:
|
||||
game.concede(getPlayerId(userId));
|
||||
break;
|
||||
case MANA_AUTO_PAYMENT_OFF:
|
||||
game.setManaPoolMode(getPlayerId(userId), false);
|
||||
break;
|
||||
case MANA_AUTO_PAYMENT_ON:
|
||||
game.setManaPoolMode(getPlayerId(userId), true);
|
||||
break;
|
||||
default:
|
||||
game.sendPlayerAction(playerAction, getPlayerId(userId));
|
||||
}
|
||||
}
|
||||
|
||||
public void passPriorityUntilNextYourTurn(UUID userId) {
|
||||
game.passPriorityUntilNextYourTurn(getPlayerId(userId));
|
||||
}
|
||||
|
||||
public void passTurnPriority(UUID userId) {
|
||||
game.passTurnPriority(getPlayerId(userId));
|
||||
}
|
||||
|
||||
public void restorePriority(UUID userId) {
|
||||
game.restorePriority(getPlayerId(userId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void cheat(UUID userId, UUID playerId, DeckCardLists deckList) {
|
||||
Deck deck;
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.UUID;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.game.Game;
|
||||
import mage.view.GameView;
|
||||
|
||||
|
@ -106,52 +107,17 @@ public class GameManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void setManaPoolMode(UUID gameId, UUID userId, boolean autoPayment) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.setManaPoolMode(userId, autoPayment);
|
||||
}
|
||||
}
|
||||
|
||||
public void concedeGame(UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.concede(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void quitMatch(UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.quitMatch(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void undo(UUID gameId, UUID userId) {
|
||||
|
||||
public void sendPlayerAction(PlayerAction playerAction, UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.undo(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void passPriorityUntilNextYourTurn(UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.passPriorityUntilNextYourTurn(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void passTurnPriority(UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.passTurnPriority(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void restorePriority(UUID gameId, UUID userId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
gameController.restorePriority(userId);
|
||||
if (gameController != null) {
|
||||
gameController.sendPlayerAction(playerAction, userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
44
Mage/src/mage/constants/PlayerAction.java
Normal file
44
Mage/src/mage/constants/PlayerAction.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.constants;
|
||||
|
||||
/**
|
||||
* Defines player actions for a game
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public enum PlayerAction {
|
||||
PASS_PRIORITY_UNTIL_MY_NEXT_TURN,
|
||||
PASS_PRIORITY_UNTIL_OPPONENTS_TURN_END_STEP,
|
||||
PASS_PRIORITY_UNTIL_NEXT_TURN,
|
||||
PASS_PRIORITY_CANCEL_ALL_ACTIONS,
|
||||
UNDO,
|
||||
CONCEDE,
|
||||
MANA_AUTO_PAYMENT_ON,
|
||||
MANA_AUTO_PAYMENT_OFF
|
||||
}
|
|
@ -68,6 +68,7 @@ import mage.util.functions.ApplyToPermanent;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import mage.constants.PlayerAction;
|
||||
|
||||
public interface Game extends MageItem, Serializable {
|
||||
|
||||
|
@ -233,10 +234,8 @@ public interface Game extends MageItem, Serializable {
|
|||
void addCommander(Commander commander);
|
||||
void addPermanent(Permanent permanent);
|
||||
|
||||
// priority methods
|
||||
void passPriorityUntilNextYourTurn(UUID userId);
|
||||
void passTurnPriority(UUID userId);
|
||||
void restorePriority(UUID userId);
|
||||
// priority method
|
||||
void sendPlayerAction(PlayerAction playerAction, UUID playerId);
|
||||
|
||||
/**
|
||||
* This version supports copying of copies of any depth.
|
||||
|
|
|
@ -1022,22 +1022,15 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void passPriorityUntilNextYourTurn(UUID playerId) {
|
||||
public void sendPlayerAction(PlayerAction playerAction, UUID playerId) {
|
||||
Player player = state.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.passPriorityUntilNextYourTurn(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void passTurnPriority(UUID playerId) {
|
||||
Player player = state.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.passTurnPriority(this);
|
||||
}
|
||||
player.sendPlayerAction(playerAction, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void setManaPoolMode(UUID playerId, boolean autoPayment) {
|
||||
|
@ -1047,14 +1040,6 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void restorePriority(UUID playerId) {
|
||||
Player player = state.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.restorePriority(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playPriority(UUID activePlayerId, boolean resuming) {
|
||||
int bookmark = 0;
|
||||
|
|
|
@ -59,6 +59,7 @@ import mage.util.Copyable;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.game.combat.CombatGroup;
|
||||
|
||||
/**
|
||||
|
@ -256,10 +257,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
void abort();
|
||||
void skip();
|
||||
|
||||
//priority methods
|
||||
void passPriorityUntilNextYourTurn(Game game);
|
||||
void passTurnPriority(Game game);
|
||||
void restorePriority(Game game);
|
||||
// priority, undo, ...
|
||||
void sendPlayerAction(PlayerAction passPriorityAction, Game game);
|
||||
|
||||
int getStoredBookmark();
|
||||
void setStoredBookmark(int bookmark);
|
||||
|
|
|
@ -81,6 +81,7 @@ import mage.constants.AsThoughEffectType;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.constants.SpellAbilityType;
|
||||
|
@ -149,17 +150,21 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
protected int maxHandSize = 7;
|
||||
protected int maxAttackedBy = Integer.MAX_VALUE;
|
||||
protected ManaPool manaPool;
|
||||
// priority control
|
||||
protected boolean passed; // player passed priority
|
||||
protected boolean passedTurn;
|
||||
protected boolean passedTurn; // F4
|
||||
protected boolean passedUntilEndOfTurn; // F5
|
||||
/**
|
||||
* This indicates that player passed all turns until his own turn starts (F9).
|
||||
* Note! This differs from passedTurn as it doesn't care about spells and abilities in the stack and will pass them as well.
|
||||
*/
|
||||
protected boolean passedAllTurns;
|
||||
|
||||
protected int turns;
|
||||
protected int storedBookmark = -1;
|
||||
protected int priorityTimeLeft = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* This indicates that player passed all turns until his own turn starts.
|
||||
* Note! This differs from passedTurn as it doesn't care about spells and abilities in the stack and will pass them as well.
|
||||
*/
|
||||
protected boolean passedAllTurns;
|
||||
|
||||
|
||||
// conceded or connection lost game
|
||||
protected boolean left;
|
||||
|
@ -279,7 +284,9 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.passed = player.passed;
|
||||
|
||||
this.passedTurn = player.passedTurn;
|
||||
this.passedUntilEndOfTurn = player.passedUntilEndOfTurn;
|
||||
this.passedAllTurns = player.passedAllTurns;
|
||||
|
||||
this.priorityTimeLeft = player.getPriorityTimeLeft();
|
||||
this.reachedNextTurnAfterLeaving = player.reachedNextTurnAfterLeaving;
|
||||
|
||||
|
@ -386,6 +393,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.playersUnderYourControl.clear();
|
||||
this.passed = false;
|
||||
this.passedTurn = false;
|
||||
this.passedUntilEndOfTurn = false;
|
||||
this.passedAllTurns = false;
|
||||
this.canGainLife = true;
|
||||
this.canLoseLife = true;
|
||||
|
@ -533,6 +541,9 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
@Override
|
||||
public void endOfTurn(Game game) {
|
||||
this.passedTurn = false;
|
||||
if (!game.getActivePlayerId().equals(playerId)) {
|
||||
this.passedUntilEndOfTurn = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1617,25 +1628,28 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void passPriorityUntilNextYourTurn(Game game) {
|
||||
passedTurn = true;
|
||||
passedAllTurns = true;
|
||||
this.skip();
|
||||
logger.trace("Passed priority for turns");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passTurnPriority(Game game) {
|
||||
passedTurn = true;
|
||||
this.skip();
|
||||
logger.trace("Passed priority for turn");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restorePriority(Game game) {
|
||||
passedAllTurns = false;
|
||||
passedTurn = false;
|
||||
logger.trace("Restore priority");
|
||||
public void sendPlayerAction(PlayerAction passPriorityAction, Game game) {
|
||||
switch(passPriorityAction) {
|
||||
case PASS_PRIORITY_UNTIL_MY_NEXT_TURN:
|
||||
passedTurn = true;
|
||||
passedAllTurns = true;
|
||||
this.skip();
|
||||
break;
|
||||
case PASS_PRIORITY_UNTIL_OPPONENTS_TURN_END_STEP:
|
||||
passedUntilEndOfTurn = true;
|
||||
this.skip();
|
||||
break;
|
||||
case PASS_PRIORITY_UNTIL_NEXT_TURN:
|
||||
passedTurn = true;
|
||||
this.skip();
|
||||
break;
|
||||
case PASS_PRIORITY_CANCEL_ALL_ACTIONS:
|
||||
passedAllTurns = false;
|
||||
passedTurn = false;
|
||||
passedUntilEndOfTurn = false;
|
||||
break;
|
||||
}
|
||||
logger.trace("PASS Priority: " + passPriorityAction.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue