public void UpdateCurrentNodeTest() { int expectedNode = 2; //update current node (move to next node on map) _progress.UpdateCurrentNode(profileID); //get current profile progress ProfileProgress progess = _progress.Get(profileID); int result = progess.CurrentNode; //Restore current node back to original value using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Aura"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = connection; cmd.CommandText = "UPDATE ProfileProgress SET CurrentNode=@NewNode WHERE ProfileID=@ProfileID"; cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@ProfileID", profileID); cmd.Parameters.AddWithValue("@NewNode", currentNode); connection.Open(); cmd.ExecuteNonQuery(); } } //get current profile progress progess = _progress.Get(profileID); //check that expected node, result node from update, and current node + 1 from //restoring of current node value are equal Assert.AreEqual(expectedNode, result, (progess.CurrentNode + 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 } } }