public async Task <bool> CheckGuess(Player player, string guess) { if (State != LobbyState.Drawing) { return(true); } if (guess.Equals(Selection, StringComparison.OrdinalIgnoreCase)) { player.HasGuessedCorrectly = true; _scoreCalculator.AddPlayer(player.Name); await _lobbyHub.Clients.Group(Id).SendAsync("GuessedCorrectly", new Message(player.Name + " guessed correctly.", Message.MessageType.Guessed, player.Name)); await CheckForCompletedGuessing(); return(true); } //TODO: rework with interface if (_wordDistanceCalculator.Calculate(guess, Selection) <= 2) { await _lobbyHub.Clients.Client(player.Connection).SendAsync("ReceiveMessage", new Message(guess + " is a close one!", Message.MessageType.CloseGuess)); } return(false); }
private void BuildGraphReferencesJustForSmallestPossibleWordDistance( string currentWord, string otherWord, GraphNode currentWordNode) { const int smallestDistanceBetweenWords = 1; var distance = _wordDistanceCalculator.Calculate(currentWord, otherWord); if (distance == smallestDistanceBetweenWords) { var otherWordGraphNode = GetOrCreateGraphNode(otherWord); currentWordNode.ReferencedNodes.Add(otherWordGraphNode); } }