/// <summary>
        /// Takes the word submitted by the client and scores it for the client, returning it to them.
        /// </summary>
        /// <param name="words">class that containes the userToken and word that the client is submitting</param>
        /// <param name="GameID">ID of the game that the word is being submitted for</param>
        /// <returns></returns>
        public TokenScoreGameIDReturn playWord(UserGame words, string GameID)
        {
            lock (sync)
            {
                if (words.UserToken == null || words.UserToken.Trim().Length == 0 || !AllPlayers.ContainsKey(words.UserToken))
                {
                    SetStatus(Forbidden);
                    return(null);
                }

                if (words.Word == null || words.Word.Trim().Length == 0 || !AllGames.ContainsKey(GameID))
                {
                    SetStatus(Forbidden);
                    return(null);
                }

                if (AllGames[GameID].GameState != "active")
                {
                    SetStatus(Conflict);
                    return(null);
                }


                if (AllPlayers[words.UserToken].personalList == null)
                {
                    AllPlayers[words.UserToken].personalList = new List <WordScore>();
                }

                int userScore;
                int.TryParse(AllPlayers[words.UserToken].Score, out userScore);
                int       WordScoreResult = ScoreWord(words.Word, words.UserToken, GameID);
                WordScore totalResult     = new WordScore();
                totalResult.Word  = words.Word;
                totalResult.Score = WordScoreResult;
                AllPlayers[words.UserToken].personalList.Add(totalResult);
                AllPlayers[words.UserToken].Score = (userScore + WordScoreResult).ToString();
                TokenScoreGameIDReturn var = new TokenScoreGameIDReturn();
                var.Score = WordScoreResult.ToString();
                SetStatus(OK);
                return(var);
            }
        }
 /// <summary>
 /// If the requesting player is in a pending game, removes them from the pending game.
 /// </summary>
 /// <param name="endUser"></param>
 public void CancelGame(UserGame endUser)
 {
     lock (sync)
     {
         string cancelGameID = null;
         foreach (KeyValuePair <string, GameStatus> games in AllGames)
         {
             if (games.Value.GameState == "pending" && games.Value.Player1.UserToken == endUser.UserToken)
             {
                 cancelGameID = games.Key;
             }
         }
         if (cancelGameID != null)
         {
             SetStatus(OK);
             AllGames[cancelGameID].Player1 = null;
         }
         else
         {
             SetStatus(Forbidden);
         }
     }
 }