public static JSON.BuildingLevels CurrentBuildingToJson(Scaffold.CurrentBuilding currentBuildings) { if (currentBuildings == null) { return(null); } var result = new JSON.BuildingLevels(); AddIfNotNull(result, "snob", currentBuildings.Snob); AddIfNotNull(result, "barracks", currentBuildings.Barracks); AddIfNotNull(result, "church", currentBuildings.Church); AddIfNotNull(result, "stone", currentBuildings.Stone); AddIfNotNull(result, "farm", currentBuildings.Farm); AddIfNotNull(result, "main", currentBuildings.Main); AddIfNotNull(result, "hide", currentBuildings.Hide); AddIfNotNull(result, "iron", currentBuildings.Iron); AddIfNotNull(result, "market", currentBuildings.Market); AddIfNotNull(result, "place", currentBuildings.Place); AddIfNotNull(result, "smith", currentBuildings.Smith); AddIfNotNull(result, "stable", currentBuildings.Stable); AddIfNotNull(result, "status", currentBuildings.Statue); AddIfNotNull(result, "wood", currentBuildings.Wood); AddIfNotNull(result, "wall", currentBuildings.Wall); AddIfNotNull(result, "storage", currentBuildings.Storage); AddIfNotNull(result, "watchtower", currentBuildings.Watchtower); AddIfNotNull(result, "garage", currentBuildings.Garage); return(result); }
public RecruitmentCalculator(float worldSpeed, JSON.BuildingLevels buildingLevels = null) { this.worldSpeed = worldSpeed; this.buildingLevels = buildingLevels ?? new JSON.BuildingLevels(); if (!this.buildingLevels.ContainsKey(Native.BuildingType.Barracks)) { this.buildingLevels[Native.BuildingType.Barracks] = DefaultBarracksLevel; } if (!this.buildingLevels.ContainsKey(Native.BuildingType.Stable)) { this.buildingLevels[Native.BuildingType.Stable] = DefaultStableLevel; } if (!this.buildingLevels.ContainsKey(Native.BuildingType.Garage)) { this.buildingLevels[Native.BuildingType.Garage] = DefaultWorkshopLevel; } if (!this.buildingLevels.ContainsKey(Native.BuildingType.Snob)) { if (this.buildingLevels.ContainsKey(Native.BuildingType.Smith) && this.buildingLevels[Native.BuildingType.Smith] == Native.BuildingStats.MaxLevels[Native.BuildingType.Smith]) { this.buildingLevels[Native.BuildingType.Snob] = DefaultAcademyLevel; } else { this.buildingLevels[Native.BuildingType.Snob] = 0; } } }
public BuildingLevels(BuildingLevels source) { foreach (var kvp in source) { this.Add(kvp.Key, kvp.Value); } }
public RecruitmentCalculator(float worldSpeed, short barracksLevel, short stablesLevel, short workshopLevel, short academyLevel) { this.worldSpeed = worldSpeed; this.buildingLevels = new JSON.BuildingLevels(); this.buildingLevels[Native.BuildingType.Barracks] = barracksLevel; this.buildingLevels[Native.BuildingType.Stable] = stablesLevel; this.buildingLevels[Native.BuildingType.Garage] = workshopLevel; this.buildingLevels[Native.BuildingType.Snob] = academyLevel; }
public static Scaffold.ReportBuilding JsonToReportBuilding(JSON.BuildingLevels buildingLevels, short worldId, Scaffold.ReportBuilding existingBuildings = null, Scaffold.VaultContext context = null) { if (buildingLevels == null || buildingLevels.Count == 0) { if (existingBuildings != null && context != null) { context.Remove(existingBuildings); } return(null); } Scaffold.ReportBuilding result; if (existingBuildings != null) { result = existingBuildings; } else { result = new Scaffold.ReportBuilding(); result.WorldId = worldId; context.Add(result); } result.Barracks = GetOrNull(buildingLevels, "barracks"); result.Church = GetOrNull(buildingLevels, "church"); result.Farm = GetOrNull(buildingLevels, "farm"); result.Garage = GetOrNull(buildingLevels, "garage"); result.Hide = GetOrNull(buildingLevels, "hide"); result.Iron = GetOrNull(buildingLevels, "iron"); result.Main = GetOrNull(buildingLevels, "main"); result.Market = GetOrNull(buildingLevels, "market"); result.Place = GetOrNull(buildingLevels, "place"); result.Smith = GetOrNull(buildingLevels, "smith"); result.Snob = GetOrNull(buildingLevels, "snob"); result.Stable = GetOrNull(buildingLevels, "stable"); result.Statue = GetOrNull(buildingLevels, "statue"); result.Stone = GetOrNull(buildingLevels, "stone"); result.Storage = GetOrNull(buildingLevels, "storage"); result.Wall = GetOrNull(buildingLevels, "wall"); result.Watchtower = GetOrNull(buildingLevels, "watchtower"); result.Wood = GetOrNull(buildingLevels, "wood"); // ? //result.FirstChurch = GetOrNull(buildingLevels, "First church"); return(result); }
public static Scaffold.ReportBuilding ToModel(this JSON.BuildingLevels jsonBuildings, short worldId, Scaffold.ReportBuilding existingBuildings = null, Scaffold.VaultContext context = null) => JsonToReportBuilding(jsonBuildings, worldId, existingBuildings, context);