public gameEngineReturnMessage Poll(string accessToken) { pollResponse returnMessage = new pollResponse(); game associatedGame = FindGameByPlayer(accessToken); if (associatedGame == null) { return(null); } returnMessage.gameName = associatedGame.GetId(); returnMessage.status = associatedGame.GetStatus(); List <string> names = associatedGame.GetPlayersNames(); foreach (var n in names) { int? rerollCount = associatedGame.GetPlayerByName(n).GetRerollCount(); pokerDiceHand handClaim = associatedGame.GetPlayerByName(n).GetHandClaim(); bool handClaimMade = handClaim != null; int livesLeft = associatedGame.GetPlayerByName(n).GetLivesRemaining(); returnMessage.playerStatusLines.Add(new playerStatusLine(n, livesLeft, handClaimMade, handClaim, rerollCount)); } returnMessage.awaitingActionFromPlayerName = associatedGame.GetPlayerNameWithActionAwaited(); //Decide whether or not to reveal actual hand to the calling player if (associatedGame.GetPlayerById(accessToken).GetName() == associatedGame.GetPlayerNameCurrentlyHoldingTheHand()) { returnMessage.SetHandToView(associatedGame.GetActualHand()); } return(returnMessage); }
public gameEngineReturnMessage CreateNewGame(string adminsName, int initialLives) { player administrator = new player(adminsName, initialLives); game newGame = new game(administrator, mRoller, initialLives); gamesList.Add(newGame); newGameDetails returnMsg = new newGameDetails(administrator.GetId(), newGame.GetId()); return(returnMsg); }