mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-14 02:38:12 +02:00
Added plant info upgrade.
This commit is contained in:
1 parent
23cc94dc69
commit
367e34ef18
8 files changed
+733
-10
No files matched your search
+176
-1
@@ -123,7 +123,8 @@ function RenderGardenUpgrades() {
|
||||
),
|
||||
CreateGardenExpansionCard(
|
||||
"Row"
|
||||
)
|
||||
),
|
||||
CreatePlantInformationUpgradeCard()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -270,6 +271,122 @@ function CreateGardenExpansionCard(
|
||||
}
|
||||
|
||||
|
||||
function CreatePlantInformationUpgradeCard() {
|
||||
const Cost =
|
||||
GetPlantInformationUpgradeCost();
|
||||
|
||||
const IsOwned =
|
||||
HasPlantInformationUpgrade(
|
||||
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 =
|
||||
"Plant information";
|
||||
|
||||
Header.appendChild(Name);
|
||||
|
||||
|
||||
const Description =
|
||||
document.createElement(
|
||||
"p"
|
||||
);
|
||||
|
||||
Description.textContent =
|
||||
"Show each plant's name above its sprite and exact time remaining below it. Both displays can be toggled on or off from your Profile.";
|
||||
|
||||
|
||||
const Details =
|
||||
document.createElement(
|
||||
"div"
|
||||
);
|
||||
|
||||
Details.className =
|
||||
"ShopItemDetails";
|
||||
|
||||
Details.append(
|
||||
CreateShopStat(
|
||||
"Plant names",
|
||||
IsOwned
|
||||
? "Unlocked"
|
||||
: "Locked"
|
||||
),
|
||||
CreateShopStat(
|
||||
"Growth timers",
|
||||
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",
|
||||
BuyPlantInformationUpgrade
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Card.append(
|
||||
Header,
|
||||
Description,
|
||||
Details,
|
||||
BuyButton
|
||||
);
|
||||
|
||||
|
||||
return Card;
|
||||
}
|
||||
|
||||
|
||||
function CreateShopSeedCard(
|
||||
Plant
|
||||
) {
|
||||
@@ -839,6 +956,64 @@ async function BuyGardenExpansion(
|
||||
}
|
||||
|
||||
|
||||
async function BuyPlantInformationUpgrade() {
|
||||
if (
|
||||
ShopPurchasePending ||
|
||||
HasPlantInformationUpgrade(
|
||||
ShopSave
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const Cost =
|
||||
GetPlantInformationUpgradeCost();
|
||||
|
||||
if (
|
||||
ShopSave.Currency.Dew <
|
||||
Cost
|
||||
) {
|
||||
SetShopMessage(
|
||||
"You don't have enough Dew for Plant information."
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ShopPurchasePending = true;
|
||||
|
||||
try {
|
||||
ShopSave.Currency.Dew -=
|
||||
Cost;
|
||||
|
||||
ShopSave.Statistics.CurrencySpent.Dew +=
|
||||
Cost;
|
||||
|
||||
UnlockPlantInformation(
|
||||
ShopSave
|
||||
);
|
||||
|
||||
|
||||
SetShopMessage(
|
||||
"Bought Plant information for " +
|
||||
Cost.toLocaleString() +
|
||||
" Dew. Plant names and growth timers are now visible."
|
||||
);
|
||||
|
||||
RenderShop();
|
||||
|
||||
await SaveGame(
|
||||
ShopSave
|
||||
);
|
||||
} finally {
|
||||
ShopPurchasePending = false;
|
||||
RenderShop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function SetShopMessage(
|
||||
Message
|
||||
) {
|
||||
|
||||
Reference in new issue
Block a user