mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-14 10:48:12 +02:00
Added better info display upgrade.
This commit is contained in:
1 parent
11be2c8a52
commit
64807f3c7a
9 files changed
+855
-96
No files matched your search
+176
-1
@@ -124,7 +124,8 @@ function RenderGardenUpgrades() {
|
||||
CreateGardenExpansionCard(
|
||||
"Row"
|
||||
),
|
||||
CreatePlantInformationUpgradeCard()
|
||||
CreatePlantInformationUpgradeCard(),
|
||||
CreateGardenOverviewUpgradeCard()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -387,6 +388,122 @@ function CreatePlantInformationUpgradeCard() {
|
||||
}
|
||||
|
||||
|
||||
function CreateGardenOverviewUpgradeCard() {
|
||||
const Cost =
|
||||
GetGardenOverviewUpgradeCost();
|
||||
|
||||
const IsOwned =
|
||||
HasGardenOverviewUpgrade(
|
||||
ShopSave
|
||||
);
|
||||
|
||||
|
||||
const Card =
|
||||
document.createElement(
|
||||
"article"
|
||||
);
|
||||
|
||||
Card.className =
|
||||
"Panel ShopItem";
|
||||
|
||||
|
||||
const Header =
|
||||
document.createElement(
|
||||
"div"
|
||||
);
|
||||
|
||||
Header.className =
|
||||
"ShopItemHeader";
|
||||
|
||||
|
||||
const Name =
|
||||
document.createElement(
|
||||
"h3"
|
||||
);
|
||||
|
||||
Name.textContent =
|
||||
"Garden overview";
|
||||
|
||||
Header.appendChild(Name);
|
||||
|
||||
|
||||
const Description =
|
||||
document.createElement(
|
||||
"p"
|
||||
);
|
||||
|
||||
Description.textContent =
|
||||
"Expand the Garden status box with detailed plot counts and the name of the next plant ready to harvest. Every overview line can be toggled on/off from the profile page.";
|
||||
|
||||
|
||||
const Details =
|
||||
document.createElement(
|
||||
"div"
|
||||
);
|
||||
|
||||
Details.className =
|
||||
"ShopItemDetails";
|
||||
|
||||
Details.append(
|
||||
CreateShopStat(
|
||||
"Garden details",
|
||||
IsOwned
|
||||
? "Unlocked"
|
||||
: "Locked"
|
||||
),
|
||||
CreateShopStat(
|
||||
"Profile controls",
|
||||
IsOwned
|
||||
? "Unlocked"
|
||||
: "Locked"
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const BuyButton =
|
||||
document.createElement(
|
||||
"button"
|
||||
);
|
||||
|
||||
BuyButton.className =
|
||||
"ActionButton ShopBuyButton";
|
||||
|
||||
BuyButton.type = "button";
|
||||
|
||||
if (IsOwned) {
|
||||
BuyButton.textContent =
|
||||
"Purchased";
|
||||
|
||||
BuyButton.disabled = true;
|
||||
} else {
|
||||
BuyButton.textContent =
|
||||
"Buy - " +
|
||||
Cost.toLocaleString() +
|
||||
" Dew";
|
||||
|
||||
BuyButton.disabled =
|
||||
ShopSave.Currency.Dew < Cost ||
|
||||
ShopPurchasePending;
|
||||
|
||||
BuyButton.addEventListener(
|
||||
"click",
|
||||
BuyGardenOverviewUpgrade
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Card.append(
|
||||
Header,
|
||||
Description,
|
||||
Details,
|
||||
BuyButton
|
||||
);
|
||||
|
||||
|
||||
return Card;
|
||||
}
|
||||
|
||||
|
||||
function CreateShopSeedCard(
|
||||
Plant
|
||||
) {
|
||||
@@ -1014,6 +1131,64 @@ async function BuyPlantInformationUpgrade() {
|
||||
}
|
||||
|
||||
|
||||
async function BuyGardenOverviewUpgrade() {
|
||||
if (
|
||||
ShopPurchasePending ||
|
||||
HasGardenOverviewUpgrade(
|
||||
ShopSave
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const Cost =
|
||||
GetGardenOverviewUpgradeCost();
|
||||
|
||||
if (
|
||||
ShopSave.Currency.Dew <
|
||||
Cost
|
||||
) {
|
||||
SetShopMessage(
|
||||
"You don't have enough Dew for Garden overview."
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ShopPurchasePending = true;
|
||||
|
||||
try {
|
||||
ShopSave.Currency.Dew -=
|
||||
Cost;
|
||||
|
||||
ShopSave.Statistics.CurrencySpent.Dew +=
|
||||
Cost;
|
||||
|
||||
UnlockGardenOverview(
|
||||
ShopSave
|
||||
);
|
||||
|
||||
|
||||
SetShopMessage(
|
||||
"Bought Garden overview for " +
|
||||
Cost.toLocaleString() +
|
||||
" Dew. All overview lines are now visible."
|
||||
);
|
||||
|
||||
RenderShop();
|
||||
|
||||
await SaveGame(
|
||||
ShopSave
|
||||
);
|
||||
} finally {
|
||||
ShopPurchasePending = false;
|
||||
RenderShop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function SetShopMessage(
|
||||
Message
|
||||
) {
|
||||
|
||||
Reference in new issue
Block a user