mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Multiplayer - Fixed a bug that a player that left a multiplayer game was not handled correctly. Next game did not start. Running game was ended after some minutes.
This commit is contained in:
parent
54f0fd8fc1
commit
8fd2a9e234
2 changed files with 9 additions and 5 deletions
|
@ -431,6 +431,7 @@ public class TableController {
|
||||||
if (player != null && player.isInGame()) {
|
if (player != null && player.isInGame()) {
|
||||||
GameManager.getInstance().quitMatch(game.getId(), userId);
|
GameManager.getInstance().quitMatch(game.getId(), userId);
|
||||||
}
|
}
|
||||||
|
match.quitMatch(playerId);
|
||||||
} else {
|
} else {
|
||||||
if (table.getState().equals(TableState.SIDEBOARDING)) {
|
if (table.getState().equals(TableState.SIDEBOARDING)) {
|
||||||
if (!matchPlayer.isDoneSideboarding()) {
|
if (!matchPlayer.isDoneSideboarding()) {
|
||||||
|
@ -519,8 +520,10 @@ public class TableController {
|
||||||
GameManager.getInstance().createGameSession(match.getGame(), userPlayerMap, table.getId(), choosingPlayerId);
|
GameManager.getInstance().createGameSession(match.getGame(), userPlayerMap, table.getId(), choosingPlayerId);
|
||||||
String creator = null;
|
String creator = null;
|
||||||
StringBuilder opponent = new StringBuilder();
|
StringBuilder opponent = new StringBuilder();
|
||||||
|
int activePlayers = 0;
|
||||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||||
if (!match.getPlayer(entry.getValue()).hasQuit()) {
|
if (!match.getPlayer(entry.getValue()).hasQuit()) {
|
||||||
|
activePlayers++;
|
||||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (!user.isConnected()) {
|
if (!user.isConnected()) {
|
||||||
|
@ -549,11 +552,11 @@ public class TableController {
|
||||||
matchPlayer.setQuit(true);
|
matchPlayer.setQuit(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Match player has already quit
|
|
||||||
throw new MageException("Can't start game - user already quit userId " + entry.getKey());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (activePlayers < 2) {
|
||||||
|
throw new MageException("Can't start game - Less than two players active - " +activePlayers);
|
||||||
|
}
|
||||||
// Append AI opponents to the log file
|
// Append AI opponents to the log file
|
||||||
for (MatchPlayer mPlayer :match.getPlayers()) {
|
for (MatchPlayer mPlayer :match.getPlayers()) {
|
||||||
if (!mPlayer.getPlayer().isHuman()) {
|
if (!mPlayer.getPlayer().isHuman()) {
|
||||||
|
@ -855,7 +858,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
if (matchPlayer.getPlayer().isHuman()) {
|
if (matchPlayer.getPlayer().isHuman()) {
|
||||||
humanPlayers++;
|
humanPlayers++;
|
||||||
if (!matchPlayer.hasQuit()) {
|
if (!matchPlayer.hasQuit() && match.getGame() != null && matchPlayer.getPlayer().isInGame()) {
|
||||||
User user = UserManager.getInstance().getUser(userPlayerEntry.getKey());
|
User user = UserManager.getInstance().getUser(userPlayerEntry.getKey());
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
logger.debug("- Active user of match is missing: " + matchPlayer.getName());
|
logger.debug("- Active user of match is missing: " + matchPlayer.getName());
|
||||||
|
|
|
@ -289,12 +289,13 @@ public class GameSession extends GameWatcher {
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
logger.fatal("Game session game quit exception " + (ex.getMessage() == null ? "null":ex.getMessage()));
|
logger.fatal("Game session game quit exception " + (ex.getMessage() == null ? "null":ex.getMessage()));
|
||||||
|
logger.debug("- gameId:" + game.getId() +" playerId: " + playerId);
|
||||||
if (ex.getCause() != null) {
|
if (ex.getCause() != null) {
|
||||||
logger.debug("- Cause: " + (ex.getCause().getMessage() == null ? "null":ex.getCause().getMessage()));
|
logger.debug("- Cause: " + (ex.getCause().getMessage() == null ? "null":ex.getCause().getMessage()));
|
||||||
}
|
}
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}else {
|
}else {
|
||||||
logger.fatal("Game session game quit exception - null");
|
logger.fatal("Game session game quit exception - null gameId:" + game.getId() +" playerId: " + playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue