/// <summary> /// Returns the amount of gold the user should get for the specified city /// </summary> /// <param name="city">City to recalculate resources for</param> /// <returns></returns> public virtual int GetGoldRate(ICity city) { int value = 0; var weaponExportMax = city.Technologies.GetEffects(EffectCode.WeaponExport) .DefaultIfEmpty() .Max(x => x == null ? 0 : (int)x.Value[0]); if (weaponExportMax > 0) { value += GetWeaponExportLaborProduce(weaponExportMax, city.Resource.Labor.Value, city.Resource.Gold.Value); } foreach (Structure structure in city.Where(x => ObjectTypeFactory.IsStructureType("Market", x))) { if (structure.Lvl >= 10) { value += 50; } else if (structure.Lvl >= 6) { value += 18; } else if (structure.Lvl >= 4) { value += 4; } } return(value); }
/// <summary> /// Returns the amount of crop the user should get for the specified city /// </summary> /// <param name="city">City to recalculate resources for</param> /// <returns></returns> public virtual int GetCropRate(ICity city) { double[] lvlBonus = { 1, 1, 1, 1, 1, 1, 1, 1.1, 1.1, 1.2, 1.2, 1.3, 1.3, 1.4, 1.4, 1.5 }; return(60 + city.Lvl * 5 + (int) city.Sum(x => ObjectTypeFactory.IsStructureType("Crop", x) ? x.Stats.Labor * lvlBonus[x.Lvl] : 0)); }
public virtual string GetForestCampLaborerString(IStructure lumbermill) { int max = GetLumbermillMaxLabor(lumbermill); int cur = lumbermill.City.Where(s => ObjectTypeFactory.IsStructureType("ForestCamp", s)).Sum(x => x.Stats.Labor); return(string.Format("{0}/{1}", cur, max)); }
/// <summary> /// Returns the rate that the specified structure should gather from the given forest. /// </summary> /// <param name="forestCamp"></param> /// <param name="efficiency"></param> /// <returns></returns> public virtual int GetWoodRateForForestCamp(IStructure forestCamp, float efficiency) { var lumbermill = forestCamp.City.FirstOrDefault(s => ObjectTypeFactory.IsStructureType("Lumbermill", s)); if (lumbermill == null) { return(0); } double[] rate = { 0, .75, .75, 1, 1, 1, 1, 1.25, 1.25, 1.25, 1.25, 1.25, 1.5, 1.5, 1.5, 1.5 }; return((int)(forestCamp.Stats.Labor * rate[lumbermill.Lvl] * (1f + efficiency))); }
/// <summary> /// Returns the amount of wood the user should get for the specified city. /// Notice: This function looks at all the Forest Camps Rate property and adds them up. /// </summary> /// <param name="city">City to recalculate resources for</param> /// <returns></returns> public virtual int GetWoodRate(ICity city) { return(60 + city.Lvl * 5 + city.Sum(x => { object rate; if (!ObjectTypeFactory.IsStructureType("ForestCamp", x) || x.Lvl == 0 || !x.Properties.TryGet("Rate", out rate)) { return 0; } return (int)rate; })); }
/// <summary> /// Gets amount of resources that are hidden /// </summary> /// <param name="city"></param> /// <param name="checkAlignmentPointBonus"></param> /// <returns></returns> public virtual Resource HiddenResource(ICity city, bool checkAlignmentPointBonus = false) { int[] rateCrop = { 0, 100, 150, 220, 330, 500, 740, 1100, 1100, 1100, 1100 }; int[] rateWood = { 0, 100, 150, 220, 330, 500, 740, 1100, 1100, 1100, 1100 }; int[] rateGold = { 0, 0, 0, 0, 0, 100, 150, 220, 330, 500, 740 }; int[] rateIron = { 0, 0, 0, 0, 0, 0, 0, 0, 200, 360, 660 }; var resource = new Resource(); foreach (var structure in city.Where(x => ObjectTypeFactory.IsStructureType("Basement", x))) { resource.Add(rateCrop[structure.Lvl], rateGold[structure.Lvl], rateIron[structure.Lvl], rateWood[structure.Lvl], 0); } int[] tempRateCrop = { 0, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700 }; int[] tempRateWood = { 0, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700 }; int[] tempRateGold = { 0, 0, 0, 0, 0, 500, 600, 700, 800, 900, 1000 }; int[] tempRateIron = { 0, 0, 0, 0, 0, 0, 0, 0, 500, 750, 1000 }; foreach (var structure in city.Where(x => ObjectTypeFactory.IsStructureType("TempBasement", x))) { resource.Add(tempRateCrop[structure.Lvl], tempRateGold[structure.Lvl], tempRateIron[structure.Lvl], tempRateWood[structure.Lvl], 0); } if (checkAlignmentPointBonus && city.AlignmentPoint >= 75m) { const double pct = .75; return(new Resource((int)Math.Max(city.Resource.Crop.Limit * pct, resource.Crop), (int)Math.Max(city.Resource.Gold.Limit * pct, resource.Gold), (int)Math.Max(city.Resource.Iron.Limit * pct, resource.Iron), (int)Math.Max(city.Resource.Wood.Limit * pct, resource.Wood), 0)); } return(resource); }
/// <summary> /// Returns the amount of iron the user should get for the specified city /// </summary> /// <param name="city">City to recalculate resources for.</param> /// <returns></returns> public virtual int GetIronRate(ICity city) { int[] multiplier = { int.MaxValue, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 4 }; return(city.Sum(x => ObjectTypeFactory.IsStructureType("Iron", x) ? x.Stats.Labor / multiplier[x.Lvl] : 0)); }
public virtual ushort CalculateCityValue(ICity city) { return((ushort)city.Where(structure => !ObjectTypeFactory.IsStructureType("NoInfluencePoint", structure)).Sum(x => x.Lvl * x.Size)); }
public virtual int BuildTime(int baseValue, ICity city, ITechnologyManager em) { IStructure university = city.FirstOrDefault(structure => ObjectTypeFactory.IsStructureType("University", structure)); return((int)(baseValue * (100 - (university == null ? 0 : university.Stats.Labor) * 0.25) / 100)); }