mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
server: fixed game errors in rare use cases for big games (related to #11285);
This commit is contained in:
parent
3ae1f0d7fb
commit
4f0691ad08
1 changed files with 9 additions and 5 deletions
|
|
@ -209,16 +209,20 @@ public class GameSessionPlayer extends GameSessionWatcher {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static GameView prepareGameView(Game game, UUID playerId, UUID userId) {
|
public static GameView prepareGameView(Game game, UUID playerId, UUID userId) {
|
||||||
Player player = game.getPlayer(playerId); // null for watcher
|
// game view calculation can take some time and can be called from non-game thread,
|
||||||
GameView gameView = new GameView(game.getState(), game, playerId, null);
|
// so use copy for thread save (protection from ConcurrentModificationException)
|
||||||
|
Game sourceGame = game.copy();
|
||||||
|
|
||||||
|
Player player = sourceGame.getPlayer(playerId); // null for watcher
|
||||||
|
GameView gameView = new GameView(sourceGame.getState(), sourceGame, playerId, null);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (gameView.getPriorityPlayerName().equals(player.getName())) {
|
if (gameView.getPriorityPlayerName().equals(player.getName())) {
|
||||||
gameView.setCanPlayObjects(player.getPlayableObjects(game, Zone.ALL));
|
gameView.setCanPlayObjects(player.getPlayableObjects(sourceGame, Zone.ALL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processControlledPlayers(game, player, gameView);
|
processControlledPlayers(sourceGame, player, gameView);
|
||||||
processWatchedHands(game, userId, gameView);
|
processWatchedHands(sourceGame, userId, gameView);
|
||||||
//TODO: should player who controls another player's turn be able to look at all these cards?
|
//TODO: should player who controls another player's turn be able to look at all these cards?
|
||||||
|
|
||||||
return gameView;
|
return gameView;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue