Vu Nguyen
Vu Nguyen10mo ago

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',
},
},
},
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
2 Replies
S3BAS
S3BAS10mo ago
Wajo an xstate question here Which version are you using?
reactibot
reactibot10mo ago
This thread hasn’t had any activity in 36 hours, so it’s now locked. Threads are closed automatically after 36 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1199186753551073321