public QuickInputSemesterScoreForm(JHStudentRecord student)
            : this()
        {
            _student = student;
            JHScoreCalcRuleRecord record = student.ScoreCalcRule;

            _calculator = new ScoreCalculator(record);
            _util       = new SemesterHistoryUtility(JHSemesterHistory.SelectByStudentID(student.ID));
            _semesterScoreRecordList = JHSemesterScore.SelectByStudentID(_student.ID);

            errorProvider.SetError(cboSchoolYear, "無效的學年度");
            errorProvider.SetError(cboSemester, "無效的學期");
        }
示例#2
0
        public void CalculateScore_If_AllFramesAreZero()
        {
            var frames = new List <Frame>();

            for (int i = 0; i < 10; i++)
            {
                frames.Add(new Frame());
            }

            var result = ScoreCalculator.CalculateScore(frames);

            Assert.AreEqual(0, result);
        }
        public void ThrowHasASextet()
        {
            // arrange
            var scoreCalculator = new ScoreCalculator();

            // act
            var rollValues = new List <int>  {
                2, 2, 2, 2, 2, 2
            };

            // assert
            Assert.IsTrue(scoreCalculator.RollHasSextet(rollValues));
        }
        public void ThrowHasATriple()
        {
            // arrange
            var scoreCalculator = new ScoreCalculator();

            // act
            var rollValues = new List <int>  {
                2, 2, 2, 4, 3, 6
            };

            // assert
            Assert.IsTrue(scoreCalculator.RollHasTriple(rollValues));
        }
        public void ThrowDoesntHaveOneOrFive()
        {
            // arrange
            var scoreCalculator = new ScoreCalculator();

            // act
            var rollValues = new List <int>  {
                3, 2, 2, 4, 3, 6
            };

            // assert
            Assert.IsFalse(scoreCalculator.RollHasOneOrFive(rollValues));
        }
示例#6
0
        public void Calculate_NullOrEmptyTest()
        {
            IEnumerable <int> nullInput = null;

            Assert.That.It(() => ScoreCalculator.Calculate(nullInput)).Throws <ArgumentNullException>();

            var emptyInput  = new int[0];
            var emptyResult = ScoreCalculator.Calculate(emptyInput);

            Assert.That.They(emptyResult.Frames).Are.Empty();
            Assert.That.It(emptyResult.IsScoreConfirmed).Is.False();
            Assert.That.It(() => emptyResult.Score).Throws <InvalidOperationException>();
            Assert.That.It(emptyResult.IsGameEnded).Is.False();
        }
示例#7
0
        public async Task <IActionResult> Create(Performance performance)
        {
            if (ModelState.IsValid)
            {
                ScoreCalculator.CalculateTotal(performance, _context);
                _context.Add(performance);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { matchID = performance.MatchID }));
            }
            ViewData["MatchID"]  = new SelectList(_context.Matches, "ID", "ID", performance.MatchID);
            ViewData["PlayerID"] = new SelectList(_context.Players, "ID", "ID", performance.PlayerID);
            return(View(performance));
        }
示例#8
0
    private void displayScore()
    {
        var score = ScoreCalculator.ScoreCalc(_goalPuyo, _mergedPuyo);

        if (score < 50)
        {
            _gameSoundManager.callLooseSound();
        }
        else
        {
            _gameSoundManager.callWinSound();
        }
        displayMessage(score + "%");
    }
        public void Calculate_ReturnsFive_WhenFramesContainFive()
        {
            var calculator = new ScoreCalculator();
            var scoreArray = new List <ScoreInfo>();
            var scoreInfo  = new ScoreInfo();

            scoreInfo.Scores.Add(2);
            scoreInfo.Scores.Add(3);
            scoreArray.Add(scoreInfo);

            var score = calculator.Calculate(scoreArray);

            Assert.Equal(5, score);
        }
示例#10
0
    public int GetScoreFromSimulation()
    {
        if (!AdjustGroupPosition())
        {
            return(-1);
        }

        foreach (ISimulatedBlock block in SimulatedGroup.Children)
        {
            if (SimulatedGrid[block.Location.X, block.Location.Y] != null)
            {
                return(-2);
            }

            block.FixedOnGrid = true;
            SimulatedGrid[block.Location.X, block.Location.Y] = block;
        }


        bool simulationDone = false;
        int  totalScore     = 0;
        int  chains         = 1;

        while (!simulationDone)
        {
            DropBlocks();

            var deletedBlocks = DeleteBlocks();

            if (deletedBlocks.Count != 0)
            {
                totalScore += ScoreCalculator.Calculate(deletedBlocks, chains++);
            }
            else
            {
                simulationDone = true;
            }
        }

        CopyOriginalToSimulatedGrid();

        foreach (ISimulatedBlock block in SimulatedGroup.Children)
        {
            block.FixedOnGrid = false;
        }
        SimulatedGroup.SetLocation(SimulatedGroup.Location);

        return(totalScore);
    }
