Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions frontend/src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,7 @@
};

const clickPack = (card) => {
if (!App.state.gameState.isPick(card.cardId)) {
App.state.gameState.updateCardPick(card.cardId, App.state.picksPerPack);

Check failure on line 336 in frontend/src/events.js

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected indentation of 2 spaces but found 4
} else if (App.state.gameState.isSelectionReady(App.state.picksPerPack, App.state.game.burnsPerPack)) {
App.state.gameState.resetPack();
App.update();
App.send("confirmSelection");
}
};

const hash = () => {
Expand Down
37 changes: 21 additions & 16 deletions frontend/src/gamestate.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,17 @@
}

updateCardPick(cardId, picksPerPack) {
if (this.#pickCardIds.length == picksPerPack) {
this.#pickCardIds.shift();
}

if (this.isBurn(cardId)) {
remove(this.#burnCardIds, id => id === cardId);
}
if(this.#pickCardIds.includes(cardId)){
// if the card is already picked, remove it
remove(this.#pickCardIds, id => id === cardId);
} else if(this.#pickCardIds.length < picksPerPack){
// if the card had not been picked yet, pick it and remove burn if any
if (this.isBurn(cardId)) {
remove(this.#burnCardIds, id => id === cardId);
}
this.#pickCardIds.push(cardId);
}

Check failure on line 204 in frontend/src/gamestate.js

View workflow job for this annotation

GitHub Actions / Run ESLint

Trailing spaces not allowed

this.#pickCardIds.push(cardId);
this.updState();
this.updateSelection();
}
Expand All @@ -216,15 +218,18 @@
return false;
}

if (this.#burnCardIds.length == burnsPerPack) {
this.#burnCardIds.shift();
}

if (this.isPick(cardId)) {
remove(this.#pickCardIds, id => id === cardId);
}
if(this.#burnCardIds.includes(cardId)){
// if the card is already burned, remove it
remove(this.#burnCardIds, id => id === cardId);
} else if(this.#burnCardIds.length < burnsPerPack) {
// if the card is not burned, remove it from pick if any and burn it
if (this.isPick(cardId)) {
remove(this.#pickCardIds, id => id === cardId);
}

Check failure on line 229 in frontend/src/gamestate.js

View workflow job for this annotation

GitHub Actions / Run ESLint

Trailing spaces not allowed
this.#burnCardIds.push(cardId);
}

Check failure on line 231 in frontend/src/gamestate.js

View workflow job for this annotation

GitHub Actions / Run ESLint

Trailing spaces not allowed

this.#burnCardIds.push(cardId);
this.updState();
this.updateSelection();
}
Expand Down
Loading