public WeaponOptionNode(string stringNotation, WeaponList weaponList) { int dept = 0; string nextlevel = ""; string itemString = ""; string stringNotationMinusMinMax = stripMinMaxOffString(stringNotation, ref _min, ref _max); foreach (Char c in stringNotationMinusMinMax) { if (c.CompareTo(']') == 0) { dept -= dept; if (dept == 0) { WeaponOptionNode newNode = new WeaponOptionNode(nextlevel, weaponList); _weaponOptions.Add(newNode); nextlevel = ""; } if (dept < 0) { SimpleLogger sl = new SimpleLogger("WarhammerUnitCompareCSharp.log", true); sl.Error("More ] than [ in : " + stringNotation); } } if (dept > 0) { nextlevel += c; } else if (c.CompareTo('+') == 0) { if (_operator != Operator.Or) { _operator = Operator.And; if (itemString != "") { WeaponOptionNode newNode = new WeaponOptionNode(itemString, weaponList); _weaponOptions.Add(newNode); itemString = ""; } } else { SimpleLogger sl = new SimpleLogger("WarhammerUnitCompareCSharp.log", true); sl.Error("Conflicting operators in: " + stringNotation); } } else if (c.CompareTo('/') == 0) { if (_operator != Operator.And) { _operator = Operator.Or; if (itemString != "") { WeaponOptionNode newNode = new WeaponOptionNode(itemString, weaponList); _weaponOptions.Add(newNode); itemString = ""; } } else { SimpleLogger sl = new SimpleLogger("WarhammerUnitCompareCSharp.log", true); sl.Error("Conflicting operators in: " + stringNotation); } } else if ("[]".IndexOf(c) < 0) { itemString += c; } if (c.CompareTo('[') == 0) { dept += 1; } } if (itemString.Length != 0) { if (_weaponOptions.Count == 0) { _weapon = weaponList[itemString]; } else { WeaponOptionNode newNode = new WeaponOptionNode(itemString, weaponList); _weaponOptions.Add(newNode); } } }