diff --git a/Scripts/Garden/Shop.js b/Scripts/Garden/Shop.js index 49d8233..01fda45 100644 --- a/Scripts/Garden/Shop.js +++ b/Scripts/Garden/Shop.js @@ -111,11 +111,6 @@ function CreateShopSeedCard( "ShopItemHeader"; - const Number = - document.createElement( - "span" - ); - const Name = document.createElement( "h3" @@ -156,7 +151,7 @@ function CreateShopSeedCard( if ( typeof Plant.Description === - "string" && + "string" && Plant.Description.length > 0 ) { const Description = @@ -173,6 +168,16 @@ function CreateShopSeedCard( } + Details.appendChild( + CreateShopStat( + "Growth time", + FormatShopGrowthTime( + Plant.GrowthTime + ) + ) + ); + + const Cost = GetPlantShopCost( ShopSave, @@ -366,6 +371,51 @@ function CreateShopPlantVisual( } +function FormatShopGrowthTime( + Milliseconds +) { + const TotalMinutes = + Math.max( + 1, + Math.ceil( + Number( + Milliseconds + ) / + 60000 + ) + ); + + const Hours = + Math.floor( + TotalMinutes / + 60 + ); + + const Minutes = + TotalMinutes % + 60; + + + if ( + Hours > 0 && + Minutes > 0 + ) { + return ( + Hours + + "h " + + Minutes + + "m" + ); + } + + if (Hours > 0) { + return Hours + "h"; + } + + return Minutes + "m"; +} + + function CreateShopStat( Name, Value