示例#11
0
        public void Calculate_StrikeTest()
        {
            var strike       = new int[] { Rule.MaxPinCount };
            var strikeResult = ScoreCalculator.Calculate(strike);

            Assert.That.It(strikeResult.Frames.Count).Is.EqualTo(1);
            Assert.That.It(strikeResult.Frames[0].Rolls.Count).Is.EqualTo(1);
            Assert.That.It(strikeResult.Frames[0].Rolls[0].PinScore).Is.EqualTo(10);
            Assert.That.It(strikeResult.Frames[0].IsLastFrame).Is.False();
            Assert.That.It(strikeResult.Frames[0].IsScoreConfirmed).Is.False();
            Assert.That.It(() => strikeResult.Frames[0].Score).Throws <InvalidOperationException>();
            Assert.That.It(strikeResult.IsScoreConfirmed).Is.False();
            Assert.That.It(() => strikeResult.Score).Throws <InvalidOperationException>();
            Assert.That.It(strikeResult.IsGameEnded).Is.False();
        }
    public void CheckPress()
    {
        ProblemHandler.Vec4i score;
        ProblemHandler.checkSolution(grid, out score);
        int stars = ScoreCalculator.StarRater(score);

        if (stars > 0)
        {
            SolutionCheckPass(stars);
        }
        else
        {
            SolutionCheckFail();
        }
    }
        public BoardViewModel()
        {
            this.Players          = this.InitializePlayers();
            this.CurrentPlayer    = this.Players[0];
            this.scoreCalculator  = new ScoreCalculator();
            this.gameOverDetector = new GameOverDetector();
            this.dialogService    = new DialogService();

            BoardBuilder boardBuilder = new BoardBuilder();

            this.board          = boardBuilder.CreateBoard(this.Players);
            this.movementFinder = new MovementFinder(this.board);

            this.FieldSize = 50;
        }
示例#14
0
        public void Calculate_OpenTest()
        {
            var open       = new int[] { 5, 4 };
            var openResult = ScoreCalculator.Calculate(open);

            Assert.That.It(openResult.Frames.Count).Is.EqualTo(1);
            Assert.That.It(openResult.Frames[0].Rolls.Count).Is.EqualTo(2);
            Assert.That.It(openResult.Frames[0].Rolls[0].PinScore).Is.EqualTo(5);
            Assert.That.It(openResult.Frames[0].Rolls[1].PinScore).Is.EqualTo(4);
            Assert.That.It(openResult.Frames[0].IsLastFrame).Is.False();
            Assert.That.It(openResult.Frames[0].IsScoreConfirmed).Is.True();
            Assert.That.It(openResult.Frames[0].Score).Is.EqualTo(9);
            Assert.That.It(openResult.IsScoreConfirmed).Is.True();
            Assert.That.It(openResult.Score).Is.EqualTo(9);
            Assert.That.It(openResult.IsGameEnded).Is.False();
        }
示例#15
0
        public void Calculate_InProgressTest()
        {
            var inProgress       = new int[] { 5 };
            var inProgressResult = ScoreCalculator.Calculate(inProgress);

            Assert.That.It(inProgressResult.Frames.Count).Is.EqualTo(1);
            Assert.That.It(inProgressResult.Frames[0].Rolls.Count).Is.EqualTo(1);
            Assert.That.It(inProgressResult.Frames[0].Rolls[0].PinScore).Is.EqualTo(5);
            Assert.That.It(inProgressResult.Frames[0].Rolls[0].Next).Is.Null();
            Assert.That.It(inProgressResult.Frames[0].IsLastFrame).Is.False();
            Assert.That.It(inProgressResult.Frames[0].IsScoreConfirmed).Is.False();
            Assert.That.It(() => inProgressResult.Frames[0].Score).Throws <InvalidOperationException>();
            Assert.That.It(inProgressResult.IsScoreConfirmed).Is.False();
            Assert.That.It(() => inProgressResult.Score).Throws <InvalidOperationException>();
            Assert.That.It(inProgressResult.IsGameEnded).Is.False();
        }
示例#16
0
        public void CalculateScore_If_AllFramesAreOne()
        {
            var frames = new List <Frame>();

            for (int i = 0; i < 10; i++)
            {
                frames.Add(new Frame()
                {
                    First = 1, Second = 1
                });
            }

            var result = ScoreCalculator.CalculateScore(frames);

            Assert.AreEqual(20, result);
        }
    //
    public void GameOver(GameEndingType endType)
    {
        if (gameStatus == GameStatus.Ended)
        {
            return;
        }
        gameStatus = GameStatus.Ended;
        var score = ScoreCalculator.GetScore(this);

        uicontroller?.GameOver(endType, score);
        if (gameID != -1)
        {
            Highscore.AddHighscore(new Highscore(gameID, colonyController.cityName, score, endType));
        }
        SetPause(true);
    }
        public async Task CalculateScoreWith1And2And3ExtraPointsAsync()
        {
            //-- Arrange
            var          calculator = new ScoreCalculator(_wordLookup);
            const string WORD       = "Bakes";

            //-- Act
            Score score = await calculator.CalculateScoreAsync(WORD);

            var actual = (int)score?.WordScore;

            //-- Assert
            var expected = 15; // 5 + (3 + 0 + 5 + 0 + 1) + 1

            Assert.AreEqual(expected, actual);
        }
示例#19
0
        public void Calculate_SpareTest()
        {
            var spare       = new int[] { 5, 5 };
            var spareResult = ScoreCalculator.Calculate(spare);

            Assert.That.It(spareResult.Frames.Count).Is.EqualTo(1);
            Assert.That.It(spareResult.Frames[0].Rolls.Count).Is.EqualTo(2);
            Assert.That.It(spareResult.Frames[0].Rolls[0].PinScore).Is.EqualTo(5);
            Assert.That.It(spareResult.Frames[0].Rolls[1].PinScore).Is.EqualTo(5);
            Assert.That.It(spareResult.Frames[0].IsLastFrame).Is.False();
            Assert.That.It(spareResult.Frames[0].IsScoreConfirmed).Is.False();
            Assert.That.It(() => spareResult.Frames[0].Score).Throws <InvalidOperationException>();
            Assert.That.It(spareResult.IsScoreConfirmed).Is.False();
            Assert.That.It(() => spareResult.Score).Throws <InvalidOperationException>();
            Assert.That.It(spareResult.IsGameEnded).Is.False();
        }
        private async Task <ScoreCalculator> GetScoreCalculator(long betGroupId)
        {
            var matchRules = await _dbContext
                             .BetGroupMatchPredictionRules
                             .Where(q => q.BetGroupId == betGroupId)
                             .ToArrayAsync();

            var bonusRules = await _dbContext
                             .BetGroupBonusPredictionRules
                             .Where(q => q.BetGroupId == betGroupId)
                             .ToArrayAsync();

            var scoreCalculator = new ScoreCalculator(matchRules, bonusRules);

            return(scoreCalculator);
        }
        public async Task CalculateScoreWith1DoublePairAsync()
        {
            //-- Arrange
            var          calculator = new ScoreCalculator(_wordLookup);
            const string WORD       = "TOO";

            //-- Act
            Score score = await calculator.CalculateScoreAsync(WORD);

            var actual = (int)score?.WordScore;

            //-- Assert
            var expected = 5; // 3 + (0 + 0 + 0) + 1 + 1

            Assert.AreEqual(expected, actual);
        }
示例#22
0
        public async Task CalculateScoreForNonDictionaryWordAsync()
        {
            //-- Arrange
            var          calculator = new ScoreCalculator(_wordLookup);
            const string WORD       = "afdghophasg";

            //-- Act
            Score score = await calculator.CalculateScoreAsync(WORD);

            var actual = (int)score?.WordScore;

            //-- Assert
            var expected = 0;

            Assert.AreEqual(expected, actual);
        }
        public async Task CalculateScoreWith3ExtraPointsAsync()
        {
            //-- Arrange
            var          calculator = new ScoreCalculator(_wordLookup);
            const string WORD       = "jot";

            //-- Act
            Score score = await calculator.CalculateScoreAsync(WORD);

            var actual = (int)score?.WordScore;

            //-- Assert
            var expected = 9; // 3 + (5 + 0 + 0) + 1

            Assert.AreEqual(expected, actual);
        }
        public async Task CalculateScoreWith2DoublePairsAsync()
        {
            //-- Arrange
            var          calculator = new ScoreCalculator(_wordLookup);
            const string WORD       = "teepee";

            //-- Act
            Score score = await calculator.CalculateScoreAsync(WORD);

            var actual = (int)score?.WordScore;

            //-- Assert
            var expected = 13; // 6 + (0 + 0 + 0 + 3 + 0 + 0) + 2 + 2

            Assert.AreEqual(expected, actual);
        }
示例#25
0
        public async Task CalculateScoreForProperNounAsync()
        {
            //-- Arrange
            var          calculator = new ScoreCalculator(_wordLookup);
            const string WORD       = "Amanda";

            //-- Act
            Score score = await calculator.CalculateScoreAsync(WORD);

            int?actual = score?.WordScore;

            //-- Assert
            var expected = 0;

            Assert.AreEqual(expected, actual);
        }
