mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
* Fixed a bug that tournament player was not removed correctly, if he left thetournament start panel. Changes to logging.
This commit is contained in:
parent
5f85d52837
commit
5a2b445e43
2 changed files with 12 additions and 6 deletions
|
|
@ -157,8 +157,6 @@ public class TableController {
|
||||||
}
|
}
|
||||||
Player player = createPlayer(name, seat.getPlayerType(), skill);
|
Player player = createPlayer(name, seat.getPlayerType(), skill);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
tournament.addPlayer(player, seat.getPlayerType());
|
|
||||||
table.joinTable(player, seat);
|
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
logger.fatal(new StringBuilder("couldn't get user ").append(name).append(" for join tornament userId = ").append(userId).toString());
|
logger.fatal(new StringBuilder("couldn't get user ").append(name).append(" for join tornament userId = ").append(userId).toString());
|
||||||
|
|
@ -168,6 +166,8 @@ public class TableController {
|
||||||
user.showUserMessage("Join Table", new StringBuilder("A ").append(seat.getPlayerType()).append(" player can't join this table.").toString());
|
user.showUserMessage("Join Table", new StringBuilder("A ").append(seat.getPlayerType()).append(" player can't join this table.").toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
tournament.addPlayer(player, seat.getPlayerType());
|
||||||
|
table.joinTable(player, seat);
|
||||||
user.addTable(player.getId(), table);
|
user.addTable(player.getId(), table);
|
||||||
logger.debug("player joined " + player.getId());
|
logger.debug("player joined " + player.getId());
|
||||||
//only inform human players and add them to sessionPlayerMap
|
//only inform human players and add them to sessionPlayerMap
|
||||||
|
|
@ -371,7 +371,7 @@ public class TableController {
|
||||||
if (table.getState() == TableState.WAITING || table.getState() == TableState.STARTING) {
|
if (table.getState() == TableState.WAITING || table.getState() == TableState.STARTING) {
|
||||||
table.leaveNotStartedTable(playerId);
|
table.leaveNotStartedTable(playerId);
|
||||||
if (table.isTournament()) {
|
if (table.isTournament()) {
|
||||||
TournamentManager.getInstance().quit(tournament.getId(), userId);
|
tournament.removePlayer(playerId);
|
||||||
} else {
|
} else {
|
||||||
match.leave(playerId);
|
match.leave(playerId);
|
||||||
}
|
}
|
||||||
|
|
@ -431,8 +431,14 @@ public class TableController {
|
||||||
public synchronized void startMatch() {
|
public synchronized void startMatch() {
|
||||||
if (table.getState() == TableState.STARTING) {
|
if (table.getState() == TableState.STARTING) {
|
||||||
try {
|
try {
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
String tableInfo;
|
||||||
logger.info(new StringBuilder("User (table controller) ").append(user.getName()).append(" starts match: ").append(match.getId()));
|
if (table.isTournamentSubTable()) {
|
||||||
|
tableInfo = "Tournament tournamentId: " + table.getTournament().getId() + " - sub";
|
||||||
|
} else {
|
||||||
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
|
tableInfo = "User (table controller) " + user.getName();
|
||||||
|
}
|
||||||
|
logger.info(new StringBuilder(tableInfo).append(" match started match Id: ").append(match.getId()));
|
||||||
match.startMatch();
|
match.startMatch();
|
||||||
startGame(null);
|
startGame(null);
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ public class TableManager {
|
||||||
public void leaveTable(UUID userId, UUID tableId) {
|
public void leaveTable(UUID userId, UUID tableId) {
|
||||||
if (controllers.containsKey(tableId)) {
|
if (controllers.containsKey(tableId)) {
|
||||||
controllers.get(tableId).leaveTable(userId);
|
controllers.get(tableId).leaveTable(userId);
|
||||||
// table not started yet and user is he owner, remove the table
|
// table not started yet and user is the owner, remove the table
|
||||||
if (isTableOwner(tableId, userId)) {
|
if (isTableOwner(tableId, userId)) {
|
||||||
if (getTable(tableId).getState().equals(TableState.WAITING)
|
if (getTable(tableId).getState().equals(TableState.WAITING)
|
||||||
|| getTable(tableId).getState().equals(TableState.STARTING)) {
|
|| getTable(tableId).getState().equals(TableState.STARTING)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue