mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-14 18:58:11 +02:00
Added rotation to plots.. Only does stuff for functional plants.
This commit is contained in:
1 parent
75e4f31ccd
commit
132aba0b9a
14 files changed
+1244
-197
No files matched your search
@@ -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
|
||||
) {
|
||||
|
||||
Reference in new issue
Block a user