Use labour value for prices

This commit is contained in:
Joshua Barretto 2021-04-18 17:05:14 +01:00
parent fcc23a4427
commit 11683084ad
3 changed files with 15 additions and 9 deletions

View File

@ -36,10 +36,10 @@ loot_tables: [
// this is the amount of that good the most common item represents
// so basically this table balances the goods against each other (higher=less valuable)
good_scaling: [
(Potions, 0.0005), // common.items.consumable.potion_minor
(Food, 1.0), // common.items.food.mushroom
(Coin, 10.0), // common.items.utility.coins
(Armor, 0.5), // common.items.armor.misc.pants.worker_blue
(Tools, 0.5), // common.items.weapons.staff.starter_staff
(Ingredients, 2.5), // common.items.crafting_ing.leather_scraps
(Potions, 0.3), // common.items.consumable.potion_minor
(Food, 3.0), // common.items.food.mushroom
(Coin, 1.0), // common.items.utility.coins
(Armor, 0.2), // common.items.armor.misc.pants.worker_blue
(Tools, 0.2), // common.items.weapons.staff.starter_staff
(Ingredients, 0.25), // common.items.crafting_ing.leather_scraps
])

View File

@ -1,5 +1,10 @@
// we use a vector to easily generate a key into all the economic data containers
([
(
name: "Banker",
orders: [ (Ingredients, 12.0), (Stone, 4.0), (Tools, 1.0), (RoadSecurity, 4.0) ],
products: [ (Coin, 16.0) ],
),
(
name: "Cook",
orders: [ (Flour, 12.0), (Meat, 4.0), (Wood, 1.5), (Stone, 1.0) ],

View File

@ -328,14 +328,15 @@ impl Economy {
pub fn get_site_prices(&self) -> SitePrices {
SitePrices {
values: {
// Use labor values as prices. Not correct (doesn't care about exchange value)
let prices = self.labor_values.clone();
// Normalized values. Note: not correct, but better than nothing
let sum = self
.values
let sum = prices
.iter()
.map(|(_, price)| (*price).unwrap_or(0.0))
.sum::<f32>()
.max(0.001);
self.values
prices
.iter()
.map(|(g, v)| (g, v.map(|v| v / sum).unwrap_or(Economy::MINIMUM_PRICE)))
.collect()