Message

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

function harvestAll() {

let harvestCount = 0;
for (let i = 0; i < newFarmingAreas[currentFarmingArea].patches.length; i++) {
if (newFarmingAreas[currentFarmingArea].patches[i].hasGrown) {
harvestSeed(currentFarmingArea, i);
harvestCount++;
}
}
}

function compostAll() {
for (let i = 0; i < newFarmingAreas[currentFarmingArea].patches.length; i++) {
if (newFarmingAreas[currentFarmingArea].patches[i].unlocked &&
newFarmingAreas[currentFarmingArea].patches[i].seedID === 0 &&
newFarmingAreas[currentFarmingArea].patches[i].compost < 100 &&
newFarmingAreas[currentFarmingArea].patches[i].timePlanted === 0 &&
(checkBankForItem(CONSTANTS.item.Compost) ||
equippedItems.includes(CONSTANTS.item.Farming_Skillcape))) {
addCompost(currentFarmingArea, i, 5);
}
}
updateCompostQty();

// saveData();
}

function gloopAll() {
for (let i = 0; i < newFarmingAreas[currentFarmingArea].patches.length; i++) {
if (newFarmingAreas[currentFarmingArea].patches[i].unlocked &&
newFarmingAreas[currentFarmingArea].patches[i].seedID === 0 &&
newFarmingAreas[currentFarmingArea].patches[i].compost < 100 &&
newFarmingAreas[currentFarmingArea].patches[i].timePlanted === 0 &&
(checkBankForItem(CONSTANTS.item.Weird_Gloop))) {
addGloop(currentFarmingArea, i);
}
}
updateCompostQty();

// saveData();
}

function plantSeed(plantAll = false) {


if (!plantAll) {
const findItem = checkBankForItem(selectedSeed);
if (findItem) {
const bankID = getBankId(selectedSeed);
if (bank[bankID].qty >= items[selectedSeed].seedsRequired) {
updateItemInBank(bankID, selectedSeed, 0 -
items[selectedSeed].seedsRequired);
const currentTime = new Date().getTime();
newFarmingAreas[selectedPatch[0]].patches[selectedPatch[1]].seedID
= selectedSeed;

newFarmingAreas[selectedPatch[0]].patches[selectedPatch[1]].timePlanted =
currentTime;
startSeedTimer(selectedPatch[0], selectedPatch[1]);
if (items[selectedSeed].tier != 'Tree') {
addXP(CONSTANTS.skill.Farming, items[selectedSeed].farmingXP);
}
updateSkillWindow(CONSTANTS.skill.Farming);

// saveData();
loadFarmingArea(selectedPatch[0]);
} else {
notifyPlayer(CONSTANTS.skill.Farming, "You don't have enough
seeds", 'danger');
}
}
} else {
for (let i = 0; i < newFarmingAreas[currentFarmingArea].patches.length; i+
+) {
if (newFarmingAreas[currentFarmingArea].patches[i].seedID === 0 &&
newFarmingAreas[currentFarmingArea].patches[i].unlocked) {
const findItem = checkBankForItem(selectedSeed);
if (findItem) {
const bankID = getBankId(selectedSeed);
if (bank[bankID].qty >= items[selectedSeed].seedsRequired) {
updateItemInBank(bankID, selectedSeed, 0 -
items[selectedSeed].seedsRequired);
const currentTime = new Date().getTime();
newFarmingAreas[currentFarmingArea].patches[i].seedID =
selectedSeed;
newFarmingAreas[currentFarmingArea].patches[i].timePlanted
= currentTime;
startSeedTimer(currentFarmingArea, i);
if (items[selectedSeed].tier != 'Tree') {
addXP(CONSTANTS.skill.Farming,
items[selectedSeed].farmingXP);
}
updateSkillWindow(CONSTANTS.skill.Farming);

// saveData();
} else {
notifyPlayer(CONSTANTS.skill.Farming, "You don't have
enough seeds", 'danger');
break;
}
}
}
}
loadFarmingArea(currentFarmingArea);
}
}

You might also like