Created
January 22, 2021 16:37
-
-
Save mobyjames/3350f105dd97cfcde1664cbf10814bd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PlayStateMachine = Machine( | |
{ | |
id: 'game', | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
INIT: 'waiting', | |
}, | |
}, | |
waiting: { | |
exit: ['stopWaiting'], | |
on: { | |
QUORUM: 'quorum', | |
}, | |
}, | |
quorum: { | |
on: { | |
QUORUM_FAIL: 'waiting', | |
START_GAME: 'newRound', | |
}, | |
}, | |
newRound: { | |
entry: ['beginRound'], | |
on: { | |
ROUND_READY: 'roundIntro', | |
QUORUM_FAIL: 'waiting', | |
NO_ARTISTS: 'quorum', | |
}, | |
}, | |
roundIntro: { | |
entry: ['beginRoundIntro'], | |
exit: ['stopTimer'], | |
on: { | |
TIMER: 'playing', | |
ARTIST_READY: 'playing', | |
ARTIST_SKIP: 'skipped', | |
ARTIST_LEAVE: 'newRound', | |
QUORUM_FAIL: 'waiting', | |
}, | |
}, | |
playing: { | |
entry: ['beginPlaying'], | |
exit: ['stopPlaying'], | |
on: { | |
TIMER: 'reveal', | |
ALL_ANSWERS: 'reveal', | |
ARTIST_LEAVE: 'newRound', | |
ARTIST_DERP: 'skipped', | |
QUORUM_FAIL: 'waiting', | |
}, | |
}, | |
skipped: { | |
entry: ['beginSkipped'], | |
exit: ['stopTimer'], | |
on: { | |
TIMER: 'newRound', | |
QUORUM_FAIL: 'waiting', | |
}, | |
}, | |
reveal: { | |
entry: ['beginReveal'], | |
exit: ['stopTimer'], | |
on: { | |
TIMER: 'newRound', | |
QUORUM_FAIL: 'waiting', | |
}, | |
}, | |
}, | |
}, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment