private bool CheckValidModifiers(Dictionary <string, double> manualModifiers, Action <string> messageCallback) { if (manualModifiers == null) { return(true); } foreach (string currentMod in manualModifiers.Keys) { if (!ModifierRanges.ContainsKey(currentMod)) { messageCallback.Invoke(ColorCoder.Error($"The modifier '{currentMod}' doesn't exist!")); } double manualVal = manualModifiers[currentMod]; double min = ModifierRanges[currentMod].Item1; double max = ModifierRanges[currentMod].Item2; if (manualVal < min || manualVal > max) { messageCallback.Invoke(ColorCoder.Error($"The modifier '{currentMod}' is not in the valid range of [{min} to {max}]!")); return(false); } } return(true); }
public static Dictionary <string, double> ParseModifierParameters(List <string> parameters) { Dictionary <string, double> toRet = new Dictionary <string, double>(); for (int i = 0; i < parameters.Count; i++) { if (!parameters[i].Contains("=")) { return(toRet); } string[] split = parameters[i].Split(new char[] { '=' }); string modName = split[0]; string modValue = split[1].Replace(".", ","); if (!ModifierRanges.ContainsKey(modName)) { return(toRet); } if (!double.TryParse(modValue, out double modValueParsed)) { return(toRet); } toRet.Add(modName, modValueParsed); } return(toRet); }