示例#26
0
        public void CalculateScore_if_FirstFrameSpare_OthersAreZero()
        {
            var frames = new List <Frame>();

            frames.Add(new Frame()
            {
                First = 5, Second = 5
            });
            for (int i = 0; i < 9; i++)
            {
                frames.Add(new Frame());
            }

            var result = ScoreCalculator.CalculateScore(frames);

            Assert.AreEqual(10, result);
        }
示例#27
0
    public void newPolygonCreated(GameObject polygon, List <Node> borderNodes)
    {
        if (currentPlayer.mat == null)
        {
            currentPlayer.mat       = new Material(Shader.Find("Unlit/Color"));
            currentPlayer.mat.color = currentPlayer.color;
        }
        polygon.GetComponent <MeshRenderer>().material = currentPlayer.mat;
        var score = ScoreCalculator.getScore(polygon, borderNodes);

        currentPlayer.score += score;
        var da = polygon.AddComponent <DisplayArea>();

        da.Area = score;
        HUD.Instance.UpdateScore(players.IndexOf(currentPlayer), currentPlayer.score);
        checkGameEndedState(score);
    }
示例#28
0
        public void GameShouldScoreIfResponseIsScoreInCategory(string input, int expected)
        {
            var mockInput = new Mock <IConsoleReader>();

            mockInput.Setup(consoleReader => consoleReader.GetInput()).Returns(input);
            var player = new Player(mockInput.Object);
            var score  = ScoreCalculator.CalculateScore(new List <int>
            {
                1,
                2,
                2,
                2,
                4
            }, player.Respond().Input.ToLower());

            Assert.Equal(expected, score);
        }
示例#29
0
    int TrySwap(ScoreCalculator calculator, int lastScore, double temperature, double time)
    {
        const int    MaxSwapSquare = 15;
        const int    MinSwapSquare = 3;
        const double expRatio      = 10;
        int          swapSquare    = Math.Min(_mazeSize, (int)((MaxSwapSquare - MinSwapSquare) * Math.Exp(-time * expRatio)) + MinSwapSquare);
        var          offset        = new Diff(_xorShift.Next(_mazeSize - swapSquare + 1), _xorShift.Next(_mazeSize - swapSquare + 1));
        var          swapCount     = _xorShift.Next(5);

        swapCount = swapCount < 2 ? 2 : swapCount; // 2の回数を気持ち多めに(2,2,2,3,4点スワップ)
        var swaps        = new Square[swapCount];
        var swappedWalls = new bool[swapCount];

        for (int i = 0; i < swapCount; i++)
        {
            swaps[i]        = new Square(_xorShift.Next(swapSquare), _xorShift.Next(swapSquare)) + offset;
            swappedWalls[i] = _walls[swaps[i].Row, swaps[i].Column];
        }

        if (swappedWalls.Any(w => w) && swappedWalls.Any(w => !w))  // 全部壁or全部通路はSwapの意味がない
        {
            for (int i = 0; i < swaps.Length; i++)
            {
                _walls[swaps[i].Row, swaps[i].Column] = swappedWalls[(i + 1) % swappedWalls.Length];
            }

            var newScore = calculator.CalculateScore(_walls);
            if (IsAcceptableScore(lastScore, newScore, temperature))
            {
                //ShowMap();
                Debug.WriteLine((newScore > lastScore ? "[Updated!]" : "") + "Swap(" + swapCount + ", sq:" + swapSquare + "): " + newScore);
                return(newScore);
            }
            else
            {
                for (int i = 0; i < swaps.Length; i++)
                {
                    _walls[swaps[i].Row, swaps[i].Column] = swappedWalls[i];
                }
                return(lastScore);
            }
        }

        return(lastScore);
    }
        public async Task CalculateScoreWithNoExtraPointsAsync()
        {
            //IDatamuseAPI bob = RestService.For<IDatamuseAPI>("https://api.datamuse.com");

            //-- Arrange
            var          calculator = new ScoreCalculator(_wordLookup);
            const string WORD       = "toe";

            //-- Act
            Score score = await calculator.CalculateScoreAsync(WORD);

            var actual = (int)score?.WordScore;

            //-- Assert
            var expected = 4; // 3 + (0 + 0 + 0) + 1

            Assert.AreEqual(expected, actual);
        }
示例#31
0
 // Use this for initialization
 void Start()
 {
     m_scoreCalculator = GetComponent<ScoreCalculator>();
 }
示例#32
0
    void Awake()
    {
        Instance = this;

        calculator =  new ScoreCalculator();
    }