Fixed starting player setup (thanks, Eva)

Signed-off-by: Sarahtonin <[email protected]>
This commit is contained in:
sarah committed 2026-08-30 22:21:22 +02:00
1 parent 2fe5171450
commit 0b3905f92f
4 files changed
+54 -41

No files matched your search

+2 -2
View File
@@ -138,7 +138,7 @@ function IsPlantAvailableInShop(
Plant Plant
) { ) {
if ( if (
Plant.Shop?.StartingPlant === Plant.Shop?.ShopPlant ===
true true
) { ) {
return true; return true;
@@ -226,7 +226,7 @@ function GetPlantShopCost(
} }
if ( if (
Plant.Shop?.StartingPlant === Plant.Shop?.ShopPlant ===
true true
) { ) {
const BaseCost = Number( const BaseCost = Number(
+10 -4
View File
@@ -17,7 +17,7 @@ const Plants = {
Effects: [], Effects: [],
Shop: { Shop: {
StartingPlant: true, ShopPlant: true,
BaseCost: 10 BaseCost: 10
} }
}, },
@@ -40,7 +40,7 @@ const Plants = {
Effects: [], Effects: [],
Shop: { Shop: {
StartingPlant: false ShopPlant: false
} }
}, },
@@ -48,6 +48,9 @@ const Plants = {
Id: 3, Id: 3,
Name: "Blue Rose", Name: "Blue Rose",
Description:
"An uncommon blue rose.",
Tags: [ Tags: [
"Rose", "Rose",
"Flower", "Flower",
@@ -59,7 +62,7 @@ const Plants = {
Effects: [], Effects: [],
Shop: { Shop: {
StartingPlant: true, ShopPlant: true,
BaseCost: 15 BaseCost: 15
} }
}, },
@@ -68,6 +71,9 @@ const Plants = {
Id: 4, Id: 4,
Name: "Purple Rose", Name: "Purple Rose",
Description:
"A rare purple rose.",
Tags: [ Tags: [
"Rose", "Rose",
"Flower", "Flower",
@@ -79,7 +85,7 @@ const Plants = {
Effects: [], Effects: [],
Shop: { Shop: {
StartingPlant: false ShopPlant: false
} }
} }
}; };
+38 -35
View File
@@ -3,43 +3,41 @@ const LocalSaveName = "SarahtoninGarden";
const ApiUrl = "https://api.srhtnin.garden"; const ApiUrl = "https://api.srhtnin.garden";
const StartingDew = 15;
const StartingSeeds = {
RedRose: 1
};
function CreateNewSave() { function CreateNewSave() {
const StartingSeeds = {}; const SeedInventory = {};
const StartingPlants = []; const StartingPlants = [];
if (
typeof Plants !==
"undefined"
) {
for ( for (
const Plant const [
of Object.values(Plants) PlantKey,
) { Amount
if ( ]
Plant.Shop of Object.entries(
?.StartingPlant !== StartingSeeds
true )
) { ) {
const Plant =
Plants[PlantKey];
if (Plant === undefined) {
continue; continue;
} }
StartingSeeds[ SeedInventory[
String(Plant.Id) String(Plant.Id)
] = 1; ] = Amount;
StartingPlants.push( StartingPlants.push(
Plant.Id Plant.Id
); );
} }
}
if (
StartingPlants.length === 0
) {
StartingSeeds["1"] = 1;
StartingPlants.push(1);
}
return { return {
@@ -48,7 +46,7 @@ function CreateNewSave() {
LastSavedAt: Date.now(), LastSavedAt: Date.now(),
Currency: { Currency: {
Dew: 0 Dew: StartingDew
}, },
Statistics: { Statistics: {
@@ -64,7 +62,7 @@ function CreateNewSave() {
}, },
Inventory: { Inventory: {
Seeds: StartingSeeds Seeds: SeedInventory
}, },
Upgrades: { Upgrades: {
@@ -340,20 +338,25 @@ function NormalizeSaveData(
function GetStartingPlantDefinitions() { function GetStartingPlantDefinitions() {
if ( const StartingPlants = [];
typeof Plants ===
"undefined" for (
const PlantKey
of Object.keys(
StartingSeeds
)
) { ) {
return []; const Plant =
Plants[PlantKey];
if (Plant !== undefined) {
StartingPlants.push(
Plant
);
}
} }
return Object.values(Plants) return StartingPlants;
.filter(
Plant =>
Plant.Shop
?.StartingPlant ===
true
);
} }
+4
View File
@@ -461,6 +461,10 @@ async function BuyPlantSeed(
PlantId PlantId
); );
DiscoverPlant(
ShopSave,
PlantId
);
SetShopMessage( SetShopMessage(
"Bought a " + "Bought a " +