Exemple #1
0
        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);
        }
Exemple #2
0
        public void CallLiar(string accessToken)
        {
            game associatedGame = FindGameByPlayer(accessToken);

            if (associatedGame == null)
            {
                return;
            }
            associatedGame.CallLiar(accessToken);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        public gameEngineReturnMessage ReRoll(string accessToken, string facesToReRoll)
        {
            boolResponse returnMsg      = new boolResponse();
            game         associatedGame = FindGameByPlayer(accessToken);

            if (associatedGame == null)
            {
                returnMsg.okay = false;
                return(returnMsg);
            }
            returnMsg.okay = associatedGame.ReRoll(accessToken, facesToReRoll);
            return(returnMsg);
        }
Exemple #5
0
        public gameEngineReturnMessage AcceptHand(string accessToken)
        {
            boolResponse returnMsg      = new boolResponse();
            game         associatedGame = FindGameByPlayer(accessToken);

            if (associatedGame == null)
            {
                returnMsg.okay = false;
                return(returnMsg);
            }

            bool acceptedOk = associatedGame.AcceptHand(accessToken);

            returnMsg.okay = acceptedOk;
            return(returnMsg);
        }
Exemple #6
0
        public gameEngineReturnMessage JoinGame(string gameName, string playerName)
        {
            game g = FindGameByName(gameName);

            if (g == null || !g.isOpenToNewPlayers())
            {
                return(new playerRegistration(false, ""));
            }

            player p = new player(playerName, g.GetInitialLivesCount());

            g.Join(p);

            playerRegistration returnMsg = new playerRegistration(true, p.GetId());

            return(returnMsg);
        }
Exemple #7
0
        public gameEngineReturnMessage DeclareHand(string accessToken, pokerDiceHand hand)
        {
            game         associatedGame = FindGameByPlayer(accessToken);
            boolResponse returnMsg      = new boolResponse();

            if (associatedGame == null)
            {
                returnMsg.okay = false;
                return(returnMsg);
            }

            bool declareAccepted = associatedGame.DeclareHand(accessToken, hand);

            if (declareAccepted)
            {
                returnMsg.okay = true;
            }
            else
            {
                returnMsg.okay = false;
            }

            return(returnMsg);
        }