diff --git a/GameData/Aetheria.cc b/GameData/Aetheria.cc index 9c2f2dc12..4c4e607a4 100644 --- a/GameData/Aetheria.cc +++ b/GameData/Aetheria.cc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:027fc407196b90b299b0c789259b77cc883edcf5d66dd2ec7e6ad43a970c4723 -size 274281 +oid sha256:589e6db0ee98b9a43b963725164832b0421e07bcb2de56a5ab8f3878c3ea5343 +size 274284 diff --git a/tools/AetherDb/Economy/RawStartPrices.cs b/tools/AetherDb/Economy/RawStartPrices.cs new file mode 100644 index 000000000..c56349a51 --- /dev/null +++ b/tools/AetherDb/Economy/RawStartPrices.cs @@ -0,0 +1,19 @@ +using System; +using GameCult.Caching; + +// One-shot: gives each raw good still at Price 0 a start price, its labour at the going wage over its output count (at least 1). +// Price 0 on a raw good is unset, not free; after this the wage reads only authored raw prices, and author's reprice writes only made +// goods, which never enter the wage. Applied, then deleted. +public sealed class RawStartPrices : EconomyBatch +{ + public override void Author(EconomyAuthor author) + { + var wage = EconomyBalance.Wage(author.Catalog); + foreach (var recipe in author.Catalog.GetAll()) + { + var item = author.Catalog.Get(recipe.Output); + if (item == null || !Recipes.IsCommodity(item) || !Recipes.IsRaw(author.Catalog, recipe) || item.Price != 0) continue; + author.SetPrice(recipe.Output.Key.Value, Math.Max(1, (int) Math.Round(wage * recipe.Workforce * recipe.Cycle / recipe.OutputCount, MidpointRounding.AwayFromZero))); + } + } +}