Skip to content

Commit a5eaea7

Browse files
committed
Merge branch 'develop' of https://github.com/AbstractPlay/gameslib into develop
2 parents 6d5fb8c + a78502f commit a5eaea7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/games/frogger.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,9 @@ export class FroggerGame extends GameBase {
497497
let points: string[] = [];
498498
const card = Card.deserialize(cardId);
499499
if (card === undefined) {
500-
throw new Error(`Could not deserialize the card ${cardId} in getNextForwardsFromCard.`);
500+
//If you can see this, the front end is trying to generate moves
501+
// for the next player from his hidden hand cards. Be forgiving...
502+
return points;
501503
}
502504
const suits = card.suits.map(s => s.uid);
503505

@@ -984,6 +986,7 @@ export class FroggerGame extends GameBase {
984986
let to;
985987
const cardObj = Card.deserialize(card);
986988
if (cardObj === undefined) {
989+
//Already handled the hidden case, so something else is wrong.
987990
throw new Error(`Could not deserialize the card ${card} in randomMove.`);
988991
}
989992

@@ -1989,9 +1992,9 @@ export class FroggerGame extends GameBase {
19891992

19901993
// create an area for all invisible cards (if there are any cards left)
19911994
const hands = this.hands.map(h => [...h]);
1992-
const closedhands = this.closedhands.map(h => [...h]);
1993-
const visibleCards = [...this.getBoardCards(), ...hands.flat(), ...this.market, ...this.discards, ...closedhands.flat()].map(uid => Card.deserialize(uid));
1994-
1995+
const closedhands = this.closedhands.map(h => [...h]).flat().filter(c => c !== "");
1996+
const visibleCards = [...this.getBoardCards(), ...hands.flat(), ...this.market, ...this.discards, ...closedhands].map(uid => Card.deserialize(uid));
1997+
19951998
if (visibleCards.includes(undefined)) {
19961999
throw new Error("Could not deserialize one of the cards. This should never happen!");
19972000
}

0 commit comments

Comments
 (0)