mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
fixed bug in pvp phase stops (now based on uuid, not player's name)
This commit is contained in:
parent
5df3a6e488
commit
33d29bcdac
4 changed files with 31 additions and 8 deletions
|
|
@ -138,7 +138,6 @@ public class JoinTableDialog extends MageDialog {
|
||||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||||
Session session = MageFrame.getSession();
|
Session session = MageFrame.getSession();
|
||||||
try {
|
try {
|
||||||
PhaseManager.getInstance().setName(this.newPlayerPanel.getPlayerName());
|
|
||||||
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleError(ex);
|
handleError(ex);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import javax.swing.JOptionPane;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.chat.ChatPanel;
|
import mage.client.chat.ChatPanel;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
|
import mage.client.util.GameManager;
|
||||||
import mage.interfaces.callback.CallbackClient;
|
import mage.interfaces.callback.CallbackClient;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.util.Logging;
|
import mage.util.Logging;
|
||||||
|
|
@ -73,6 +74,7 @@ public class Client implements CallbackClient {
|
||||||
try {
|
try {
|
||||||
if (callback.getMethod().equals("startGame")) {
|
if (callback.getMethod().equals("startGame")) {
|
||||||
UUID[] data = (UUID[]) callback.getData();
|
UUID[] data = (UUID[]) callback.getData();
|
||||||
|
GameManager.getInstance().setCurrentPlayerUUID(data[1]);
|
||||||
gameStarted(data[0], data[1]);
|
gameStarted(data[0], data[1]);
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("replayGame")) {
|
else if (callback.getMethod().equals("replayGame")) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package mage.client.util;
|
package mage.client.util;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls game state on client side.
|
* Controls game state on client side.
|
||||||
*
|
*
|
||||||
|
|
@ -7,15 +9,27 @@ package mage.client.util;
|
||||||
*/
|
*/
|
||||||
public class GameManager {
|
public class GameManager {
|
||||||
private static GameManager fInstance = new GameManager();
|
private static GameManager fInstance = new GameManager();
|
||||||
|
|
||||||
public static GameManager getInstance() {
|
public static GameManager getInstance() {
|
||||||
return fInstance;
|
return fInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStackSize(int stackSize) {
|
public void setStackSize(int stackSize) {
|
||||||
this.stackSize = stackSize;
|
this.stackSize = stackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStackSize() {
|
public int getStackSize() {
|
||||||
return stackSize;
|
return stackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int stackSize;
|
public UUID getCurrentPlayerUUID() {
|
||||||
|
return currentPlayerUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentPlayerUUID(UUID currentPlayerUUID) {
|
||||||
|
this.currentPlayerUUID = currentPlayerUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int stackSize;
|
||||||
|
private UUID currentPlayerUUID;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,11 @@ package mage.client.util;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.view.GameView;
|
import mage.view.GameView;
|
||||||
|
import mage.view.PlayerView;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
public class PhaseManager {
|
public class PhaseManager {
|
||||||
|
|
@ -51,21 +53,27 @@ public class PhaseManager {
|
||||||
put("End Turn - play instants and activated abilities.", END_OF_TURN_OTHERS);
|
put("End Turn - play instants and activated abilities.", END_OF_TURN_OTHERS);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
private String yourName;
|
|
||||||
|
|
||||||
public static PhaseManager getInstance() {
|
public static PhaseManager getInstance() {
|
||||||
return fInstance;
|
return fInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String yourName) {
|
|
||||||
this.yourName = yourName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSkip(GameView gameView, String message) {
|
public boolean isSkip(GameView gameView, String message) {
|
||||||
if (GameManager.getInstance().getStackSize() > 0) {
|
if (GameManager.getInstance().getStackSize() > 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Map<String, String> map = gameView.getActivePlayerName().equals(DEFAULT_PLAYER_NAME) ? mapYou : mapOthers;
|
UUID activePlayer = null;
|
||||||
|
Map<String, String> map = mapOthers;
|
||||||
|
for (PlayerView playerView : gameView.getPlayers()) {
|
||||||
|
if (playerView.isActive()) {
|
||||||
|
activePlayer = playerView.getPlayerId();
|
||||||
|
if (activePlayer.equals(GameManager.getInstance().getCurrentPlayerUUID())) {
|
||||||
|
map = mapYou;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (activePlayer == null) {
|
||||||
|
throw new IllegalStateException("No active player found.");
|
||||||
|
}
|
||||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||||
if (message.equals(entry.getKey())) {
|
if (message.equals(entry.getKey())) {
|
||||||
Preferences prefs = MageFrame.getPreferences();
|
Preferences prefs = MageFrame.getPreferences();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue