mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
* Some changes to game handling to support replay in the future (not working yet).
This commit is contained in:
parent
9a15bdb933
commit
e6f55d3b80
10 changed files with 55 additions and 37 deletions
|
|
@ -345,13 +345,13 @@ public class TableController {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean replayTable(UUID userId) {
|
||||
if (table.getState() != TableState.FINISHED) {
|
||||
return false;
|
||||
}
|
||||
ReplayManager.getInstance().replayGame(table.getId(), userId);
|
||||
return true;
|
||||
}
|
||||
// public boolean replayTable(UUID userId) {
|
||||
// if (table.getState() != TableState.FINISHED) {
|
||||
// return false;
|
||||
// }
|
||||
// ReplayManager.getInstance().replayGame(table.getId(), userId);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
private Player createPlayer(String name, String playerType, int skill) {
|
||||
Player player;
|
||||
|
|
|
|||
|
|
@ -249,12 +249,12 @@ public class TableManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean replayTable(UUID userId, UUID tableId) {
|
||||
if (controllers.containsKey(tableId)) {
|
||||
return controllers.get(tableId).replayTable(userId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// public boolean replayTable(UUID userId, UUID tableId) {
|
||||
// if (controllers.containsKey(tableId)) {
|
||||
// return controllers.get(tableId).replayTable(userId);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public void endGame(UUID tableId) {
|
||||
if (controllers.containsKey(tableId)) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import java.util.Map.Entry;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.constants.TableState;
|
||||
import mage.game.Table;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.players.net.UserData;
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ public class GameController implements GameCallback {
|
|||
this.userPlayerMap = userPlayerMap;
|
||||
chatId = ChatManager.getInstance().createChatSession();
|
||||
this.game = game;
|
||||
this.game.setSaveGame(ConfigSettings.getInstance().isSaveGameActivated());
|
||||
this.tableId = tableId;
|
||||
this.choosingPlayerId = choosingPlayerId;
|
||||
for (Player player: game.getPlayers().values()) {
|
||||
|
|
|
|||
|
|
@ -73,5 +73,8 @@ public class ReplayManager {
|
|||
replaySessions.get(gameId.toString() + userId.toString()).next(moves);
|
||||
}
|
||||
|
||||
public void endReplay(UUID gameId, UUID userId) {
|
||||
replaySessions.remove(gameId.toString() + userId.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import mage.interfaces.callback.ClientCallback;
|
|||
import mage.server.User;
|
||||
import mage.server.UserManager;
|
||||
import mage.view.GameView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -43,8 +42,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class ReplaySession implements GameCallback {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ReplaySession.class);
|
||||
private GameReplay replay;
|
||||
private final GameReplay replay;
|
||||
protected UUID userId;
|
||||
|
||||
ReplaySession(UUID gameId, UUID userId) {
|
||||
|
|
@ -85,6 +83,7 @@ public class ReplaySession implements GameCallback {
|
|||
if (user != null) {
|
||||
user.fireCallback(new ClientCallback("replayDone", replay.getGame().getId(), result));
|
||||
}
|
||||
ReplayManager.getInstance().endReplay(replay.getGame().getId(), userId);
|
||||
}
|
||||
|
||||
private void updateGame(final GameState state, Game game) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue