private PlayerGameInfo ParseGameInfo(int gameID) { ChessGame game = new ChessGame(gameID); PlayerGameInfo gameInfo = new PlayerGameInfo(); gameInfo.gameID = game.ID; Player opponent; bool curPlayerWhite = false; opponent = game.GetWhitePlayer(); if (opponent.ID == this.ID) { opponent = game.GetBlackPlayer(); curPlayerWhite = true; } gameInfo.opponent = new PlayerInfo(opponent); gameInfo.gameState = game.GetGameState(); gameInfo.currentTimeLeft = (curPlayerWhite) ? game.GetWhiteActualTimeLeft() : game.GetBlackActualTimeLeft(); return(gameInfo); }
private ChessGame CreateGame(int oppID) { Random random = new Random(); int whitePlayerID, blackPlayerID; string opponentInfoKey = playerInfoPrefix + oppID.ToString(); if (random.Next() % 2 == 0) { whitePlayerID = player.ID; blackPlayerID = oppID; } else { whitePlayerID = oppID; blackPlayerID = player.ID; } ChessGame chessGame = new ChessGame(); chessGame.CreateGame(whitePlayerID, blackPlayerID, GameTimeInSeconds); //Set Game ID for opponent redis.SetEntryInHash(opponentInfoKey, gameFoundIDKey, chessGame.ID.ToString()); return(chessGame); }
public ChessGameValidationResult(ChessGameValidationStatus status, ChessGame game = null) { this.status = status; this.newSearchScope = ChessGameManager.StartingRankScope; this.game = game; }