From dd89f3099dad283e27e1cfb9faa69134eb8af19f Mon Sep 17 00:00:00 2001 From: Sarahtonin Date: Wed, 2 Sep 2026 20:47:17 +0200 Subject: [PATCH] Added net dew per hour --- Scripts/Garden/Economy.js | 82 +++++++++++++++++++++++++++++ Scripts/Garden/PlantEncyclopedia.js | 15 ++++++ Scripts/Garden/Shop.js | 15 ++++++ 3 files changed, 112 insertions(+) diff --git a/Scripts/Garden/Economy.js b/Scripts/Garden/Economy.js index a062b46..59ee46c 100644 --- a/Scripts/Garden/Economy.js +++ b/Scripts/Garden/Economy.js @@ -617,3 +617,85 @@ function GetPlantHarvestReward( Cost * 1.5 ); } + + +function GetPlantDewPerHour( + SaveData, + PlantId +) { + const Plant = + GetPlantById( + PlantId + ); + + if (Plant === null) { + return null; + } + + + const GrowthTime = Number( + Plant.GrowthTime + ); + + if ( + !Number.isFinite( + GrowthTime + ) || + GrowthTime <= 0 + ) { + return null; + } + + + const Cost = + GetPlantShopCost( + SaveData, + PlantId + ); + + const Reward = + GetPlantHarvestReward( + SaveData, + PlantId + ); + + if ( + Cost === null || + Reward === null + ) { + return null; + } + + + const Profit = + Reward - Cost; + + return ( + Profit * 3600000 / + GrowthTime + ); +} + + +function FormatDewPerHour( + DewPerHour +) { + if ( + DewPerHour === null || + !Number.isFinite( + DewPerHour + ) + ) { + return "Unavailable"; + } + + return ( + DewPerHour.toLocaleString( + undefined, + { + maximumFractionDigits: 2 + } + ) + + " Dew" + ); +} diff --git a/Scripts/Garden/PlantEncyclopedia.js b/Scripts/Garden/PlantEncyclopedia.js index 763c281..3087309 100644 --- a/Scripts/Garden/PlantEncyclopedia.js +++ b/Scripts/Garden/PlantEncyclopedia.js @@ -300,6 +300,12 @@ function CreatePlantEncyclopediaDetails( Plant.Id ); + const DewPerHour = + GetPlantDewPerHour( + PlantEncyclopediaSave, + Plant.Id + ); + Details.appendChild( CreatePlantEncyclopediaStat( "Reward", @@ -310,6 +316,15 @@ function CreatePlantEncyclopediaDetails( ) ); + Details.appendChild( + CreatePlantEncyclopediaStat( + "Dew / hour", + FormatDewPerHour( + DewPerHour + ) + ) + ); + const RecipeProgress = GetPlantRecipeProgress( diff --git a/Scripts/Garden/Shop.js b/Scripts/Garden/Shop.js index b1368e8..e8d8b76 100644 --- a/Scripts/Garden/Shop.js +++ b/Scripts/Garden/Shop.js @@ -206,6 +206,12 @@ function CreateShopSeedCard( Plant.Id ); + const DewPerHour = + GetPlantDewPerHour( + ShopSave, + Plant.Id + ); + Details.appendChild( CreateShopStat( @@ -227,6 +233,15 @@ function CreateShopSeedCard( ) ); + Details.appendChild( + CreateShopStat( + "Dew / hour", + FormatDewPerHour( + DewPerHour + ) + ) + ); + Details.appendChild( CreateShopStat( "Inventory",