Price the raw goods left at 0 and every made commodity: RawStartPrices applied to Aetheria.cc
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4d13003155
commit
c8e17c203f
2 changed files with 21 additions and 2 deletions
BIN
GameData/Aetheria.cc
(Stored with Git LFS)
BIN
GameData/Aetheria.cc
(Stored with Git LFS)
Binary file not shown.
19
tools/AetherDb/Economy/RawStartPrices.cs
Normal file
19
tools/AetherDb/Economy/RawStartPrices.cs
Normal file
|
|
@ -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<RecipeData>())
|
||||
{
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue