Fixed that to allow watchers of a game to see the hand cards of players did not work correctly.

This commit is contained in:
LevelX2 2015-04-10 12:36:22 +02:00
parent c0db6dfdc8
commit c65adebc57
14 changed files with 129 additions and 68 deletions

View file

@ -300,6 +300,7 @@ public class TableController {
logger.trace(player.getName() + " joined tableId: " + table.getId());
//only inform human players and add them to sessionPlayerMap
if (seat.getPlayer().isHuman()) {
seat.getPlayer().setUserData(user.getUserData());
if (!table.isTournamentSubTable()) {
user.addTable(player.getId(), table);
}
@ -552,14 +553,11 @@ public class TableController {
GameManager.getInstance().createGameSession(match.getGame(), userPlayerMap, table.getId(), choosingPlayerId);
String creator = null;
StringBuilder opponent = new StringBuilder();
// int activePlayers = 0;
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) { // no AI players
if (!match.getPlayer(entry.getValue()).hasQuit()) {
User user = UserManager.getInstance().getUser(entry.getKey());
if (user != null) {
// activePlayers++;
Player player = match.getPlayer(entry.getValue()).getPlayer();
player.setRequestToShowHandCardsAllowed(user.getUserData().allowRequestShowHandCards());
user.ccGameStarted(match.getGame().getId(), entry.getValue());
if (creator == null) {
@ -582,16 +580,12 @@ public class TableController {
// Append AI opponents to the log file
for (MatchPlayer mPlayer :match.getPlayers()) {
if (!mPlayer.getPlayer().isHuman()) {
// activePlayers++;
if (opponent.length() > 0) {
opponent.append(" - ");
}
opponent.append(mPlayer.getName());
}
}
// if (activePlayers < 2) {
// throw new MageException("Can't start game - Less than two players active - " +activePlayers);
// }
ServerMessagesUtil.getInstance().incGamesStarted();

View file

@ -331,7 +331,6 @@ public class GameController implements GameCallback {
if (gameSession == null) {
gameSession = new GameSessionPlayer(game, userId, playerId);
gameSessions.put(playerId, gameSession);
gameSession.setUserData(user.getUserData());
joinType = "joined";
} else {
joinType = "rejoined";

View file

@ -48,9 +48,9 @@ public class GameFactory {
private static final GameFactory INSTANCE = new GameFactory();
private static final Logger logger = Logger.getLogger(GameFactory.class);
private Map<String, Class<Match>> games = new HashMap<String, Class<Match>>();
private Map<String, MatchType> gameTypes = new HashMap<String, MatchType>();
private List<GameTypeView> gameTypeViews = new ArrayList<GameTypeView>();
private final Map<String, Class<Match>> games = new HashMap<>();
private final Map<String, MatchType> gameTypes = new HashMap<>();
private final List<GameTypeView> gameTypeViews = new ArrayList<>();
public static GameFactory getInstance() {

View file

@ -135,19 +135,6 @@ public class GameManager {
}
}
// public void removeSession(UUID userId) {
// for (GameController controller: gameControllers.values()) {
// controller.kill(userId);
// }
// }
// public void kill(UUID gameId, UUID userId) {
// GameController gameController = gameControllers.get(gameId);
// if (gameController != null) {
// gameController.kill(userId);
// }
// }
public void cheat(UUID gameId, UUID userId, UUID playerId, DeckCardLists deckList) {
GameController gameController = gameControllers.get(gameId);
if (gameController != null) {

View file

@ -70,8 +70,6 @@ public class GameSessionPlayer extends GameSessionWatcher {
private static final ExecutorService callExecutor = ThreadExecutor.getInstance().getCallExecutor();
private UserData userData;
public GameSessionPlayer(Game game, UUID userId, UUID playerId) {
super(userId, game, true);
this.playerId = playerId;
@ -214,7 +212,6 @@ public class GameSessionPlayer extends GameSessionWatcher {
@Override
public GameView getGameView() {
Player player = game.getPlayer(playerId);
player.setUserData(this.userData);
GameView gameView = new GameView(game.getState(), game, playerId, null);
gameView.setHand(new CardsView(player.getHand().getCards(game)));
if (gameView.getPriorityPlayerName().equals(player.getName())) {
@ -298,7 +295,4 @@ public class GameSessionPlayer extends GameSessionWatcher {
}
}
public void setUserData(UserData userData) {
this.userData = userData;
}
}