Fix bug with storing locked buildings

This commit is contained in:
Daniël van Noord
2021-07-25 14:41:51 +02:00
parent 9996e59024
commit 65eff470cf

View File

@@ -4,18 +4,30 @@
*/ */
export default function toggleBuildingLock(index) { export default function toggleBuildingLock(index) {
if (l(`productLock${index}`).innerHTML === 'Lock') { if (l(`productLock${index}`).innerHTML === 'Lock') {
// Add to storing array
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames.push( Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames.push(
index.toString(), index.toString(),
); );
// Update styles
l(`row${index}`).style.pointerEvents = 'none'; l(`row${index}`).style.pointerEvents = 'none';
l(`row${index}`).style.opacity = '0.4'; l(`row${index}`).style.opacity = '0.4';
l(`productLock${index}`).innerHTML = 'Unlock'; l(`productLock${index}`).innerHTML = 'Unlock';
l(`productLock${index}`).style.pointerEvents = 'auto'; l(`productLock${index}`).style.pointerEvents = 'auto';
} else { } else {
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames = // Remove from storing array
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames.filter( if (
(value) => value !== index.toString(), Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames.includes(
); index.toString(),
)
) {
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames =
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.lockedMinigames.filter(
(value) => value !== index.toString(),
);
}
// Update styles
l(`productLock${index}`).innerHTML = 'Lock'; l(`productLock${index}`).innerHTML = 'Lock';
l(`row${index}`).style.pointerEvents = 'auto'; l(`row${index}`).style.pointerEvents = 'auto';
l(`row${index}`).style.opacity = '1'; l(`row${index}`).style.opacity = '1';