From 0b3905f92f2df9c6b9ebf50b2523b2bb46301894 Mon Sep 17 00:00:00 2001 From: Sarahtonin Date: Sun, 30 Aug 2026 22:21:22 +0200 Subject: [PATCH] Fixed starting player setup (thanks, Eva) Signed-off-by: Sarahtonin --- Scripts/Garden/Economy.js | 4 +- Scripts/Garden/Plants.js | 20 +++++---- Scripts/Garden/Save.js | 85 ++++++++++++++++++++------------------- Scripts/Garden/Shop.js | 4 ++ 4 files changed, 63 insertions(+), 50 deletions(-) diff --git a/Scripts/Garden/Economy.js b/Scripts/Garden/Economy.js index 37a1bc5..edd2860 100644 --- a/Scripts/Garden/Economy.js +++ b/Scripts/Garden/Economy.js @@ -138,7 +138,7 @@ function IsPlantAvailableInShop( Plant ) { if ( - Plant.Shop?.StartingPlant === + Plant.Shop?.ShopPlant === true ) { return true; @@ -226,7 +226,7 @@ function GetPlantShopCost( } if ( - Plant.Shop?.StartingPlant === + Plant.Shop?.ShopPlant === true ) { const BaseCost = Number( diff --git a/Scripts/Garden/Plants.js b/Scripts/Garden/Plants.js index 829d2b1..d4fc741 100644 --- a/Scripts/Garden/Plants.js +++ b/Scripts/Garden/Plants.js @@ -17,7 +17,7 @@ const Plants = { Effects: [], Shop: { - StartingPlant: true, + ShopPlant: true, BaseCost: 10 } }, @@ -40,7 +40,7 @@ const Plants = { Effects: [], Shop: { - StartingPlant: false + ShopPlant: false } }, @@ -48,6 +48,9 @@ const Plants = { Id: 3, Name: "Blue Rose", + Description: + "An uncommon blue rose.", + Tags: [ "Rose", "Flower", @@ -59,7 +62,7 @@ const Plants = { Effects: [], Shop: { - StartingPlant: true, + ShopPlant: true, BaseCost: 15 } }, @@ -68,10 +71,13 @@ const Plants = { Id: 4, Name: "Purple Rose", + Description: + "A rare purple rose.", + Tags: [ - "Rose", - "Flower", - "Purple" + "Rose", + "Flower", + "Purple" ], GrowthTime: 3600000, @@ -79,7 +85,7 @@ const Plants = { Effects: [], Shop: { - StartingPlant: false + ShopPlant: false } } }; diff --git a/Scripts/Garden/Save.js b/Scripts/Garden/Save.js index bdd485f..2be3d65 100644 --- a/Scripts/Garden/Save.js +++ b/Scripts/Garden/Save.js @@ -3,42 +3,40 @@ const LocalSaveName = "SarahtoninGarden"; const ApiUrl = "https://api.srhtnin.garden"; +const StartingDew = 15; + +const StartingSeeds = { + RedRose: 1 +}; + function CreateNewSave() { - const StartingSeeds = {}; + const SeedInventory = {}; const StartingPlants = []; - if ( - typeof Plants !== - "undefined" + for ( + const [ + PlantKey, + Amount + ] + of Object.entries( + StartingSeeds + ) ) { - for ( - const Plant - of Object.values(Plants) - ) { - if ( - Plant.Shop - ?.StartingPlant !== - true - ) { - continue; - } + const Plant = + Plants[PlantKey]; - StartingSeeds[ - String(Plant.Id) - ] = 1; - - StartingPlants.push( - Plant.Id - ); + if (Plant === undefined) { + continue; } - } - if ( - StartingPlants.length === 0 - ) { - StartingSeeds["1"] = 1; - StartingPlants.push(1); + SeedInventory[ + String(Plant.Id) + ] = Amount; + + StartingPlants.push( + Plant.Id + ); } @@ -48,7 +46,7 @@ function CreateNewSave() { LastSavedAt: Date.now(), Currency: { - Dew: 0 + Dew: StartingDew }, Statistics: { @@ -64,7 +62,7 @@ function CreateNewSave() { }, Inventory: { - Seeds: StartingSeeds + Seeds: SeedInventory }, Upgrades: { @@ -340,20 +338,25 @@ function NormalizeSaveData( function GetStartingPlantDefinitions() { - if ( - typeof Plants === - "undefined" + const StartingPlants = []; + + for ( + const PlantKey + of Object.keys( + StartingSeeds + ) ) { - return []; + const Plant = + Plants[PlantKey]; + + if (Plant !== undefined) { + StartingPlants.push( + Plant + ); + } } - return Object.values(Plants) - .filter( - Plant => - Plant.Shop - ?.StartingPlant === - true - ); + return StartingPlants; } diff --git a/Scripts/Garden/Shop.js b/Scripts/Garden/Shop.js index d37ea7c..ddf096a 100644 --- a/Scripts/Garden/Shop.js +++ b/Scripts/Garden/Shop.js @@ -461,6 +461,10 @@ async function BuyPlantSeed( PlantId ); + DiscoverPlant( + ShopSave, + PlantId + ); SetShopMessage( "Bought a " +