Added mutation engine (so stuff actually mutates), and added a shovel

(to dig up plants).

Signed-off-by: Sarahtonin <[email protected]>
This commit is contained in:
sarah committed 2026-08-30 21:38:23 +02:00
1 parent 97204f2d3f
commit 2c1f3851e8
6 files changed
+1551 -16

No files matched your search

+15
View File
@@ -56,6 +56,20 @@ $SubNavbarCurrent = "Garden";
id="SeedList" id="SeedList"
class="SeedList" class="SeedList"
></div> ></div>
<h3 class="GardenToolHeading">
Tools
</h3>
<div class="ToolList">
<button
id="ShovelToolButton"
class="ToolButton ToolButtonShovel"
type="button"
>
Shovel
</button>
</div>
</section> </section>
</div> </div>
@@ -134,6 +148,7 @@ $SubNavbarCurrent = "Garden";
<script src="/Scripts/Garden/Mutations.js"></script> <script src="/Scripts/Garden/Mutations.js"></script>
<script src="/Scripts/Garden/Save.js"></script> <script src="/Scripts/Garden/Save.js"></script>
<script src="/Scripts/Garden/Economy.js"></script> <script src="/Scripts/Garden/Economy.js"></script>
<script src="/Scripts/Garden/MutationEngine.js"></script>
<script src="/Scripts/Garden/Users.js"></script> <script src="/Scripts/Garden/Users.js"></script>
<script src="/Scripts/Garden/Leaderboard.js"></script> <script src="/Scripts/Garden/Leaderboard.js"></script>
<script src="/Scripts/Garden/Garden.js"></script> <script src="/Scripts/Garden/Garden.js"></script>
+2 -1
View File
@@ -356,7 +356,8 @@ function GetMutationIngredientCost(
) { ) {
if ( if (
Matcher === null || Matcher === null ||
Matcher === "Empty" Matcher === "Empty" ||
Matcher === "Any"
) { ) {
continue; continue;
} }
+184 -13
View File
@@ -1,5 +1,8 @@
let GameSave; let GameSave;
let SelectedSeedId = null; let SelectedSeedId = null;
let SelectedGardenTool = "Seed";
let MutationCheckPending = false;
const GardenUpdateInterval = 1000; const GardenUpdateInterval = 1000;
@@ -7,14 +10,24 @@ const GardenUpdateInterval = 1000;
async function StartGame() { async function StartGame() {
GameSave = await LoadGame(); GameSave = await LoadGame();
BindGardenTools();
EnsureSelectedSeed(); EnsureSelectedSeed();
const InitialMutationResult =
CheckGardenMutations(
GameSave
);
RenderGame(); RenderGame();
if (InitialMutationResult.Attempted) {
await SaveGame(
GameSave
);
}
setInterval( setInterval(
() => { GardenTick,
RenderGarden();
RenderNextHarvest();
},
GardenUpdateInterval GardenUpdateInterval
); );
@@ -27,11 +40,62 @@ function RenderGame() {
EnsureSelectedSeed(); EnsureSelectedSeed();
RenderCurrency(); RenderCurrency();
RenderSeeds(); RenderSeeds();
RenderTools();
RenderGarden(); RenderGarden();
RenderNextHarvest(); RenderNextHarvest();
} }
function BindGardenTools() {
const ShovelButton =
document.getElementById(
"ShovelToolButton"
);
if (ShovelButton === null) {
return;
}
ShovelButton.addEventListener(
"click",
() => {
SelectedGardenTool =
"Shovel";
RenderSeeds();
RenderTools();
RenderGarden();
}
);
}
function RenderTools() {
const ShovelButton =
document.getElementById(
"ShovelToolButton"
);
if (ShovelButton === null) {
return;
}
if (
SelectedGardenTool ===
"Shovel"
) {
ShovelButton.setAttribute(
"aria-current",
"true"
);
} else {
ShovelButton.removeAttribute(
"aria-current"
);
}
}
function RenderCurrency() { function RenderCurrency() {
const DewAmount = const DewAmount =
document.getElementById( document.getElementById(
@@ -178,8 +242,10 @@ function RenderSeeds() {
); );
if ( if (
SelectedGardenTool ===
"Seed" &&
PlantId === PlantId ===
SelectedSeedId SelectedSeedId
) { ) {
Button.setAttribute( Button.setAttribute(
"aria-current", "aria-current",
@@ -190,10 +256,15 @@ function RenderSeeds() {
Button.addEventListener( Button.addEventListener(
"click", "click",
() => { () => {
SelectedGardenTool =
"Seed";
SelectedSeedId = SelectedSeedId =
PlantId; PlantId;
RenderSeeds(); RenderSeeds();
RenderTools();
RenderGarden();
SetGardenMessage( SetGardenMessage(
"Selected " + "Selected " +
@@ -262,14 +333,19 @@ function CreatePlotElement(
Button.title = Button.title =
"Empty plot"; "Empty plot";
Button.addEventListener( if (
"click", SelectedGardenTool ===
() => { "Seed"
PlantSeed( ) {
PlotIndex Button.addEventListener(
); "click",
} () => {
); PlantSeed(
PlotIndex
);
}
);
}
return Button; return Button;
} }
@@ -327,6 +403,31 @@ function CreatePlotElement(
} }
if (
SelectedGardenTool ===
"Shovel"
) {
Button.classList.add(
"GardenPlotRemove"
);
Button.title =
"Remove " +
Plant.Name;
Button.addEventListener(
"click",
() => {
RemovePlant(
PlotIndex
);
}
);
return Button;
}
if ( if (
IsPlantMature( IsPlantMature(
Plot, Plot,
@@ -437,6 +538,10 @@ async function PlantSeed(
"." "."
); );
CheckGardenMutations(
GameSave
);
RenderGame(); RenderGame();
await SaveGame( await SaveGame(
@@ -506,6 +611,10 @@ async function HarvestPlant(
" Dew." " Dew."
); );
CheckGardenMutations(
GameSave
);
RenderGame(); RenderGame();
await SaveGame( await SaveGame(
@@ -514,6 +623,68 @@ async function HarvestPlant(
} }
async function RemovePlant(
PlotIndex
) {
if (
GameSave.Garden.Plots[
PlotIndex
] === null
) {
return;
}
GameSave.Garden.Plots[
PlotIndex
] = null;
CheckGardenMutations(
GameSave
);
RenderGame();
await SaveGame(
GameSave
);
}
async function GardenTick() {
RenderGarden();
RenderNextHarvest();
if (MutationCheckPending) {
return;
}
MutationCheckPending = true;
try {
const MutationResult =
CheckGardenMutations(
GameSave
);
if (MutationResult.Attempted) {
RenderGame();
await SaveGame(
GameSave
);
}
} finally {
MutationCheckPending = false;
}
}
function GiveReward( function GiveReward(
Reward Reward
) { ) {
File diff suppressed because it is too large. Load diff
+6
View File
@@ -6,6 +6,9 @@ const MutationSets = {
Description: Description:
"A mutation that seems to corrupt roses.", "A mutation that seems to corrupt roses.",
Priority: 10,
Rotation: "Any",
Chance: 0.1, Chance: 0.1,
Cooldown: 120000, Cooldown: 120000,
@@ -59,6 +62,9 @@ const MutationSets = {
Description: Description:
"A colourful mutation that makes a purple rose.", "A colourful mutation that makes a purple rose.",
Priority: 20,
Rotation: "Any",
Chance: 1.0, Chance: 1.0,
Cooldown: 100000, Cooldown: 100000,
+64 -2
View File
@@ -501,6 +501,66 @@ select {
border-color: var(--Green); border-color: var(--Green);
} }
.GardenToolHeading {
margin-top: 1rem;
margin-bottom: 0.5rem;
color: var(--Peach);
}
.ToolList {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.ToolButton {
width: 100%;
padding: 0.6rem;
cursor: pointer;
color: var(--Text);
background-color: var(--Surface0);
border: 3px solid var(--Surface2);
border-radius: 0;
box-shadow:
3px 3px 0
var(--Crust);
appearance: none;
}
.ToolButton:hover {
color: var(--Sky);
background-color: var(--Surface1);
border-color: var(--Sky);
transform:
translate(
1px,
1px
);
box-shadow:
2px 2px 0
var(--Crust);
}
.ToolButtonShovel[aria-current="true"] {
color: var(--Red);
background-color: var(--Surface1);
border-color: var(--Red);
}
.GardenPlotRemove:hover {
border-color: var(--Red);
}
#GardenMessage { #GardenMessage {
margin-top: 1rem; margin-top: 1rem;
margin-bottom: 0; margin-bottom: 0;
@@ -1016,12 +1076,14 @@ select {
grid-row: 1; grid-row: 1;
} }
.SeedList { .SeedList,
.ToolList {
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
} }
.SeedButton { .SeedButton,
.ToolButton {
width: auto; width: auto;
} }