public StatTable(StatTable other) { id = nextId++; // Base values must be copied BaseValues = new StatMap(other.BaseValues); // Don't need to copy these directly, as changing level will propagate changes LeveledValues = new StatMap(); ModifiedValues = new StatMap(); // Progressions, modifiers, dependants must be copied Progressions = new StatMap(other.Progressions); Dependants = new StatDependantMap(other.Dependants); // Modifiers need extra care, as they need to refer to other objects Modifiers = new Dictionary <string, ModifierMap>(); foreach (KeyValuePair <string, ModifierMap> modMap in other.Modifiers) { foreach (KeyValuePair <ModifierType, HashSet <StatModifier> > modSet in modMap.Value) { foreach (StatModifier mod in modSet.Value) { AddModifier(new StatModifier(mod, this)); } } } // Using property fills out leveled and modified values Level = other.Level; }
/// <summary> /// Populates a given NarrativeEffect struct with all parsable stat changes found in a line. /// </summary> /// <param name="input">The data line to parse.</param> /// <param name="effect">The struct to populate.</param> private void PopulateStatChanges(string input, ref NarrativeEffect effect, List <int> lineNumbers) { var statMatches = StatRegex.Matches(input); foreach (Match match in statMatches) { // Check if a matched stat is invalid if (!StatMap.ContainsKey(match.Groups[1].Value)) { WarnInvalidStat(match.Groups[1].Value, lineNumbers); continue; } // Otherwise, process as normal var stat = StatMap[match.Groups[1].Value]; var operation = match.Groups[2].Value[0]; _ = int.TryParse(match.Groups[3].Value, out var value); switch (operation) { case Symbol.AddChar: effect.statChanges.Add(new StatChange(stat, value, true)); break; case Symbol.SubChar: effect.statChanges.Add(new StatChange(stat, -value, true)); break; case Symbol.SetChar: effect.statChanges.Add(new StatChange(stat, value, false)); break; } } }
public StatTable(int level_ = 1) { id = nextId++; BaseValues = new StatMap(); LeveledValues = new StatMap(); ModifiedValues = new StatMap(); Progressions = new StatMap(); Modifiers = new Dictionary <string, ModifierMap>(); Dependants = new StatDependantMap(); Level = level_; }
public virtual void Show(StatMap statMap) { Show(statMap.StatType, (int)statMap.Value); }