Skip to content

Instantly share code, notes, and snippets.

@robertpenner
Last active August 5, 2021 20:42
Show Gist options
  • Save robertpenner/13e84f52841f13e7e81b6be21a72709f to your computer and use it in GitHub Desktop.
Save robertpenner/13e84f52841f13e7e81b6be21a72709f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'Tournament',
initial: 'inactive',
states: {
inactive: {
on: { 'SCHEDULE TOURNAMENT': 'pre' },
},
pre: {
on: { 'START TOURNAMENT': 'during' },
},
during: {
initial: 'groupings official',
states: {
'groupings official': {
on: {
'START PLAY': 'playing',
},
},
playing: {
initial: 'round 1',
states: {
'round 1': {
initial: 'in progress',
states: {
'in progress': {
on: { 'COMPLETE ROUND': 'complete' }
},
complete: {
on: { 'START NEXT ROUND': '#round 2' },
},
},
},
'round 2': {
id: 'round 2',
initial: 'in progress',
states: {
'in progress': {
on: { 'COMPLETE ROUND': 'complete' }
},
complete: {
on: { 'START NEXT ROUND': '#round 3' },
},
},
},
'round 3': {
id: 'round 3',
initial: 'in progress',
states: {
'in progress': {
on: { 'COMPLETE ROUND': 'complete' }
},
complete: {
on: { 'START NEXT ROUND': '#round 4' },
},
},
},
'round 4': {
id: 'round 4',
initial: 'in progress',
states: {
'in progress': {
on: { 'COMPLETE ROUND': '#tallying' }
},
},
},
tallying: {
id: 'tallying',
on: {
'TRIGGER PLAYOFF': 'playoff',
WINNER: 'done',
},
},
playoff: {
on: {
'PLAYOFF COMPLETE': 'done',
},
},
done: { type: 'final' },
history: {
type: 'history',
history: 'deep',
},
},
on: {
'DELAY PLAY': 'play delayed',
},
},
'play delayed': {
on: {
'RESUME PLAY': 'playing.history'
},
},
},
on: { 'COMPLETE TOURNAMENT': 'complete' },
},
complete: {
on: { 'TOURNAMENT INACTIVE': 'inactive' },
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment