Exemplo n.º 1
0
        public int Score(Guid playerId, Guid boardId, string word)
        {
            int points;

            word = word.ToLower();
            BoggleTracker tracker = FindTracker(playerId, boardId);

            if (tracker.WordPointDict.TryGetValue(word, out points))
            {
                return(0);
            }

            if (IsWordInDictionary(word))
            {
                if (tracker.Board.FindWord(word) != null)
                {
                    points = Rules.Score(word.Length);
                }
                else
                {
                    points = BoggleRules.IncorrectWordScore;
                }
            }
            else
            {
                points = BoggleRules.IncorrectWordScore;
            }

            tracker.Update(word, points);

            return(points);
        }
Exemplo n.º 2
0
        public BoggleResult Play(IBogglePlayer player, int randomSeed = 0, int boardSize = BoggleRules.BoardSizeDefault)
        {
            BoggleBoard   board   = Rules.GenerateBoard(randomSeed, boardSize);
            BoggleTracker tracker = CreateTracker(player, board);

            tracker.Start();

            try
            {
                player.Solve(board);
                tracker.Stop();
            }
            catch (Exception)
            {
                tracker.Stop();
                tracker.Update(string.Empty, BoggleRules.CatastrophicScore);
                throw;
            }

            BoggleResult result = CreateResult(tracker);

            DeleteTracker(player.Id, board.Id);
            return(result);
        }