mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
show Table Waiting dialog on reconnect
This commit is contained in:
parent
161404242f
commit
2ad50b2983
7 changed files with 82 additions and 29 deletions
|
|
@ -136,6 +136,9 @@ public class TableController {
|
|||
Player player = createPlayer(name, seat.getPlayerType(), skill);
|
||||
tournament.addPlayer(player, seat.getPlayerType());
|
||||
table.joinTable(player, seat);
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
user.addTable(player.getId(), table);
|
||||
user.joinedTable(table.getRoomId(), table.getId(), true);
|
||||
logger.info("player joined " + player.getId());
|
||||
//only add human players to sessionPlayerMap
|
||||
if (seat.getPlayer().isHuman()) {
|
||||
|
|
@ -161,6 +164,9 @@ public class TableController {
|
|||
Player player = createPlayer(name, seat.getPlayerType(), skill);
|
||||
match.addPlayer(player, deck);
|
||||
table.joinTable(player, seat);
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
user.addTable(player.getId(), table);
|
||||
user.joinedTable(table.getRoomId(), table.getId(), false);
|
||||
logger.info("player joined " + player.getId());
|
||||
//only add human players to sessionPlayerMap
|
||||
if (seat.getPlayer().isHuman()) {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.Table;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.server.draft.DraftSession;
|
||||
import mage.server.game.GameManager;
|
||||
|
|
@ -57,6 +58,7 @@ public class User {
|
|||
private Date connectionTime = new Date();
|
||||
private Date lastActivity = new Date();
|
||||
private UserState userState;
|
||||
private Map<UUID, Table> tables = new HashMap<UUID, Table>();
|
||||
private Map<UUID, GameSession> gameSessions = new HashMap<UUID, GameSession>();
|
||||
private Map<UUID, DraftSession> draftSessions = new HashMap<UUID, DraftSession>();
|
||||
private Map<UUID, TournamentSession> tournamentSessions = new HashMap<UUID, TournamentSession>();
|
||||
|
|
@ -110,6 +112,10 @@ public class User {
|
|||
}
|
||||
}
|
||||
|
||||
public void joinedTable(final UUID roomId, final UUID tableId, boolean isTournament) {
|
||||
fireCallback(new ClientCallback("joinedTable", tableId, new TableClientMessage(roomId, tableId, isTournament)));
|
||||
}
|
||||
|
||||
public void gameStarted(final UUID gameId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId)));
|
||||
}
|
||||
|
|
@ -178,6 +184,9 @@ public class User {
|
|||
entry.getValue().init();
|
||||
entry.getValue().update();
|
||||
}
|
||||
for (Entry<UUID, Table> entry: tables.entrySet()) {
|
||||
joinedTable(entry.getValue().getRoomId(), entry.getValue().getId(), entry.getValue().isTournament());
|
||||
}
|
||||
}
|
||||
|
||||
public void addGame(UUID playerId, GameSession gameSession) {
|
||||
|
|
@ -204,15 +213,29 @@ public class User {
|
|||
tournamentSessions.remove(playerId);
|
||||
}
|
||||
|
||||
public void addTable(UUID playerId, Table table) {
|
||||
tables.put(playerId, table);
|
||||
}
|
||||
|
||||
public void removeTable(UUID playerId) {
|
||||
tables.remove(playerId);
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
for (Entry<UUID, GameSession> entry: gameSessions.entrySet()) {
|
||||
entry.getValue().kill();
|
||||
for (GameSession session: gameSessions.values()) {
|
||||
session.kill();
|
||||
}
|
||||
for (Entry<UUID, DraftSession> entry: draftSessions.entrySet()) {
|
||||
entry.getValue().setKilled();
|
||||
for (DraftSession session: draftSessions.values()) {
|
||||
session.setKilled();
|
||||
}
|
||||
for (Entry<UUID, TournamentSession> entry: tournamentSessions.entrySet()) {
|
||||
entry.getValue().setKilled();
|
||||
for (TournamentSession session: tournamentSessions.values()) {
|
||||
session.setKilled();
|
||||
}
|
||||
for (Entry<UUID, Table> entry: tables.entrySet()) {
|
||||
entry.getValue().leaveTable(entry.getKey());
|
||||
if (TableManager.getInstance().isTableOwner(entry.getValue().getId(), userId)) {
|
||||
TableManager.getInstance().removeTable(userId, entry.getValue().getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue