Added rotation to plots.. Only does stuff for functional plants.

This commit is contained in:
sarah committed 2026-09-05 16:32:41 +02:00
1 parent 75e4f31ccd
commit 132aba0b9a
14 files changed
+1244 -197

No files matched your search

+81 -3
View File
@@ -1,5 +1,13 @@
let Plants = {};
const PlantDirectionCodes = {
North: "N",
East: "E",
South: "S",
West: "W"
};
async function FetchPlantsFromApi() {
const Response =
@@ -50,7 +58,8 @@ async function FetchPlantsFromApi() {
}
function GetPlantImageSources(
PlantOrKey
PlantOrKey,
Direction = null
) {
const PlantKey =
typeof PlantOrKey === "string"
@@ -86,10 +95,43 @@ function GetPlantImageSources(
? Plant.ImageStages
: [];
const DirectionCode =
typeof Direction === "string"
? (
PlantDirectionCodes[
Direction
] ??
Direction.toUpperCase()
)
: null;
const DirectionalStages =
Plant?.DirectionalSprites === true &&
DirectionCode !== null &&
Array.isArray(
Plant?.DirectionalImageStages
)
? Plant.DirectionalImageStages
.filter(
ImageStage =>
String(
ImageStage?.Direction ??
""
).toUpperCase() ===
DirectionCode
)
: [];
let HighestStage =
StaticImages.length;
for (const ImageStage of ApiStages) {
for (
const ImageStage
of [
...ApiStages,
...DirectionalStages
]
) {
const Stage = Number(
typeof ImageStage === "object" &&
ImageStage !== null
@@ -156,10 +198,46 @@ function GetPlantImageSources(
Query.toString();
}
for (
const ImageStage
of DirectionalStages
) {
const Stage = Number(
ImageStage?.Stage
);
if (
!Number.isInteger(Stage) ||
Stage < 1
) {
continue;
}
const Revision = Number(
ImageStage?.Revision ?? 0
);
const Query =
new URLSearchParams({
PlantId: String(Plant.Id),
Stage: String(Stage),
Direction: DirectionCode,
v: String(
Number.isFinite(Revision)
? Revision
: 0
)
});
Images[Stage - 1] =
ApiUrl +
"/PlantImage.php?" +
Query.toString();
}
return Images;
}
function GetPlantMatureImageSource(
PlantOrKey
) {