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
@@ -1114,6 +1114,7 @@ function RenderGardenUpgrades() {
|
||||
"Row"
|
||||
),
|
||||
CreateNewGardenCard(),
|
||||
CreateRotationUpgradeCard(),
|
||||
CreatePlantInformationUpgradeCard(),
|
||||
CreateGardenOverviewUpgradeCard(),
|
||||
CreateGardenEconomyUpgradeCard(),
|
||||
@@ -1377,6 +1378,117 @@ function CreateNewGardenCard() {
|
||||
}
|
||||
|
||||
|
||||
function CreateRotationUpgradeCard() {
|
||||
const Cost =
|
||||
GetRotationUpgradeCost();
|
||||
|
||||
const IsOwned =
|
||||
HasRotationUpgrade(
|
||||
ShopSave
|
||||
);
|
||||
|
||||
const Card =
|
||||
document.createElement(
|
||||
"article"
|
||||
);
|
||||
|
||||
Card.className =
|
||||
"Panel ShopItem";
|
||||
|
||||
const Header =
|
||||
document.createElement(
|
||||
"div"
|
||||
);
|
||||
|
||||
Header.className =
|
||||
"PanelHeader PanelHeaderInset ShopItemHeader" +
|
||||
(
|
||||
IsOwned
|
||||
? " ShopItemHeaderOwned"
|
||||
: ""
|
||||
);
|
||||
|
||||
const Name =
|
||||
document.createElement(
|
||||
"h3"
|
||||
);
|
||||
|
||||
Name.textContent =
|
||||
"Plot rotation";
|
||||
|
||||
Header.appendChild(Name);
|
||||
|
||||
const Description =
|
||||
document.createElement(
|
||||
"p"
|
||||
);
|
||||
|
||||
Description.textContent =
|
||||
"Rotate planted plots clockwise. Direction is stored per plot and can be shown beside the plot timer.";
|
||||
|
||||
const Details =
|
||||
document.createElement(
|
||||
"div"
|
||||
);
|
||||
|
||||
Details.className =
|
||||
"ShopItemDetails";
|
||||
|
||||
Details.append(
|
||||
CreateShopStat(
|
||||
"Current",
|
||||
IsOwned
|
||||
? "Rotation unlocked"
|
||||
: "Rotation locked"
|
||||
),
|
||||
CreateShopStat(
|
||||
"Next",
|
||||
IsOwned
|
||||
? "Purchased"
|
||||
: "Rotation controls"
|
||||
)
|
||||
);
|
||||
|
||||
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",
|
||||
BuyRotationUpgrade
|
||||
);
|
||||
}
|
||||
|
||||
Card.append(
|
||||
Header,
|
||||
Description,
|
||||
Details,
|
||||
BuyButton
|
||||
);
|
||||
|
||||
return Card;
|
||||
}
|
||||
|
||||
|
||||
function CreatePlantInformationUpgradeCard() {
|
||||
const Cost =
|
||||
GetPlantInformationUpgradeCost();
|
||||
@@ -2854,6 +2966,55 @@ async function BuyNewGarden() {
|
||||
}
|
||||
|
||||
|
||||
async function BuyRotationUpgrade() {
|
||||
if (
|
||||
ShopPurchasePending ||
|
||||
HasRotationUpgrade(
|
||||
ShopSave
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Cost =
|
||||
GetRotationUpgradeCost();
|
||||
|
||||
if (ShopSave.Currency.Dew < Cost) {
|
||||
SetShopMessage(
|
||||
"You don't have enough Dew for Plot rotation."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
ShopPurchasePending = true;
|
||||
|
||||
try {
|
||||
ShopSave.Currency.Dew -= Cost;
|
||||
ShopSave.Statistics.CurrencySpent.Dew +=
|
||||
Cost;
|
||||
|
||||
UnlockRotation(
|
||||
ShopSave
|
||||
);
|
||||
|
||||
SetShopMessage(
|
||||
"Bought Plot rotation for " +
|
||||
Cost.toLocaleString() +
|
||||
" Dew. Rotation controls are now visible on planted plots."
|
||||
);
|
||||
|
||||
RenderShop();
|
||||
|
||||
await SaveGame(
|
||||
ShopSave
|
||||
);
|
||||
} finally {
|
||||
ShopPurchasePending = false;
|
||||
RenderShop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function BuyPlantInformationUpgrade() {
|
||||
if (
|
||||
ShopPurchasePending ||
|
||||
|
||||
Reference in new issue
Block a user