Skip to content

Commit

Permalink
add province resource bonus for Barnyards and added penalty for uninv…
Browse files Browse the repository at this point in the history
…ented manufactories
  • Loading branch information
Nashet committed Nov 25, 2017
1 parent e790eed commit c397180
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
9 changes: 7 additions & 2 deletions Assets/code/Logic/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public enum Priority { none, low, medium, high }
private int hiredLastTurn;

internal static readonly Modifier
modifierHasResourceInProvince = new Modifier(x => !(x as Factory).getType().isResourceGathering() && (x as Factory).getProvince().isProducingOnFactories((x as Factory).getType().resourceInput),
modifierHasResourceInProvince = new Modifier(x => !(x as Factory).getType().isResourceGathering() &&
((x as Factory).getProvince().isProducingOnEnterprises((x as Factory).getType().resourceInput)
|| ((x as Factory).getProvince().getResource() == Product.Grain && (x as Factory).getType() == FactoryType.Barnyard)
),
"Has input resource in this province", 0.20f, false),

modifierLevelBonus = new Modifier(x => ((x as Factory).getLevel() - 1) / 100f, "High production concentration bonus", 1f, false),
Expand Down Expand Up @@ -148,7 +151,9 @@ internal static readonly ModifiersList
&& (x as Factory).getProvince().isCapital(), "Capital of Polis", 0.50f, false),
new Modifier(x=>(x as Factory).getProvince().hasModifier(Mod.recentlyConquered), Mod.recentlyConquered.ToString(), -0.20f, false),
new Modifier(Government.isTribal, x=>(x as Factory).getCountry(), -1.0f, false),
new Modifier(Government.isDespotism, x=>(x as Factory).getCountry(), -0.30f, false) // remove this?
new Modifier(Government.isDespotism, x=>(x as Factory).getCountry(), -0.30f, false), // remove this?
new Modifier(x=>!(x as Factory).getCountry().isInvented(Invention.Manufactures)
&& !(x as Factory).getType().isResourceGathering(), Invention.ManufacturesUnInvented.getName(), -1f, false)
});

internal Factory(Province province, Agent factoryOwner, FactoryType type) : base(type, province)
Expand Down
2 changes: 2 additions & 0 deletions Assets/code/Logic/FactoryType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@ internal FactoryType(string name, Storage basicProduction, bool shaft)
else
{
Value cost = Game.market.getCost(this.getBuildNeeds());
cost.add(Options.factoryMoneyReservPerLevel);
return agent.canPay(cost);
}
},
delegate
{
var sb = new StringBuilder();
Value cost = Game.market.getCost(this.getBuildNeeds());
cost.add(Options.factoryMoneyReservPerLevel);
sb.Append("Have ").Append(cost).Append(" coins");
sb.Append(" or (with ").Append(Economy.PlannedEconomy).Append(") have ").Append(this.getBuildNeeds());
return sb.ToString();
Expand Down
1 change: 1 addition & 0 deletions Assets/code/Logic/Invention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class Invention : Name
readonly public static Condition WelfareInvented = new Condition(x => (x as Country).isInvented(Invention.Welfare), "Welfare is invented", true);
readonly public static Condition CollectivismInvented = new Condition(x => (x as Country).isInvented(Invention.Collectivism), "Collectivism is invented", true);
readonly public static Condition ManufacturesInvented = new Condition(x => (x as Country).isInvented(Invention.Manufactures), "Manufactures are invented", true);
readonly public static Condition ManufacturesUnInvented = new Condition(x => !(x as Country).isInvented(Invention.Manufactures), "Manufactures aren't invented", true);
internal Invention(string name, string description, Value cost) : base(name)
{
//this.name = name;
Expand Down
8 changes: 4 additions & 4 deletions Assets/code/Logic/Province.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public void secedeTo(Country taker, bool addModifier)
pop.loyalty.subtract(Options.PopLoyaltyChangeOnAnnexNonStateCulture, false);
pop.loyalty.clamp100();
Movement.leave(pop);
}
}

//transfer province
if (oldCountry != null)
Expand Down Expand Up @@ -788,12 +788,12 @@ internal Factory findFactory(FactoryType proposition)
return f;
return null;
}
internal bool isProducingOnFactories(StorageSet resourceInput)
internal bool isProducingOnEnterprises(StorageSet resourceInput)
{
foreach (Storage inputNeed in resourceInput)
foreach (Factory provinceFactory in allFactories)
//if (provinceFactory.isWorking() && provinceFactory.getType().basicProduction.getProduct().isSameProduct(inputNeed.getProduct()))
if (provinceFactory.getGainGoodsThisTurn().isNotZero() && provinceFactory.getType().basicProduction.getProduct().isSameProduct(inputNeed.getProduct()))
if (provinceFactory.getGainGoodsThisTurn().isNotZero() && provinceFactory.getType().basicProduction.getProduct().isSameProduct(inputNeed.getProduct())
)
return true;
return false;
}
Expand Down

0 comments on commit c397180

Please sign in to comment.