Last active
May 28, 2021 22:04
-
-
Save tivac/26014ee913503a5faa415a517d1a65cf to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const hostMachine = Machine({ | |
id: 'game-host', | |
initial: 'round_one', | |
context: { | |
active: false, | |
answering: false, | |
}, | |
states: { | |
round_one: { | |
initial: "categories", | |
on: { | |
ROUND_OVER: 'round_two', | |
}, | |
states: { | |
categories: { | |
on: { | |
DONE: "choosing", | |
}, | |
}, | |
choosing: { | |
on: { | |
QUESTION: "question", | |
}, | |
}, | |
question: { | |
initial: "reading", | |
states: { | |
reading: { | |
on: { | |
DONE_READING: "waiting", | |
}, | |
}, | |
waiting: { | |
on: { | |
BUZZER: { | |
target: "answering", | |
actions: "set_answering_player", | |
}, | |
}, | |
}, | |
answering: { | |
entry: "start_timer", | |
exit: "clear_answering_player", | |
on: { | |
TIMER_EXPIRE: { | |
actions: send("INCORRECT"), | |
}, | |
CORRECT: { | |
target: "done", | |
actions: [ | |
"give_money", | |
"set_answering_player_as_active_player", | |
] | |
}, | |
INCORRECT: { | |
target: "waiting", | |
actions: [ | |
"take_money" | |
], | |
}, | |
}, | |
}, | |
done: { | |
type: "final", | |
}, | |
}, | |
onDone: "choosing", | |
}, | |
}, | |
}, | |
round_two: { | |
initial: "categories", | |
entry: "set_lowest_player_active", | |
on: { | |
ROUND_OVER: 'final_round', | |
}, | |
states: { | |
categories: { | |
on: { | |
DONE: "choosing", | |
}, | |
}, | |
choosing: { | |
on: { | |
QUESTION: "question", | |
}, | |
}, | |
question: { | |
initial: "reading", | |
states: { | |
reading: { | |
on: { | |
DONE_READING: "waiting", | |
}, | |
}, | |
waiting: { | |
on: { | |
BUZZER: { | |
target: "answering", | |
actions: "set_answering_player", | |
}, | |
}, | |
}, | |
answering: { | |
entry: "start_timer", | |
exit: "clear_answering_player", | |
on: { | |
TIMER_EXPIRE: { | |
actions: send("INCORRECT"), | |
}, | |
CORRECT: { | |
target: "done", | |
actions: [ | |
"give_money", | |
"set_active_player", | |
] | |
}, | |
INCORRECT: { | |
target: "waiting", | |
actions: [ | |
"take_money" | |
], | |
}, | |
}, | |
}, | |
done: { | |
type: "final", | |
}, | |
}, | |
onDone: "choosing", | |
}, | |
}, | |
}, | |
final_round: { | |
initial: "clue", | |
states: { | |
clue: { | |
on: { | |
DONE_READING: "answering", | |
}, | |
}, | |
answering: { | |
entry: "start_timer", | |
on: { | |
TIMER_EXPIRE: "reveal_answers", | |
}, | |
}, | |
reveal_answers: { | |
}, | |
}, | |
}, | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment