From fcc23a44272d735fb3077ee46edb24f70b84126d Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 18 Apr 2021 15:09:21 +0100 Subject: [PATCH] Normalised prices within sites --- assets/common/item_price_calculation.ron | 16 +++++++------- world/src/site/economy.rs | 27 ++++++++++++++---------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/assets/common/item_price_calculation.ron b/assets/common/item_price_calculation.ron index 1c0a9b7713..c544bb583a 100644 --- a/assets/common/item_price_calculation.ron +++ b/assets/common/item_price_calculation.ron @@ -25,9 +25,9 @@ loot_tables: [ (0.075, "common.loot_tables.armor.cultist"), // Materials (7.5, "common.loot_tables.materials.common"), - (5.0, "common.loot_tables.materials.underground"), + (8.0, "common.loot_tables.materials.underground"), // Food - (0.5, "common.loot_tables.food.farm_ingredients"), + (0.3, "common.loot_tables.food.farm_ingredients"), (0.5, "common.loot_tables.food.wild_ingredients"), (0.2, "common.loot_tables.food.prepared"), // TODO: Change consumables when they are split up later @@ -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.025), // common.items.consumable.potion_minor - (Food, 2.0), // common.items.food.mushroom - (Coin, 25.0), // common.items.utility.coins - (Armor, 0.1), // common.items.armor.misc.pants.worker_blue - (Tools, 0.15), // common.items.weapons.staff.starter_staff - (Ingredients, 0.25), // common.items.crafting_ing.leather_scraps + (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 ]) diff --git a/world/src/site/economy.rs b/world/src/site/economy.rs index 360d737b24..ef8042b5be 100644 --- a/world/src/site/economy.rs +++ b/world/src/site/economy.rs @@ -305,14 +305,11 @@ impl Economy { } else { add_biome(BiomeKind::Forest, 0.5 + ch.tree_density); add_biome(BiomeKind::Grassland, 0.5 + ch.humidity); - add_biome(BiomeKind::Jungle, 0.5 + ch.humidity * (ch.temp * 0.5 + 0.5)); - add_biome( - BiomeKind::Mountain, - 0.5 + ch.rockiness + (ch.alt / 4000.0).max(0.0), - ); + add_biome(BiomeKind::Jungle, 0.5 + ch.humidity * ch.temp.max(0.0)); + add_biome(BiomeKind::Mountain, 0.5 + (ch.alt / 4000.0).max(0.0)); add_biome( BiomeKind::Desert, - 0.5 + (1.0 - ch.humidity) * (ch.temp * 0.5 + 0.5), + 0.5 + (1.0 - ch.humidity) * ch.temp.max(0.0), ); add_biome(BiomeKind::Snowland, 0.5 + (-ch.temp).max(0.0)); } @@ -330,11 +327,19 @@ impl Economy { pub fn get_site_prices(&self) -> SitePrices { SitePrices { - values: self - .values - .iter() - .map(|(g, v)| (g, v.unwrap_or(Economy::MINIMUM_PRICE))) - .collect(), + values: { + // Normalized values. Note: not correct, but better than nothing + let sum = self + .values + .iter() + .map(|(_, price)| (*price).unwrap_or(0.0)) + .sum::() + .max(0.001); + self.values + .iter() + .map(|(g, v)| (g, v.map(|v| v / sum).unwrap_or(Economy::MINIMUM_PRICE))) + .collect() + }, } } }