Stuck on Hearts Tutorial: "Cannot read properties of undefined" in addCards loop for tableau

Game development with Board Game Arena Studio
Post Reply
Reyvolution
Posts: 3
Joined: 06 April 2020, 04:49

Stuck on Hearts Tutorial: "Cannot read properties of undefined" in addCards loop for tableau

Post by Reyvolution »

I've been following the current hearts tutorial ( https://en.doc.boardgamearena.com/Tutor ... teractions ) and got through the steps right before the "cardswon" step.

Things seemed to be working up until this point, but now after connecting the various state transitions I'm hitting an error in this block:

Code: Select all

// Cards played on table
        for (i in this.gamedatas.cardsontable) {
        var card = this.gamedatas.cardsontable[i];
        var player_id = card.location_arg;
        this.tableauStocks[player_id].addCards([card]);
        }
The final line with the .addCards() call is failing with error: Technical error: Cannot read properties of undefined (reading 'addCards')

It doesn't fail when the game first loads, but fails when switching to the 2nd or 3rd player's turn.

The previous temporary call to this.tableauStocks[player.id].addCards with a dummy index value worked fine, so this seems to be an issue with iterating through the 'cardsontable' returned from 'gamedatas' and I can't figure out how to troubleshoot it any further. :?
Reyvolution
Posts: 3
Joined: 06 April 2020, 04:49

Re: Stuck on Hearts Tutorial: "Cannot read properties of undefined" in addCards loop for tableau

Post by Reyvolution »

Just stepped through it again to confirm how it is failing:

1. Express Start game with 4 players --> Loads with initial hand dealt and an empty tableau

2. Switch to active player's view using the red arrow --> Loads with initial hand dealt and an empty tableau

3. Click a card from active player's hand --> The card moves to the tableau in the active player's view. If I view the previous (non-active) player's browser tab it also shows the card on the tableau

4. Switch to the next active player's view OR reload any page that was viewing the game -- > Fails to load with message:
Error loading the game! We have been notified.
Technical error: Cannot read properties of undefined (reading 'addCards')
Post Reply

Return to “Developers”