Bug found, when removing the second-to-last card in a deck, when cost should be 500 tnt, the resource pool of TNT becomes 0. In effect, 500 cost wipes all resource.
Numbers would work better.
const cost = Number(getDestroyCost());
and then complete function as normal. [pointing to costs, not loose string value]:
function onDestroyCardClick() {
const cost = Number(getDestroyCost());
if (resources.tnt >= cost) {
if (!tryRemoveCard(this.dataset, pile.deck)) {
tryRemoveCard(this.dataset, pile.discard);
}
adjustResource('tnt', -cost);
this.classList.add('destroyed');
this.onclick = null;
}
}
Small issue/glitch, but worth noting in case you wanted to refine. This simple game would be effective on the app market, worth reviewing.