mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-14 02:38:12 +02:00
104 lines
1.6 KiB
JavaScript
104 lines
1.6 KiB
JavaScript
const GardenExpansionBaseCost = 1000;
|
|
|
|
|
|
function GetGardenColumnUpgradeCost(
|
|
SaveData
|
|
) {
|
|
return CalculateGardenExpansionCost(
|
|
SaveData.Garden.Height
|
|
);
|
|
}
|
|
|
|
|
|
function GetGardenRowUpgradeCost(
|
|
SaveData
|
|
) {
|
|
return CalculateGardenExpansionCost(
|
|
SaveData.Garden.Width
|
|
);
|
|
}
|
|
|
|
|
|
function CalculateGardenExpansionCost(
|
|
AddedPlots
|
|
) {
|
|
const PlotCount = Math.max(
|
|
1,
|
|
Math.floor(
|
|
Number(AddedPlots) || 1
|
|
)
|
|
);
|
|
|
|
return Math.round(
|
|
GardenExpansionBaseCost *
|
|
PlotCount *
|
|
(1 + PlotCount / 10)
|
|
);
|
|
}
|
|
|
|
|
|
function AddGardenColumn(
|
|
SaveData
|
|
) {
|
|
const Garden = SaveData.Garden;
|
|
const OldWidth = Garden.Width;
|
|
const Height = Garden.Height;
|
|
const NewWidth = OldWidth + 1;
|
|
|
|
const NewPlots = Array(
|
|
NewWidth * Height
|
|
).fill(null);
|
|
|
|
|
|
for (
|
|
let Y = 0;
|
|
Y < Height;
|
|
Y++
|
|
) {
|
|
for (
|
|
let X = 0;
|
|
X < OldWidth;
|
|
X++
|
|
) {
|
|
NewPlots[
|
|
Y * NewWidth + X
|
|
] = Garden.Plots[
|
|
Y * OldWidth + X
|
|
] ?? null;
|
|
}
|
|
}
|
|
|
|
|
|
Garden.Width = NewWidth;
|
|
Garden.Plots = NewPlots;
|
|
|
|
ResetGardenMutationCooldowns(
|
|
SaveData
|
|
);
|
|
}
|
|
|
|
|
|
function AddGardenRow(
|
|
SaveData
|
|
) {
|
|
const Garden = SaveData.Garden;
|
|
const Width = Garden.Width;
|
|
|
|
Garden.Height++;
|
|
|
|
Garden.Plots.push(
|
|
...Array(Width).fill(null)
|
|
);
|
|
|
|
ResetGardenMutationCooldowns(
|
|
SaveData
|
|
);
|
|
}
|
|
|
|
|
|
function ResetGardenMutationCooldowns(
|
|
SaveData
|
|
) {
|
|
SaveData.MutationCooldowns = {};
|
|
}
|