/// <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> /// Generates a copy of the motivation state. /// </summary> /// /// <returns> A copy of the motivation state. </returns> internal MotivationState getCopy() { MotivationState ms = new MotivationState(this.motivationModel); foreach (KeyValuePair <String, double> entry in this.motivation) { ms.updateMotivationAspect(entry.Key, entry.Value); } return(ms); }
/// <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); } }