Skip to content

Instantly share code, notes, and snippets.

@mys721tx
Created January 4, 2021 04:04
Show Gist options
  • Save mys721tx/7d40654cb13b91227ad7f63fed8af158 to your computer and use it in GitHub Desktop.
Save mys721tx/7d40654cb13b91227ad7f63fed8af158 to your computer and use it in GitHub Desktop.
Kitten Game
can_build = (b) => {
c = gamePage.bld.getPrices(b).map(
(p) => {
if (!gamePage.resPool.get(p.name).unlocked) {
return false
}
if (gamePage.resPool.get(p.name).maxValue === 0) {
if (gamePage.bld.get(b).val < 200) {
return true
}
return false
}
return gamePage.resPool.get(p.name).maxValue > p.val
}
).every(Boolean);
c &&= gamePage.bld.get(b).unlocked;
c &&= gamePage.bld.get(b).val > 0;
return c;
};
for (i in gamePage.bld.buildingsData) {
bld = gamePage.bld.buildingsData[i].name;
if (can_build(bld)) {
gamePage.bld.get(bld).val += 1;
gamePage.bld.get(bld).on = gamePage.bld.get(bld).val;
}
}
for (i in gamePage.resPool.resourceMap) {
if (gamePage.resPool.get(i).unlocked ) {
if (gamePage.resPool.get(i).maxValue) {
gamePage.resPool.get(i).value = gamePage.resPool.get(i).maxValue;
} else {
gamePage.resPool.get(i).value = 10e9;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment