/// <summary> /// Method for updating secondary motivation Aspect ( != attention/satisfaction/confidence) /// </summary> /// /// <param name="ms"> Motivation state for storing the new values. </param> internal void updateSecondaryMotivationAspects(MotivationState ms) { MotivationModel mm = ms.getMotivationModel(); foreach (MotivationAspect ma in mm.motivationAspects.motivationAspectList) { if (!primaryMotivationAspects.Contains(ma.name)) { if (ms.getMotivation().ContainsKey(ma.name)) { try { double sol = FormulaInterpreter.eval(ma.rule); ms.updateMotivationAspect(ma.name, sol); } catch (Exception e) { loggingMAs("Warning: Update for secondary motivation aspects not done.", Severity.Warning); loggingMAs("Exception caught: " + e.Message); } } else { loggingMAs("Warning: Motivation aspect not found!", Severity.Warning); } } } }
/// <summary> /// Method for replacing motivation component variables with the current values. /// </summary> /// /// <param name="expression"> String for which replacement should happen. </param> /// /// <returns> String without any motivation component variables. </returns> private static String replaceVariables(String expression) { MotivationState ms = MotivationAssessmentAsset.Handler.getMotivationState(); MotivationModel mm = ms.getMotivationModel(); foreach (MotivationAspect ma in mm.motivationAspects.motivationAspectList) { expression = expression.Replace(ma.name, ms.getMotivationAspectValue(ma.name).ToString()); } MotivationAssessmentAsset.Handler.loggingMAs("FormulaInterpreter: expression to evaluate without variables=" + expression); return(expression); }
/// <summary> /// Method for updating primary motivation Aspect (attention/satisfaction/confidence) /// </summary> /// ///<param name="ms"> Motivation state for storing the new values. </param> ///<param name="aspect"> String containing "attention","satisfaction" or "confidence". Describes which component gets updated. </param> ///<param name="direction"> Boolean - if true upgrade, else downgrade is done. </param> ///<param name="playerId"> Identification of the player. </param> internal void updatePrimaryMotivationAspect(MotivationState ms, String aspect, Boolean direction) { MotivationModel mm = ms.getMotivationModel(); MotivationAspect ma = mm.motivationAspects.getMotivationAspectByName(aspect); String expression = direction ? ma.up : ma.down; try { double sol = FormulaInterpreter.eval(expression); ms.updateMotivationAspect(aspect, sol); } catch (Exception e) { loggingMAs("Warning: Update for primary motivation aspects not done.", Severity.Warning); loggingMAs("Exception caught: " + e.Message); } }