Last active
August 16, 2021 19:28
-
-
Save robertpenner/f1eecc9067013849d8abe8e8a3654c60 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
var TournamentStatus; | |
(function (TournamentStatus) { | |
TournamentStatus["INACTIVE"] = "Inactive"; | |
TournamentStatus["SCHEDULED"] = "Scheduled"; | |
TournamentStatus["GROUPINGS_OFFICIAL"] = "Groupings Official"; | |
TournamentStatus["IN_PROGRESS"] = "In Progress"; | |
TournamentStatus["IN_PLAYOFF"] = "In Playoff"; | |
TournamentStatus["DELAY"] = "Delay"; | |
TournamentStatus["FINAL"] = "Final"; | |
TournamentStatus["ARCHIVED"] = "Archived"; | |
})(TournamentStatus || (TournamentStatus = {})); | |
var TS = TournamentStatus; | |
const machine = Machine({ | |
id: 'Tournament', | |
initial: TS.SCHEDULED, | |
states: { | |
// skipping this state for now | |
// TODO: confirm flow | |
// [TS.INACTIVE]: { | |
// on: { 'SCHEDULE TOURNAMENT': TS.SCHEDULED }, | |
// }, | |
[TS.SCHEDULED]: { | |
on: { 'START TOURNAMENT': TS.GROUPINGS_OFFICIAL }, | |
}, | |
[TS.GROUPINGS_OFFICIAL]: { | |
on: { | |
'START PLAY': TS.IN_PROGRESS, | |
}, | |
}, | |
[TS.IN_PROGRESS]: { | |
// onDone: TS.FINAL, | |
// onDone: TS.IN_PLAYOFF, | |
// Pretend there's always a playoff for now | |
initial: 'R1', | |
states: { | |
R1: { | |
initial: 'In Progress', | |
states: { | |
'In Progress': { | |
on: { 'COMPLETE ROUND': 'Complete' }, | |
}, | |
Complete: { | |
on: { 'START NEXT ROUND': '#R2' }, | |
}, | |
}, | |
}, | |
R2: { | |
id: 'R2', | |
initial: 'In Progress', | |
states: { | |
'In Progress': { | |
on: { 'COMPLETE ROUND': 'Complete' }, | |
}, | |
Complete: { | |
on: { 'START NEXT ROUND': '#R3' }, | |
}, | |
}, | |
}, | |
R3: { | |
id: 'R3', | |
initial: 'In Progress', | |
states: { | |
'In Progress': { | |
on: { 'COMPLETE ROUND': 'Complete' }, | |
}, | |
Complete: { | |
on: { 'START NEXT ROUND': '#R4' }, | |
}, | |
}, | |
}, | |
R4: { | |
id: 'R4', | |
initial: 'In Progress', | |
states: { | |
'In Progress': { | |
// on: { 'COMPLETE ROUND': TournamentStatus.IN_PLAYOFF }, | |
on: { 'COMPLETE ROUND': 'Complete' }, | |
}, | |
Complete: { | |
// on: { 'COMPLETE ROUND': '#Done Rounds' }, | |
}, | |
}, | |
}, | |
// Pretend there's always a playoff for now | |
// tallying: { | |
// id: 'tallying', | |
// on: { | |
// 'TRIGGER PLAYOFF': TournamentStatus.IN_PLAYOFF, | |
// WINNER: 'done', | |
// }, | |
// }, | |
// [TournamentStatus.IN_PLAYOFF]: { | |
// on: { | |
// 'PLAYOFF COMPLETE': 'done', | |
// }, | |
// }, | |
// 'Done Rounds': { | |
// id: 'Done Rounds', | |
// type: 'final', | |
// }, | |
history: { | |
type: 'history', | |
history: 'deep', | |
}, | |
}, | |
on: { | |
DELAY: TS.DELAY, | |
// 'COMPLETE TOURNAMENT': TS.FINAL, | |
PLAYOFF: TS.IN_PLAYOFF, | |
WINNER: TS.FINAL, | |
}, | |
}, | |
[TS.DELAY]: { | |
on: { | |
'RESUME PLAY': TS.IN_PROGRESS + '.history', | |
// 'RESUME PLAYOFF': TS.IN_PLAYOFF, | |
}, | |
}, | |
[TS.IN_PLAYOFF]: { | |
on: { | |
WINNER: TS.FINAL, | |
// TODO: find a better structure for unifying delay of rounds & playoff | |
// DELAY: TS.DELAY, | |
}, | |
}, | |
[TS.FINAL]: { | |
on: { ARCHIVE: TS.ARCHIVED }, | |
}, | |
[TS.ARCHIVED]: { | |
// type: 'final', | |
on: { RESET: TS.SCHEDULED }, | |
}, | |
}, | |
on: { | |
// Hiding because the arrow is distracting | |
// RESET: '.' + TournamentStatus.SCHEDULED, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment