game, refactor: improved player related code, fixed miss reset fields between games like commanderIds (#11081, #11628)

This commit is contained in:
Oleg Agafonov 2024-01-15 00:25:51 +04:00
parent a090a2a9d0
commit 6ac2f44cc1
7 changed files with 92 additions and 71 deletions

View file

@ -44,7 +44,7 @@ public class TableController {
private static final Logger logger = Logger.getLogger(TableController.class);
private final ManagerFactory managerFactory;
private final UUID userId;
private final UUID userId; // table owner/creator (null in tourney's table)
private final UUID chatId;
private final String controllerName;
private final Table table;
@ -604,17 +604,17 @@ public class TableController {
if (table.getState() == TableState.STARTING) {
try {
if (table.isTournamentSubTable()) {
logger.info("Tourn. match started id:" + match.getId() + " tournId: " + table.getTournament().getId());
logger.info("Tourney MATCH started id:" + match.getId() + " tournId: " + table.getTournament().getId());
} else {
managerFactory.userManager().getUser(userId).ifPresent(user -> {
logger.info("MATCH started [" + match.getName() + "] " + match.getId() + " (" + user.getName() + ')');
logger.info("Single MATCH started [" + match.getName() + "] " + match.getId() + " (" + user.getName() + ')');
logger.debug("- " + match.getOptions().getGameType() + " - " + match.getOptions().getDeckType());
});
}
match.startMatch();
startGame(null);
} catch (GameException ex) {
logger.fatal("Error starting match ", ex);
} catch (GameException e) {
logger.fatal("Error starting match: " + e, e);
match.endGame();
}
}

View file

@ -102,13 +102,14 @@ public class GameController implements GameCallback {
public void cleanUp() {
cancelTimeout();
for (GameSessionPlayer gameSessionPlayer : getGameSessions()) {
gameSessionPlayer.cleanUp();
}
managerFactory.chatManager().destroyChatSession(chatId);
for (PriorityTimer priorityTimer : timers.values()) {
priorityTimer.cancel();
}
getGameSessions().forEach(GameSessionPlayer::cleanUp);
getGameSessionWatchers().forEach(GameSessionWatcher::cleanUp);
managerFactory.chatManager().destroyChatSession(chatId);
}
private void init() {