コード例 #1
0
        public void FinishMiniGame(int score, int miniGameID, int categoryID)
        {
            if (User.Identity.IsAuthenticated)
            {
                float           newStat = 0;
                ProfileProgress p       = _progress.Get((int)Session["profileID"]);

                //add minigame to recenlty played
                _minigame.UpdateRecentlyPlayedMiniGames((int)Session["profileID"], miniGameID);

                //recalculate performance statistic based on value returned from minigame
                _stats = _options.Get((int)Session["profileID"]);

                if (categoryID == 1) //Reading category
                {
                    newStat = _stats.ReadingPerformanceStat + score;

                    //check if difficulty needs to be adjusted up or down
                    if (newStat > 125 && _stats.ReadingDifficultyLevel < HIGHEST_DIFF)  //increase difficulty
                    {
                        _stats.ReadingDifficultyLevel = _stats.ReadingDifficultyLevel + 1;
                        _options.UpdateDifficulty(_stats);
                        newStat = 100;  //reset stat
                    }
                    else if (newStat < 75 && _stats.ReadingDifficultyLevel > LOWEST_DIFF)
                    {
                        _stats.ReadingDifficultyLevel = _stats.ReadingDifficultyLevel - 1; //decrease difficulty
                        _options.UpdateDifficulty(_stats);
                        newStat = 100;                                                     //reset stat
                    }
                    else if (newStat < 75 && _stats.ReadingDifficultyLevel == LOWEST_DIFF ||
                             newStat > 125 && _stats.ReadingDifficultyLevel == HIGHEST_DIFF)
                    {
                        newStat = 100;  //already at boundary, reset stat
                    }
                    //write stats to DB
                    _minigame.UpdatePerformanceStats((int)Session["profileID"], newStat, _stats.MathPerformanceStat);
                }
                else  //Math category
                {
                    newStat = _stats.MathPerformanceStat + score;

                    //check if difficulty needs to be adjusted up or down
                    if (newStat > 125 && _stats.MathDifficultyLevel < HIGHEST_DIFF) //increase difficulty
                    {
                        _stats.MathDifficultyLevel = _stats.MathDifficultyLevel + 1;
                        _options.UpdateDifficulty(_stats);
                        newStat = 100;  //reset stat
                    }
                    else if (newStat < 75 && _stats.MathDifficultyLevel > LOWEST_DIFF)
                    {
                        _stats.MathDifficultyLevel = _stats.MathDifficultyLevel - 1; //decrease difficulty
                        _options.UpdateDifficulty(_stats);
                        newStat = 100;                                               //reset stat
                    }
                    else if (newStat < 75 && _stats.MathDifficultyLevel == LOWEST_DIFF ||
                             newStat > 125 && _stats.MathDifficultyLevel == HIGHEST_DIFF)
                    {
                        newStat = 100;  //already at boundary, reset stat
                    }
                    //write stats to DB
                    _minigame.UpdatePerformanceStats((int)Session["profileID"], _stats.ReadingPerformanceStat, newStat);
                }

                //update current node (move to next node on map)
                if (p.CurrentNode < _node.GetList(p.CurrentMap).Count)
                {
                    _progress.UpdateCurrentNode((int)Session["profileID"]);
                }
            }
            else     //free play mode
            {
                if ((int)Session["fp_nodeID"] < _node.GetList((int)Session["fp_mapID"]).Count)
                {
                    Session["fp_nodeID"] = (int)Session["fp_nodeID"] + 1;  //go to next node
                }
            }
        }
コード例 #2
0
        public void UpdateReadingPerformanceStatTest()
        {
            int     score          = 5;   //score from minigame
            float   oldReadingStat = 0;   //stat for reading from database for profile
            float   oldMathStat    = 0;   //stat for math from database for profile
            float   newStat        = 0;   //new stat for profile
            int     oldReadingDifficulty; //reading difficulty from database for profile
            int     categoryID = 1;       //minigame CategoryID (1 for Reading)
            Options _stats;               //stats for updating difficulty after minigame

            //set initial reading stat and math stats for profile
            _minigame.UpdatePerformanceStats(profileID, 80, 70);

            _stats               = _options.Get(profileID);       //get information for profile from database
            oldReadingStat       = _stats.ReadingPerformanceStat; //get reading stat from database
            oldMathStat          = _stats.MathPerformanceStat;    //ensure that math stat doesn't change
            oldReadingDifficulty = _stats.ReadingDifficultyLevel; //ensure difficulty doesn't change

            //recalculate performance statistic based on value returned from minigame
            if (categoryID == 1) //Reading category
            {
                newStat = _stats.ReadingPerformanceStat + score;
                _minigame.UpdatePerformanceStats(profileID, newStat, _stats.MathPerformanceStat);

                //check if difficulty needs to be adjusted up or down
                if (newStat > 125 && _stats.ReadingDifficultyLevel < HIGHEST_DIFF)
                {
                    _stats.ReadingDifficultyLevel = _stats.ReadingDifficultyLevel + 1;
                    _options.UpdateDifficulty(_stats);
                }
                else if (newStat < 75 && _stats.ReadingDifficultyLevel > LOWEST_DIFF)
                {
                    _stats.ReadingDifficultyLevel = _stats.ReadingDifficultyLevel - 1;
                    _options.UpdateDifficulty(_stats);
                }
            }

            //requery for latest profile information
            _stats = _options.Get(profileID);                                     //get information for profile from database

            Assert.AreEqual(oldMathStat, _stats.MathPerformanceStat);             //ensure didn't change
            Assert.AreEqual(newStat, _stats.ReadingPerformanceStat);              //check if updated correctly
            Assert.AreEqual(oldReadingDifficulty, _stats.ReadingDifficultyLevel); //ensure didn't change
        }