mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-13 18:38:11 +02:00
Added growthtime to shop plant card.
This commit is contained in:
1 parent
0729d9e402
commit
5c8d0c79cd
1 file changed
+56
-6
+56
-6
@@ -111,11 +111,6 @@ function CreateShopSeedCard(
|
||||
"ShopItemHeader";
|
||||
|
||||
|
||||
const Number =
|
||||
document.createElement(
|
||||
"span"
|
||||
);
|
||||
|
||||
const Name =
|
||||
document.createElement(
|
||||
"h3"
|
||||
@@ -156,7 +151,7 @@ function CreateShopSeedCard(
|
||||
|
||||
if (
|
||||
typeof Plant.Description ===
|
||||
"string" &&
|
||||
"string" &&
|
||||
Plant.Description.length > 0
|
||||
) {
|
||||
const Description =
|
||||
@@ -173,6 +168,16 @@ function CreateShopSeedCard(
|
||||
}
|
||||
|
||||
|
||||
Details.appendChild(
|
||||
CreateShopStat(
|
||||
"Growth time",
|
||||
FormatShopGrowthTime(
|
||||
Plant.GrowthTime
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const Cost =
|
||||
GetPlantShopCost(
|
||||
ShopSave,
|
||||
@@ -366,6 +371,51 @@ function CreateShopPlantVisual(
|
||||
}
|
||||
|
||||
|
||||
function FormatShopGrowthTime(
|
||||
Milliseconds
|
||||
) {
|
||||
const TotalMinutes =
|
||||
Math.max(
|
||||
1,
|
||||
Math.ceil(
|
||||
Number(
|
||||
Milliseconds
|
||||
) /
|
||||
60000
|
||||
)
|
||||
);
|
||||
|
||||
const Hours =
|
||||
Math.floor(
|
||||
TotalMinutes /
|
||||
60
|
||||
);
|
||||
|
||||
const Minutes =
|
||||
TotalMinutes %
|
||||
60;
|
||||
|
||||
|
||||
if (
|
||||
Hours > 0 &&
|
||||
Minutes > 0
|
||||
) {
|
||||
return (
|
||||
Hours +
|
||||
"h " +
|
||||
Minutes +
|
||||
"m"
|
||||
);
|
||||
}
|
||||
|
||||
if (Hours > 0) {
|
||||
return Hours + "h";
|
||||
}
|
||||
|
||||
return Minutes + "m";
|
||||
}
|
||||
|
||||
|
||||
function CreateShopStat(
|
||||
Name,
|
||||
Value
|
||||
|
||||
Reference in new issue
Block a user