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
|
||||
Session session = MageFrame.getSession();
|
||||
try {
|
||||
PhaseManager.getInstance().setName(this.newPlayerPanel.getPlayerName());
|
||||
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
||||
} catch (Exception ex) {
|
||||
handleError(ex);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import javax.swing.JOptionPane;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.chat.ChatPanel;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.GameManager;
|
||||
import mage.interfaces.callback.CallbackClient;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.util.Logging;
|
||||
|
|
@ -73,6 +74,7 @@ public class Client implements CallbackClient {
|
|||
try {
|
||||
if (callback.getMethod().equals("startGame")) {
|
||||
UUID[] data = (UUID[]) callback.getData();
|
||||
GameManager.getInstance().setCurrentPlayerUUID(data[1]);
|
||||
gameStarted(data[0], data[1]);
|
||||
}
|
||||
else if (callback.getMethod().equals("replayGame")) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package mage.client.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Controls game state on client side.
|
||||
*
|
||||
|
|
@ -7,15 +9,27 @@ package mage.client.util;
|
|||
*/
|
||||
public class GameManager {
|
||||
private static GameManager fInstance = new GameManager();
|
||||
|
||||
public static GameManager getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public void setStackSize(int stackSize) {
|
||||
this.stackSize = stackSize;
|
||||
}
|
||||
|
||||
public int getStackSize() {
|
||||
return 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.view.GameView;
|
||||
import mage.view.PlayerView;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
public class PhaseManager {
|
||||
|
|
@ -51,21 +53,27 @@ public class PhaseManager {
|
|||
put("End Turn - play instants and activated abilities.", END_OF_TURN_OTHERS);
|
||||
}};
|
||||
|
||||
private String yourName;
|
||||
|
||||
public static PhaseManager getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public void setName(String yourName) {
|
||||
this.yourName = yourName;
|
||||
}
|
||||
|
||||
public boolean isSkip(GameView gameView, String message) {
|
||||
if (GameManager.getInstance().getStackSize() > 0) {
|
||||
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()) {
|
||||
if (message.equals(entry.getKey())) {
|
||||
Preferences prefs = MageFrame.getPreferences();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue