Last active
April 22, 2020 22:42
-
-
Save chukinas/80b957256a3cd46c411d946dd6e8fff7 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
const clueTurnMachine = { | |
id: 'clue-turn-machine', | |
initial: 'begin_turn', | |
states: { | |
begin_turn: { | |
on: {NEXT: 'choosing_clue'}, | |
after: {5000: 'showing_target_word'} | |
}, | |
showing_target_word: { | |
on: {NEXT: 'choosing_clue'}, | |
after: {5000: 'choosing_clue'} | |
}, | |
choosing_clue: { | |
on: {SUBMIT_CLUE: 'awaiting_clues'} | |
}, | |
awaiting_clues: { | |
on: {ALL_CLUES_SUBMITTED: 'judge_duplicates'} | |
}, | |
judge_duplicates: { | |
on: {DUPS_REJECTED: 'awaiting_guess'} | |
}, | |
awaiting_guess: { | |
on: { | |
SKIP_GUESS: 'resolve_skipped_guess', | |
GUESS_SUBMITTED: 'judging_guess' | |
} | |
}, | |
judging_guess: { | |
on: {GUESS_JUDGED: 'resolve_clue_turn'} | |
}, | |
resolve_clue_turn: { | |
on: {TIMER: 'end_turn'} | |
}, | |
resolve_skipped_guess: { | |
on: {TIMER: 'end_turn'} | |
}, | |
end_turn: { | |
after: { | |
// 500: 'clue-turn-machine.awaiting_clues' | |
500: '#beginGuessTurn' | |
} | |
// type: 'final' | |
}, | |
} | |
}; | |
const guessTurnMachine = { | |
id: 'guess-turn machine', | |
initial: 'begin_turn', | |
states: { | |
begin_turn: { | |
id: 'beginGuessTurn', | |
after: {5000: 'awaiting_clues'} | |
}, | |
awaiting_clues: { | |
on: {DUPS_REJECTED: 'see_clues'} | |
}, | |
see_clues: { | |
after: {5000: 'making_guess'} | |
}, | |
making_guess: { | |
on: { | |
GUESS_SUBMITTED: 'awaiting_judgment', | |
SKIP_GUESS: 'resolve_skip' | |
} | |
}, | |
awaiting_judgment: { | |
on: { | |
GUESS_JUDGED: 'resolve_guess' | |
} | |
}, | |
resolve_guess: { | |
after: { | |
1000: 'end_turn' | |
} | |
}, | |
resolve_skip: { | |
after: { | |
1000: 'end_turn' | |
} | |
}, | |
end_turn: { | |
type: 'final' | |
} | |
} | |
} | |
const justOneMachine = Machine({ | |
id: 'just-one-machine', | |
initial: 'clue_turn', | |
states: { | |
clue_turn: { | |
// on: {END_CLUE_TURN: 'guess_turn'}, | |
...clueTurnMachine | |
}, | |
guess_turn: { | |
...guessTurnMachine | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment