public void UpdateRecentlyPlayedMiniGamesTest() { int miniGameID = 3; //add minigame to recenlty played _minigame.UpdateRecentlyPlayedMiniGames(profileID, miniGameID); //get list of recently plated minigames List <int> recentlyPlayed = _minigame.GetListRecentlyPlayed(profileID); //check that miniGameID is equal to last miniGameID in list of recently played Assert.AreEqual(miniGameID, recentlyPlayed[recentlyPlayed.Count - 1]); }
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 } } }