public WdTurret(string id, JsonDict turret, WdData data) { Raw = turret; Id = id; Name = data.ResolveString(turret["userString"].WdString()); Level = turret["level"].WdInt(); Price = turret["price"].WdInt(); Mass = turret["weight"].WdInt(); HitPoints = turret["maxHealth"].WdInt(); RotationSpeed = turret["rotationSpeed"].WdDecimal(); VisionDistance = turret["circularVisionRadius"].WdDecimal(); try { var armor = turret["primaryArmor"].WdString().Split(' ').Select(s => turret["armor"][s].WdDecimal()).ToArray(); ArmorThicknessFront = armor[0]; ArmorThicknessSide = armor[1]; ArmorThicknessBack = armor[2]; } catch { ArmorThicknessFront = ArmorThicknessSide = ArmorThicknessBack = 0; } Guns = new List <WdGun>(); }
public WdChassis(string id, JsonDict chassis, WdData data) { Raw = chassis; Id = id; Name = data.ResolveString(chassis["userString"].WdString()); Level = chassis["level"].WdInt(); Price = chassis["price"].WdInt(); Mass = chassis["weight"].WdInt(); HitPoints = chassis["maxHealth"].WdInt(); MaxLoad = chassis["maxLoad"].WdInt(); MaxClimbAngle = chassis["maxClimbAngle"].WdInt(); RotationSpeed = chassis["rotationSpeed"].WdInt(); var leftTrack = chassis["armor"]["leftTrack"].WdInt(); var rightTrack = chassis["armor"]["rightTrack"].WdInt(); TrackArmorThickness = Math.Max(leftTrack, rightTrack); var terr = chassis["terrainResistance"].WdString().Split(' ').Select(s => decimal.Parse(s, NumberStyles.Float, CultureInfo.InvariantCulture)).ToList(); TerrainResistanceFirm = terr[0]; TerrainResistanceMedium = terr[1]; TerrainResistanceSoft = terr[2]; }
public WdCountry(string name, WdData data, JsonDict tanks, JsonDict engines, JsonDict guns, JsonDict radios, JsonDict shells) { Name = name; Engines = new Dictionary <string, WdEngine>(); foreach (var kvp in engines["shared"].GetDict()) { var engine = new WdEngine(kvp.Key, kvp.Value.GetDict(), data); Engines.Add(kvp.Key, engine); } Radios = new Dictionary <string, WdRadio>(); foreach (var kvp in radios["shared"].GetDict()) { var radio = new WdRadio(kvp.Key, kvp.Value.GetDict(), data); Radios.Add(kvp.Key, radio); } Shells = new Dictionary <string, WdShell>(); foreach (var kvp in shells.GetDict()) { if (kvp.Key == "icons") { continue; } var shell = new WdShell(kvp.Key, kvp.Value.GetDict(), data); Shells.Add(kvp.Key, shell); } Guns = new Dictionary <string, WdGun>(); foreach (var kvp in guns["shared"].GetDict()) { try { var gun = new WdGun(kvp.Key, kvp.Value.GetDict(), data, this); Guns.Add(kvp.Key, gun); } catch { data.Warnings.Add("Could not load gun data for gun “{0}”".Fmt(kvp.Key)); } } Tanks = new Dictionary <string, WdTank>(); Chassis = new Dictionary <string, WdChassis>(); Turrets = new Dictionary <string, WdTurret>(); foreach (var kvp in tanks.GetDict()) { if (Name == "usa" && kvp.Key == "Sexton_I") { continue; // this tank is weird; it's the only one which has non-"shared" modules with identical keys to another tank. Ignore it. } var tank = new WdTank(kvp.Key, kvp.Value.GetDict(), this, data); Tanks.Add(tank.RawId, tank); } }
public WdGun(string id, JsonDict gun, WdData data, WdCountry country) { Raw = gun; Id = id; Name = data.ResolveString(gun["userString"].WdString()); Shells = new List <WdShell>(); PitchUpLimit = -999; PitchDownLimit = -999; UpdateFrom(gun, country, initialize: true); }
public WdRadio(string id, JsonDict radio, WdData data) { Raw = radio; Id = id; Name = data.ResolveString(radio["userString"].WdString()); Level = (radio.ContainsKey("Level") ? radio["Level"] : radio["level"]).WdInt(); // "Level" used in older clients for at least one radio Price = radio["price"].WdInt(); Mass = radio["weight"].WdInt(); HitPoints = radio["maxHealth"].WdInt(); Distance = radio["distance"].WdInt(); }
public WdEngine(string id, JsonDict engine, WdData data) { Raw = engine; Id = id; Name = data.ResolveString(engine["userString"].WdString()); Level = engine["level"].WdInt(); Price = engine["price"].WdInt(); Mass = engine["weight"].WdInt(); HitPoints = engine["maxHealth"].WdDecimal(); Power = engine["power"].WdInt(); FireStartChance = engine["fireStartingChance"].WdDecimal(); }
public WdShell(string id, JsonDict shell, WdData data) { Raw = shell; Id = id; Name = data.ResolveString(shell["userString"].WdString()); Kind = shell["kind"].WdString(); Caliber = shell["caliber"].WdDecimal(); DamageArmor = shell["damage"]["armor"].WdInt(); DamageDevices = shell["damage"]["devices"].WdInt(); Price = shell["price"].WdInt(); Gold = shell["price"] is JsonDict && shell["price"].ContainsKey("gold"); }
public WdTank(string id, JsonDict json, WdCountry country, WdData data) { RawId = id; Country = country; Raw = json; var tags1 = Raw["tags"].WdString().Split("\r\n").Select(s => s.Trim()).ToHashSet(); var tags2 = Raw["tags"].WdString().Split(' ').Select(s => s.Trim()).ToHashSet(); Tags = tags1.Count > tags2.Count ? tags1 : tags2; NotInShop = Raw.ContainsKey("notInShop") && Raw["notInShop"].GetBool(); Price = Raw["price"] is JsonDict ? Raw["price"][""].WdInt() : Raw["price"].WdInt(); Gold = Raw["price"] is JsonDict && Raw["price"].ContainsKey("gold"); if (Tags.Contains("lightTank")) { Class = "lightTank"; } else if (Tags.Contains("mediumTank")) { Class = "mediumTank"; } else if (Tags.Contains("heavyTank")) { Class = "heavyTank"; } else if (Tags.Contains("SPG")) { Class = "SPG"; } else if (Tags.Contains("AT-SPG")) { Class = "AT-SPG"; } else { Class = null; } Tier = Raw["level"].WdInt(); Secret = Tags.Contains("secret"); string scriptsFolder = string.IsNullOrEmpty(data.VersionConfig.PathSourceScripts) ? @"res\scripts" : data.VersionConfig.PathSourceScripts; var path = WotFileExporter.CombinePaths(data.Installation.Path, scriptsFolder, @"item_defs\vehicles\{0}\{1}.xml".Fmt(Country.Name, id)); using (var stream = WotFileExporter.GetFileStream(path)) { RawExtra = BxmlReader.ReadFile(stream); } FullName = data.ResolveString(Raw["userString"].WdString()); ShortName = Raw.ContainsKey("shortUserString") ? data.ResolveString(Raw["shortUserString"].WdString()) : FullName; Description = data.ResolveString(Raw["description"].WdString()); MaxSpeedForward = RawExtra["speedLimits"]["forward"].WdDecimal(); MaxSpeedReverse = RawExtra["speedLimits"]["backward"].WdDecimal(); RepairCost = RawExtra["repairCost"].WdDecimal(); Hull = new WdHull(RawExtra["hull"].GetDict()); Chassis = new List <WdChassis>(); Turrets = new List <WdTurret>(); Engines = new List <WdEngine>(); Radios = new List <WdRadio>(); // these lists are populated once all the tanks are loaded, since some shared modules occur before the non-shared "definition" of the module. foreach (var kvp in RawExtra["chassis"].GetDict()) { if (kvp.Value.GetStringLenientSafe() != "shared" && kvp.Value.Safe[""].GetStringSafe() != "shared" && !kvp.Value.ContainsKey("shared")) { Country.Chassis.Add(kvp.Key, new WdChassis(kvp.Key, kvp.Value.GetDict(), data)); } } foreach (var kvp in RawExtra["turrets0"].GetDict()) { if (kvp.Value.GetStringLenientSafe() != "shared" && kvp.Value.Safe[""].GetStringSafe() != "shared" && !kvp.Value.ContainsKey("shared")) { Country.Turrets.Add(kvp.Key, new WdTurret(kvp.Key, kvp.Value.GetDict(), data)); } } // RawExtra["engines"] and RawExtra["radios"] only contain information about unlocks; the rest is contained in separate files parsed in WdCountry. }