public bool GuessWord(string playerName, Word gameWords) { bool victorious = false; if (!IsGameBeingHosted()) { throw new FaultException<GameIsNotBeingHostedFault>(new GameIsNotBeingHostedFault()); } if (gameWords.ScrambledWord != _gameWords.ScrambledWord) { throw new FaultException<WordMismatchFault>(new WordMismatchFault { ClientScrambled = gameWords.ScrambledWord, ServerScrambled = _gameWords.ScrambledWord }); } if (!_activePlayers.Contains(playerName)) { throw new FaultException<PlayerNotPlayingTheGameFault>(new PlayerNotPlayingTheGameFault()); } if (gameWords.UnscrambledWord == _gameWords.UnscrambledWord) { victorious = true; _activePlayers.Remove(playerName); // This player got it so they are removed from the game. } return victorious; }
public string HostGame(string playerName, string wordToScramble) { if (IsGameBeingHosted()) { throw new FaultException<GameBeingHostedFault>( new GameBeingHostedFault { HostPlayer = _userHostingTheGame }); } _userHostingTheGame = playerName; _gameWords = new Word { UnscrambledWord = wordToScramble.Trim(), ScrambledWord = ScrambleWord(wordToScramble) }; return _gameWords.ScrambledWord; }