mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-14 10:48:12 +02:00
Added mutation hint upgrade.
This commit is contained in:
1 parent
f37d0a77f9
commit
8f27468b5e
7 files changed
+583
-20
No files matched your search
+174
-1
@@ -125,7 +125,8 @@ function RenderGardenUpgrades() {
|
||||
"Row"
|
||||
),
|
||||
CreatePlantInformationUpgradeCard(),
|
||||
CreateGardenOverviewUpgradeCard()
|
||||
CreateGardenOverviewUpgradeCard(),
|
||||
CreateMutationHintsUpgradeCard()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -504,6 +505,120 @@ function CreateGardenOverviewUpgradeCard() {
|
||||
}
|
||||
|
||||
|
||||
function CreateMutationHintsUpgradeCard() {
|
||||
const Cost =
|
||||
GetMutationHintsUpgradeCost();
|
||||
|
||||
const IsOwned =
|
||||
HasMutationHintsUpgrade(
|
||||
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 =
|
||||
"Mutation hints";
|
||||
|
||||
Header.appendChild(Name);
|
||||
|
||||
|
||||
const Description =
|
||||
document.createElement(
|
||||
"p"
|
||||
);
|
||||
|
||||
Description.textContent =
|
||||
"Show subtle hints for undiscovered mutations once you've discovered the plants needed to attempt them. Hints appear in the Mutation encyclopedia without revealing the recipe.";
|
||||
|
||||
|
||||
const Details =
|
||||
document.createElement(
|
||||
"div"
|
||||
);
|
||||
|
||||
Details.className =
|
||||
"ShopItemDetails";
|
||||
|
||||
Details.append(
|
||||
CreateShopStat(
|
||||
"Mutation hints",
|
||||
IsOwned
|
||||
? "Unlocked"
|
||||
: "Locked"
|
||||
),
|
||||
CreateShopStat(
|
||||
"Requirements",
|
||||
"Required plants discovered"
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
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",
|
||||
BuyMutationHintsUpgrade
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Card.append(
|
||||
Header,
|
||||
Description,
|
||||
Details,
|
||||
BuyButton
|
||||
);
|
||||
|
||||
|
||||
return Card;
|
||||
}
|
||||
|
||||
|
||||
function CreateShopSeedCard(
|
||||
Plant
|
||||
) {
|
||||
@@ -1189,6 +1304,64 @@ async function BuyGardenOverviewUpgrade() {
|
||||
}
|
||||
|
||||
|
||||
async function BuyMutationHintsUpgrade() {
|
||||
if (
|
||||
ShopPurchasePending ||
|
||||
HasMutationHintsUpgrade(
|
||||
ShopSave
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const Cost =
|
||||
GetMutationHintsUpgradeCost();
|
||||
|
||||
if (
|
||||
ShopSave.Currency.Dew <
|
||||
Cost
|
||||
) {
|
||||
SetShopMessage(
|
||||
"You don't have enough Dew for Mutation hints."
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ShopPurchasePending = true;
|
||||
|
||||
try {
|
||||
ShopSave.Currency.Dew -=
|
||||
Cost;
|
||||
|
||||
ShopSave.Statistics.CurrencySpent.Dew +=
|
||||
Cost;
|
||||
|
||||
UnlockMutationHints(
|
||||
ShopSave
|
||||
);
|
||||
|
||||
|
||||
SetShopMessage(
|
||||
"Bought Mutation hints for " +
|
||||
Cost.toLocaleString() +
|
||||
" Dew. Eligible hints are now visible in the Mutation encyclopedia."
|
||||
);
|
||||
|
||||
RenderShop();
|
||||
|
||||
await SaveGame(
|
||||
ShopSave
|
||||
);
|
||||
} finally {
|
||||
ShopPurchasePending = false;
|
||||
RenderShop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function SetShopMessage(
|
||||
Message
|
||||
) {
|
||||
|
||||
Reference in new issue
Block a user