Exemple #1
0
        public void Initialize(Highscore currentHighscore)
        {
            CurrentHighscore = _scoreCalculator.CalculateScore(currentHighscore.QuestionResult);

            var allHighscores           = _repository.GetAllHighscores(currentHighscore.DictionaryId);
            var highscoresForDictionary = GetOrderedHighscoresForDictionary(allHighscores, currentHighscore.DictionaryId);

            Highscores   = GetBestAllTimeHighscores(highscoresForDictionary);
            PersonalBest = GetPersonalBest(highscoresForDictionary, currentHighscore.Username);
        }
Exemple #2
0
        public void ShouldReturnCorrectScore(double seconds, int numberOfCorrectAnswers, int numberOfIncorrectAnswers, int expectedScore)
        {
            var questionResult = new QuestionResult();

            for (var i = 0; i < numberOfCorrectAnswers; i++)
            {
                questionResult.AddAnswer(new Answer(true,
                                                    DateTime.Now,
                                                    TimeSpan.FromSeconds(seconds /
                                                                         (numberOfCorrectAnswers +
                                                                          numberOfIncorrectAnswers)), null));
            }

            for (var i = 0; i < numberOfIncorrectAnswers; i++)
            {
                questionResult.AddAnswer(new Answer(false,
                                                    DateTime.Now,
                                                    TimeSpan.FromSeconds(seconds /
                                                                         (numberOfCorrectAnswers +
                                                                          numberOfIncorrectAnswers)), null));
            }

            var score = _objectUnderTest.CalculateScore(questionResult);

            Assert.AreEqual(expectedScore, score);
        }
Exemple #3
0
    public void RecordEvent(string paramEventName, int paramPosition)
    {
        PlayerEventInfo ev = _events.Where(ee => ee.EventName == paramEventName).SingleOrDefault();

        ev.Position = paramPosition;
        ev.Score    = _calculator.CalculateScore(ev);

        _total = _calculator.CalculateTotal(this);
    }
        //スコアの更新
        //スコアの増加量はIScoreCalculatorが決定する 後からコンボやらボーナスやら入れられるように
        void UpdateScore(int deleteCount)
        {
            if (deleteCount <= 0)
            {
                return;
            }
            var addScore = m_ScoreCalculator.CalculateScore(deleteCount);

            m_Score.Value += addScore;
        }
        public void BestScore_3x3_JustDoubles_Score0()
        {
            var pieces = new string[]
            {
                "dd-",
                "--d",
                "---"
            };

            BuildGrid(pieces);

            Assert.AreEqual(0, scoreCalculator.CalculateScore(BestMoverChecker.GetBestMove().Move.ToArray()));
        }
Exemple #6
0
        public Bubble Attached(Bubble bubble)
        {
            var toJoin = collector.ScoreNeighbours(bubble);

            if (toJoin.Count <= 1)
            {
                CheckRowCount();
                return(null); //nothing to join
            }

            IBubbleScore score    = calculator.CalculateScore(bubble.Score, toJoin.Count);
            Tile         bestTile = collector.SelectBestTile(toJoin, score);

            //detach old bubbles
            foreach (var bb in toJoin)
            {
                bb.Movement.MoveTowards(bestTile.transform.position);
                bb.StartCoroutine(DelayReturn(bb, DelayReturnTime));
            }

            //create new bubble
            var newBubble = spawner.Create(score);

            #if UNITY_EDITOR
            UnityEditor.EditorGUIUtility.PingObject(newBubble.gameObject);
            #endif

            grid.Insert(newBubble, bestTile);

            foreach (var toDrop in FindLooseBubbles(toJoin))
            {
                toDrop.Movement.Drop();
                toDrop.StartCoroutine(DelayReturn(toDrop, DelayReturnTime));
            }

            Debug.Log($"Collected {score.PointsString} points");

            if (newBubble.Score.Exponent > scoreRange.ExplosionExponent)
            {
                exploder.Explode(newBubble);
                CheckRowCount();
                return(null);
            }
            else
            {
                //continue chain
                return(newBubble);
            }
        }
Exemple #7
0
        public async Task <ActionResult <ScoreDto> > Scores(PinsDownedInfo pinsDowned)
        {
            if (pinsDowned == null || pinsDowned.PinsDowned == null)
            {
                throw new BowlingScoreApiExceptions($"Invalid input, pinsDowned cannot be null.");
            }
            var score = await Task.Run(() => _scoreCalculator.CalculateScore(pinsDowned.PinsDowned));

            var result = new ScoreDto
            {
                GameCompleted      = score.IsGameCompleted,
                FrameProgresScores = score.FrameProgresScores.Select(x => x == -1 ? "*" : x.ToString())
            };

            return(Ok(result));
        }
Exemple #8
0
        private void AnswerCurrentEntry()
        {
            if (CurrentEntry == null)
            {
                return;
            }

            if (IsInAnswerMode)
            {
                LastAnswerWasCorrect = RemoveWhitespaces(Answer) == RemoveWhitespaces(CurrentEntry.Pinyin);

                if (LastAnswerWasCorrect)
                {
                    NumberOfCorrectAnswers++;
                }
                else
                {
                    _dictionaryEntryPicker.QueueEntry(CurrentEntry);
                    NumberOfIncorrectAnswers++;
                }
            }
            else
            {
                GetNextEntry();
                if (CurrentEntry == null)
                {
                    var duration = _dateTime.Now - _startTime;
                    var score    = _scoreCalculator.CalculateScore(duration, NumberOfIncorrectAnswers);
                    RaiseQuestionsFinished(
                        new QuestionResult(
                            NumberOfCorrectAnswers,
                            NumberOfIncorrectAnswers,
                            duration,
                            score));
                    return;
                }

                Answer = string.Empty;
            }

            IsInAnswerMode = !IsInAnswerMode;
        }
        public void ShouldReturnCorrectScore(double seconds, int numberOfIncorrectAnswers, int expectedScore)
        {
            var score = _objectUnderTest.CalculateScore(TimeSpan.FromSeconds(seconds), numberOfIncorrectAnswers);

            Assert.AreEqual(expectedScore, score);
        }
Exemple #10
0
    public void SequenceCompleted(ISquarePiece[] pieces)
    {
        int scoreEarned = ScoreCalculator.CalculateScore(pieces);

        GainPoints(scoreEarned, pieces);
    }
Exemple #11
0
 public async Task CalculateScore(IScoreCalculator scoreCalculator)
 {
     this.Score = await scoreCalculator.CalculateScore(this);
 }