Vu NguyenV
Reactiflux3y ago
2 replies
Vu Nguyen

hoangvu12 – 03-00 Jan 23

I'm using XState to make a Blackjack game, now I want to make the dealer reveal any player's cards, but the problem is I don't know how to pass params (that input from the dealer) to the action.

Here is the dealer state:

      dealerTurn: {
        on: {
          HIT: {
            target: 'checkDealerStatus',
            actions: {
              type: 'dealCardsToDealer',
            },
          },
          REVEAL: {
            target: 'checkNumberOfPlayersLeft',
            actions: {
              type: 'revealAPlayerCards',
              params: {
                playerId: "The player id that user want to reveal" // <-- How can I pass the player ID here?
              }
            },
          },
          REVEAL_ALL: {
            target: 'revealAllPlayersCards',
          },
        },
      },


Edit: Solved this by adding a custom property to event
Was this page helpful?