mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Some rework of User/Tournament/Quit handling.
This commit is contained in:
parent
9ea54b38c2
commit
0ef340d108
10 changed files with 130 additions and 113 deletions
|
@ -213,7 +213,7 @@ public class TableController {
|
|||
//only inform human players and add them to sessionPlayerMap
|
||||
if (seat.getPlayer().isHuman()) {
|
||||
user.addTable(player.getId(), table);
|
||||
user.joinedTable(table.getRoomId(), table.getId(), true);
|
||||
user.ccJoinedTable(table.getRoomId(), table.getId(), true);
|
||||
userPlayerMap.put(userId, player.getId());
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ public class TableController {
|
|||
//only inform human players and add them to sessionPlayerMap
|
||||
if (seat.getPlayer().isHuman()) {
|
||||
user.addTable(player.getId(), table);
|
||||
user.joinedTable(table.getRoomId(), table.getId(), false);
|
||||
user.ccJoinedTable(table.getRoomId(), table.getId(), false);
|
||||
userPlayerMap.put(userId, player.getId());
|
||||
}
|
||||
return true;
|
||||
|
@ -392,7 +392,7 @@ public class TableController {
|
|||
|
||||
public boolean watchTable(UUID userId) {
|
||||
if (table.isTournament()) {
|
||||
UserManager.getInstance().getUser(userId).showTournament(table.getTournament().getId());
|
||||
UserManager.getInstance().getUser(userId).ccShowTournament(table.getTournament().getId());
|
||||
return true;
|
||||
} else {
|
||||
if (table.isTournamentSubTable() && !table.getTournament().getOptions().isWatchingAllowed()) {
|
||||
|
@ -405,7 +405,7 @@ public class TableController {
|
|||
if (userPlayerMap.get(userId) != null) {
|
||||
return false;
|
||||
}
|
||||
return UserManager.getInstance().getUser(userId).watchGame(match.getGame().getId());
|
||||
return UserManager.getInstance().getUser(userId).ccWatchGame(match.getGame().getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -550,7 +550,7 @@ public class TableController {
|
|||
// activePlayers++;
|
||||
Player player = match.getPlayer(entry.getValue()).getPlayer();
|
||||
player.setRequestToShowHandCardsAllowed(user.getUserData().allowRequestShowHandCards());
|
||||
user.gameStarted(match.getGame().getId(), entry.getValue());
|
||||
user.ccGameStarted(match.getGame().getId(), entry.getValue());
|
||||
|
||||
if (creator == null) {
|
||||
creator = user.getName();
|
||||
|
@ -618,7 +618,7 @@ public class TableController {
|
|||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
if (user != null) {
|
||||
logger.info(new StringBuilder("User ").append(user.getName()).append(" tournament started: ").append(tournament.getId()).append(" userId: ").append(user.getId()));
|
||||
user.tournamentStarted(tournament.getId(), entry.getValue());
|
||||
user.ccTournamentStarted(tournament.getId(), entry.getValue());
|
||||
}
|
||||
}
|
||||
ServerMessagesUtil.getInstance().incTournamentsStarted();
|
||||
|
@ -627,7 +627,7 @@ public class TableController {
|
|||
catch (Exception ex) {
|
||||
logger.fatal("Error starting tournament", ex);
|
||||
TableManager.getInstance().removeTable(table.getId());
|
||||
TournamentManager.getInstance().kill(tournament.getId(), userId);
|
||||
TournamentManager.getInstance().quit(tournament.getId(), userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -638,7 +638,7 @@ public class TableController {
|
|||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
if (user != null) {
|
||||
logger.info(new StringBuilder("User ").append(user.getName()).append(" draft started: ").append(draft.getId()).append(" userId: ").append(user.getId()));
|
||||
user.draftStarted(draft.getId(), entry.getValue());
|
||||
user.ccDraftStarted(draft.getId(), entry.getValue());
|
||||
} else {
|
||||
logger.fatal(new StringBuilder("Start draft user not found userId: ").append(entry.getKey()));
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ public class TableController {
|
|||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
||||
if (user != null) {
|
||||
user.sideboard(deck, table.getId(), remaining, options.isLimited());
|
||||
user.ccSideboard(deck, table.getId(), remaining, options.isLimited());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class User {
|
|||
private final Map<UUID, Table> tables;
|
||||
private final Map<UUID, GameSessionPlayer> gameSessions;
|
||||
private final Map<UUID, DraftSession> draftSessions;
|
||||
private final Map<UUID, TournamentSession> tournamentSessions;
|
||||
private final Map<UUID, UUID> userTournaments; // playerId, tournamentId
|
||||
private final Map<UUID, TournamentSession> constructing;
|
||||
private final Map<UUID, Deck> sideboarding;
|
||||
private final List<UUID> watchedGames;
|
||||
|
@ -96,7 +96,7 @@ public class User {
|
|||
this.tables = new ConcurrentHashMap<>();
|
||||
this.gameSessions = new ConcurrentHashMap<>();
|
||||
this.draftSessions = new ConcurrentHashMap<>();
|
||||
this.tournamentSessions = new ConcurrentHashMap<>();
|
||||
this.userTournaments = new ConcurrentHashMap<>();
|
||||
this.constructing = new ConcurrentHashMap<>();
|
||||
this.sideboarding = new ConcurrentHashMap<>();
|
||||
this.watchedGames = new ArrayList<>();
|
||||
|
@ -183,36 +183,36 @@ public class User {
|
|||
}
|
||||
}
|
||||
|
||||
public void joinedTable(final UUID roomId, final UUID tableId, boolean isTournament) {
|
||||
public void ccJoinedTable(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) {
|
||||
public void ccGameStarted(final UUID gameId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId)));
|
||||
}
|
||||
|
||||
public void draftStarted(final UUID draftId, final UUID playerId) {
|
||||
public void ccDraftStarted(final UUID draftId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startDraft", draftId, new TableClientMessage(draftId, playerId)));
|
||||
}
|
||||
|
||||
public void tournamentStarted(final UUID tournamentId, final UUID playerId) {
|
||||
public void ccTournamentStarted(final UUID tournamentId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startTournament", tournamentId, new TableClientMessage(tournamentId, playerId)));
|
||||
}
|
||||
|
||||
public void sideboard(final Deck deck, final UUID tableId, final int time, boolean limited) {
|
||||
public void ccSideboard(final Deck deck, final UUID tableId, final int time, boolean limited) {
|
||||
fireCallback(new ClientCallback("sideboard", tableId, new TableClientMessage(deck, tableId, time, limited)));
|
||||
sideboarding.put(tableId, deck);
|
||||
}
|
||||
|
||||
public void construct(final Deck deck, final UUID tableId, final int time) {
|
||||
public void ccConstruct(final Deck deck, final UUID tableId, final int time) {
|
||||
fireCallback(new ClientCallback("construct", tableId, new TableClientMessage(deck, tableId, time)));
|
||||
}
|
||||
|
||||
public void showTournament(final UUID tournamentId) {
|
||||
public void ccShowTournament(final UUID tournamentId) {
|
||||
fireCallback(new ClientCallback("showTournament", tournamentId));
|
||||
}
|
||||
|
||||
public void showGameEndDialog(final UUID gameId) {
|
||||
public void ccShowGameEndDialog(final UUID gameId) {
|
||||
fireCallback(new ClientCallback("showGameEndDialog", gameId));
|
||||
}
|
||||
|
||||
|
@ -223,12 +223,12 @@ public class User {
|
|||
fireCallback(new ClientCallback("showUserMessage", null, messageData ));
|
||||
}
|
||||
|
||||
public boolean watchGame(final UUID gameId) {
|
||||
public boolean ccWatchGame(final UUID gameId) {
|
||||
fireCallback(new ClientCallback("watchGame", gameId));
|
||||
return true;
|
||||
}
|
||||
|
||||
public void replayGame(final UUID gameId) {
|
||||
public void ccReplayGame(final UUID gameId) {
|
||||
fireCallback(new ClientCallback("replayGame", gameId));
|
||||
}
|
||||
|
||||
|
@ -279,22 +279,24 @@ public class User {
|
|||
|
||||
private void reconnect() {
|
||||
for (Entry<UUID, Table> entry: tables.entrySet()) {
|
||||
joinedTable(entry.getValue().getRoomId(), entry.getValue().getId(), entry.getValue().isTournament());
|
||||
ccJoinedTable(entry.getValue().getRoomId(), entry.getValue().getId(), entry.getValue().isTournament());
|
||||
}
|
||||
for (Entry<UUID, TournamentSession> entry: tournamentSessions.entrySet()) {
|
||||
tournamentStarted(entry.getValue().getTournamentId(), entry.getKey());
|
||||
entry.getValue().init();
|
||||
entry.getValue().update();
|
||||
for (Entry<UUID, UUID> entry: userTournaments.entrySet()) {
|
||||
TournamentController tournamentController = TournamentManager.getInstance().getTournamentController(entry.getValue());
|
||||
if (tournamentController != null) {
|
||||
ccTournamentStarted(entry.getValue(), entry.getKey());
|
||||
tournamentController.rejoin(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<UUID, GameSessionPlayer> entry: gameSessions.entrySet()) {
|
||||
gameStarted(entry.getValue().getGameId(), entry.getKey());
|
||||
ccGameStarted(entry.getValue().getGameId(), entry.getKey());
|
||||
entry.getValue().init();
|
||||
GameManager.getInstance().sendPlayerString(entry.getValue().getGameId(), userId, "");
|
||||
}
|
||||
|
||||
for (Entry<UUID, DraftSession> entry: draftSessions.entrySet()) {
|
||||
draftStarted(entry.getValue().getDraftId(), entry.getKey());
|
||||
ccDraftStarted(entry.getValue().getDraftId(), entry.getKey());
|
||||
entry.getValue().init();
|
||||
entry.getValue().update();
|
||||
}
|
||||
|
@ -304,7 +306,7 @@ public class User {
|
|||
}
|
||||
for (Entry<UUID, Deck> entry: sideboarding.entrySet()) {
|
||||
TableController controller = TableManager.getInstance().getController(entry.getKey());
|
||||
sideboard(entry.getValue(), entry.getKey(), controller.getRemainingTime(), controller.getOptions().isLimited());
|
||||
ccSideboard(entry.getValue(), entry.getKey(), controller.getRemainingTime(), controller.getOptions().isLimited());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,12 +326,12 @@ public class User {
|
|||
draftSessions.remove(playerId);
|
||||
}
|
||||
|
||||
public void addTournament(UUID playerId, TournamentSession tournamentSession) {
|
||||
tournamentSessions.put(playerId, tournamentSession);
|
||||
public void addTournament(UUID playerId, UUID tournamentId) {
|
||||
userTournaments.put(playerId, tournamentId);
|
||||
}
|
||||
|
||||
public void removeTournament(UUID playerId) {
|
||||
tournamentSessions.remove(playerId);
|
||||
userTournaments.remove(playerId);
|
||||
}
|
||||
|
||||
public void addTable(UUID playerId, Table table) {
|
||||
|
@ -352,33 +354,30 @@ public class User {
|
|||
sideboarding.remove(tableId);
|
||||
}
|
||||
|
||||
public void remove(DisconnectReason reason) {
|
||||
logger.trace("REMOVE " + getName() + " Game sessions: " + gameSessions.size() );
|
||||
for (GameSessionPlayer gameSession: gameSessions.values()) {
|
||||
logger.debug("-- kill game session of gameId: " + gameSession.getGameId() );
|
||||
gameSession.quitGame();
|
||||
}
|
||||
gameSessions.clear();
|
||||
public void remove(DisconnectReason reason) {
|
||||
logger.trace("REMOVE " + getName() + " Draft sessions " + draftSessions.size());
|
||||
for (DraftSession draftSession: draftSessions.values()) {
|
||||
draftSession.setKilled();
|
||||
}
|
||||
draftSessions.clear();
|
||||
logger.trace("REMOVE " + getName() + " Tournament sessions " + tournamentSessions.size());
|
||||
for (TournamentSession tournamentSession: tournamentSessions.values()) {
|
||||
TournamentController tournamentController = TournamentManager.getInstance().getTournamentController(tournamentSession.getTournamentId());
|
||||
if (tournamentController != null) {
|
||||
tournamentController.quit(userId);
|
||||
}
|
||||
tournamentSession.setKilled();
|
||||
logger.trace("REMOVE " + getName() + " Tournament sessions " + userTournaments.size());
|
||||
for (UUID tournamentId: userTournaments.values()) {
|
||||
TournamentManager.getInstance().quit(tournamentId, getId());
|
||||
}
|
||||
tournamentSessions.clear();
|
||||
userTournaments.clear();
|
||||
logger.trace("REMOVE " + getName() + " Tables " + tables.size());
|
||||
for (Entry<UUID, Table> entry: tables.entrySet()) {
|
||||
logger.debug("-- leave tableId: " + entry.getValue().getId());
|
||||
TableManager.getInstance().leaveTable(userId, entry.getValue().getId());
|
||||
}
|
||||
tables.clear();
|
||||
logger.trace("REMOVE " + getName() + " Game sessions: " + gameSessions.size() );
|
||||
for (GameSessionPlayer gameSessionPlayer: gameSessions.values()) {
|
||||
logger.debug("-- kill game session of gameId: " + gameSessionPlayer.getGameId() );
|
||||
GameManager.getInstance().quitMatch(gameSessionPlayer.getGameId(), userId);
|
||||
gameSessionPlayer.quitGame();
|
||||
}
|
||||
gameSessions.clear();
|
||||
logger.trace("REMOVE " + getName() + " watched Games " + watchedGames.size());
|
||||
for (UUID gameId: watchedGames) {
|
||||
GameManager.getInstance().stopWatching(gameId, userId);
|
||||
|
|
|
@ -442,9 +442,9 @@ public class GameController implements GameCallback {
|
|||
UUID playerId = getPlayerId(userId);
|
||||
if (playerId != null) {
|
||||
if (allJoined()) {
|
||||
GameSessionPlayer gameSession = gameSessions.get(playerId);
|
||||
if (gameSession != null) {
|
||||
gameSession.quitGame();
|
||||
GameSessionPlayer gameSessionPlayer = gameSessions.get(playerId);
|
||||
if (gameSessionPlayer != null) {
|
||||
gameSessionPlayer.quitGame();
|
||||
}
|
||||
} else {
|
||||
// The player did never join the game but the game controller was started because the player was still connected as the
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ReplayManager {
|
|||
public void replayGame(UUID gameId, UUID userId) {
|
||||
ReplaySession replaySession = new ReplaySession(gameId, userId);
|
||||
replaySessions.put(gameId.toString() + userId.toString(), replaySession);
|
||||
UserManager.getInstance().getUser(userId).replayGame(gameId);
|
||||
UserManager.getInstance().getUser(userId).ccReplayGame(gameId);
|
||||
}
|
||||
|
||||
public void startReplay(UUID gameId, UUID userId) {
|
||||
|
|
|
@ -169,7 +169,7 @@ public class TournamentController {
|
|||
tournamentSessions.put(playerId, tournamentSession);
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
user.addTournament(playerId, tournamentSession);
|
||||
user.addTournament(playerId, tournament.getId());
|
||||
TournamentPlayer player = tournament.getPlayer(playerId);
|
||||
player.setJoined();
|
||||
logger.debug("player " +player.getPlayer().getName() + " - client has joined tournament " + tournament.getId());
|
||||
|
@ -180,6 +180,19 @@ public class TournamentController {
|
|||
}
|
||||
}
|
||||
|
||||
public void rejoin(UUID playerId) {
|
||||
TournamentSession tournamentSession = tournamentSessions.get(playerId);
|
||||
if (tournamentSession == null) {
|
||||
logger.fatal("Tournament session not found - playerId:" + playerId + " tournamentId " + tournament.getId());
|
||||
return;
|
||||
}
|
||||
if (!tournamentSession.init()) {
|
||||
logger.fatal("Unable to initialize client userId: " + tournamentSession.userId + " tournamentId " + tournament.getId());
|
||||
return;
|
||||
}
|
||||
tournamentSession.update();
|
||||
}
|
||||
|
||||
private void checkStart() {
|
||||
if (!started && allJoined()) {
|
||||
ThreadExecutor.getInstance().getCallExecutor().execute(
|
||||
|
@ -318,49 +331,55 @@ public class TournamentController {
|
|||
|
||||
public void quit(UUID userId) {
|
||||
UUID playerId = userPlayerMap.get(userId);
|
||||
if (playerId != null) {
|
||||
TournamentPlayer tPlayer = tournament.getPlayer(playerId);
|
||||
if (tPlayer != null) {
|
||||
if (started) {
|
||||
if (tPlayer.isInTournament()) {
|
||||
String info;
|
||||
if (tournament.isDoneConstructing()) {
|
||||
info = new StringBuilder("during round ").append(tournament.getRounds().size()).toString();
|
||||
// quit active matches of that tournament
|
||||
TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(), userId);
|
||||
} else {
|
||||
if (tPlayer.getState().equals(TournamentPlayerState.DRAFTING)) {
|
||||
info = "during Draft phase";
|
||||
if (!checkToReplaceDraftPlayerByAi(userId, tPlayer)) {
|
||||
this.abortDraftTournament();
|
||||
} else {
|
||||
DraftController draftController = DraftManager.getInstance().getController(tableId);
|
||||
if (draftController != null) {
|
||||
DraftSession draftSession = draftController.getDraftSession(playerId);
|
||||
if (draftSession != null) {
|
||||
DraftManager.getInstance().kill(draftSession.getDraftId(), userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (tPlayer.getState().equals(TournamentPlayerState.CONSTRUCTING)) {
|
||||
info = "during Construction phase";
|
||||
} else {
|
||||
info = "";
|
||||
if (playerId == null) {
|
||||
logger.debug("Player not found userId:" + userId + " tournId: " + tournament.getId());
|
||||
return;
|
||||
}
|
||||
TournamentPlayer tournamentPlayer = tournament.getPlayer(playerId);
|
||||
if (tournamentPlayer == null) {
|
||||
logger.debug("TournamentPlayer not found userId: " + userId + " tournId: " + tournament.getId());
|
||||
return;
|
||||
}
|
||||
if (!started) {
|
||||
tournament.leave(playerId);
|
||||
return;
|
||||
}
|
||||
TournamentSession tournamentSession = tournamentSessions.get(playerId);
|
||||
if (tournamentSession == null) {
|
||||
logger.debug("TournamentSession not found userId: " + userId + " tournId: " + tournament.getId());
|
||||
return;
|
||||
}
|
||||
tournamentSession.setKilled();
|
||||
if (tournamentPlayer.isInTournament()) {
|
||||
String info;
|
||||
if (tournament.isDoneConstructing()) {
|
||||
info = new StringBuilder("during round ").append(tournament.getRounds().size()).toString();
|
||||
// quit active matches of that tournament
|
||||
TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(), userId);
|
||||
} else {
|
||||
if (tournamentPlayer.getState().equals(TournamentPlayerState.DRAFTING)) {
|
||||
info = "during Draft phase";
|
||||
if (!checkToReplaceDraftPlayerByAi(userId, tournamentPlayer)) {
|
||||
this.abortDraftTournament();
|
||||
} else {
|
||||
DraftController draftController = DraftManager.getInstance().getController(tableId);
|
||||
if (draftController != null) {
|
||||
DraftSession draftSession = draftController.getDraftSession(playerId);
|
||||
if (draftSession != null) {
|
||||
DraftManager.getInstance().kill(draftSession.getDraftId(), userId);
|
||||
}
|
||||
}
|
||||
tPlayer.setQuit(info);
|
||||
tournament.quit(playerId);
|
||||
if (tournamentSessions.containsKey(playerId)) {
|
||||
tournamentSessions.get(tPlayer.getPlayer().getId()).quit();
|
||||
}
|
||||
ChatManager.getInstance().broadcast(chatId, "", tPlayer.getPlayer().getName() + " has quit the tournament", MessageColor.BLACK, true, MessageType.STATUS, SoundToPlay.PlayerQuitTournament);
|
||||
}
|
||||
} else if (tournamentPlayer.getState().equals(TournamentPlayerState.CONSTRUCTING)) {
|
||||
info = "during Construction phase";
|
||||
} else {
|
||||
tournament.leave(playerId);
|
||||
info = "";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.debug("UserId not found " + userId + " tournId: " + tournament.getId());
|
||||
tournamentPlayer.setQuit(info);
|
||||
tournament.quit(playerId);
|
||||
tournamentSession.quit();
|
||||
ChatManager.getInstance().broadcast(chatId, "", tournamentPlayer.getPlayer().getName() + " has quit the tournament", MessageColor.BLACK, true, MessageType.STATUS, SoundToPlay.PlayerQuitTournament);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,11 +71,6 @@ public class TournamentManager {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void kill(UUID tournamentId, UUID userId) {
|
||||
controllers.get(tournamentId).quit(userId);
|
||||
}
|
||||
|
||||
public void timeout(UUID tournamentId, UUID userId) {
|
||||
controllers.get(tournamentId).timeout(userId);
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public class TournamentSession {
|
|||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
int remaining = (int) futureTimeout.getDelay(TimeUnit.SECONDS);
|
||||
user.construct(tournament.getPlayer(playerId).getDeck(), tableId, remaining);
|
||||
user.ccConstruct(tournament.getPlayer(playerId).getDeck(), tableId, remaining);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,11 +115,6 @@ public class TournamentSession {
|
|||
tournament.updateDeck(playerId, deck);
|
||||
}
|
||||
|
||||
protected void handleRemoteException(RemoteException ex) {
|
||||
logger.fatal("TournamentSession error - userId " + userId + " tId " + tournament.getId(), ex);
|
||||
TournamentManager.getInstance().kill(tournament.getId(), userId);
|
||||
}
|
||||
|
||||
public void setKilled() {
|
||||
killed = true;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import java.util.UUID;
|
|||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -47,6 +48,8 @@ import mage.game.Game;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializable {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CardsImpl.class);
|
||||
|
||||
private static Random rnd = new Random();
|
||||
private UUID ownerId;
|
||||
|
@ -62,7 +65,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
this.zone = zone;
|
||||
}
|
||||
|
||||
public CardsImpl(Zone zone, List<Card> cards) {
|
||||
public CardsImpl(Zone zone, Collection<Card> cards) {
|
||||
this(zone);
|
||||
for (Card card: cards) {
|
||||
this.add(card.getId());
|
||||
|
@ -181,8 +184,14 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
@Override
|
||||
public Set<Card> getCards(Game game) {
|
||||
Set<Card> cards = new LinkedHashSet<>();
|
||||
for (UUID card: this) {
|
||||
cards.add(game.getCard(card));
|
||||
for (UUID cardId: this) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
} else {
|
||||
// this bug seems to happen, if cause is removed, this check can also be removed
|
||||
logger.error("Card not found cardId: " + cardId + " gameId: " + game.getId() );
|
||||
}
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ public interface Game extends MageItem, Serializable {
|
|||
int mulliganDownTo(UUID playerId);
|
||||
void mulligan(UUID playerId);
|
||||
void endMulligan(UUID playerId);
|
||||
void quit(UUID playerId);
|
||||
// void quit(UUID playerId);
|
||||
void timerTimeout(UUID playerId);
|
||||
void idleTimeout(UUID playerId);
|
||||
void concede(UUID playerId);
|
||||
|
|
|
@ -1036,15 +1036,15 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
player.drawCards(numCards - deduction, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quit(UUID playerId) {
|
||||
if (state != null) {
|
||||
Player player = state.getPlayer(playerId);
|
||||
if (player != null && player.isInGame()) {
|
||||
player.quit(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// public void quit(UUID playerId) {
|
||||
// if (state != null) {
|
||||
// Player player = state.getPlayer(playerId);
|
||||
// if (player != null && player.isInGame()) {
|
||||
// player.quit(this);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public synchronized void timerTimeout(UUID playerId) {
|
||||
|
|
Loading…
Reference in a new issue