Last active
October 15, 2019 08:41
-
-
Save uliang/03d21e5ee28e086693ee1c8664c9fe78 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const numberedSectionMachine = Machine({ | |
id: 'ns', | |
initial: 'ready', | |
states: { | |
ready :{} | |
} | |
}) | |
const charMachine = Machine({ | |
id: 'app', | |
context :{ | |
hasChosenWeaponDiscipline: true, | |
numberedSectionRef: null | |
}, | |
initial: 'character', | |
states: { | |
character: { | |
entry: ['askAppForBookChoice', 'getActionChartData'], | |
on: { | |
SAVE_N_QUIT: 'default_' | |
}, | |
states: { | |
hist: { | |
type: 'history', | |
history: 'deep' | |
}, | |
new_: { | |
initial: 'rollBaseVitals', | |
entry: ['setBookChoice'], | |
states: { | |
rollBaseVitals: { | |
}, | |
chooseDisciplines:{ | |
}, | |
branch: { | |
on: { | |
'': [ | |
{ target: 'chooseWeaponMastered', | |
cond: 'ifChosenWeaponDiscipline'}, | |
{ target: 'chooseEquipment', | |
cond: 'else'} | |
] | |
} | |
}, | |
chooseWeaponMastered: { | |
}, | |
chooseEquipment: { | |
}, | |
} | |
}, | |
actionChart :{ | |
entry: ['renderActionChart'], | |
on: { | |
RETURN : 'adventure.hist' | |
}, | |
}, | |
adventure: { | |
initial: 'storySoFar', | |
on :{ | |
VIEW_ACTION_CHART : '#app.character.actionChart' | |
}, | |
states: { | |
hist: { | |
type: 'history', | |
target: 'storySoFar', | |
history: 'deep' | |
}, | |
storySoFar: { | |
}, | |
numberedSection: { | |
entry: assign({ | |
numberedSectionRef: () => spawn(numberedSectionMachine) | |
}) | |
}, | |
win: { | |
on: { | |
NEW_GAME: '#app.character.import_' | |
} | |
} | |
} | |
}, | |
import_ : { | |
entry: [ | |
'askForNextBookInSeries', | |
'restoreVitals' | |
], | |
initial: 'chooseAdditionalDiscipline', | |
states: { | |
chooseAdditionalDiscipline:{ | |
}, | |
chooseImportableSpecialItems: { | |
} | |
} | |
} | |
}, | |
initial: 'new_', | |
}, | |
default_ : { | |
on: { | |
LOAD: 'character.hist', | |
NEW_GAME: 'character' | |
} | |
} | |
} | |
}, { | |
guards: { | |
ifChosenWeaponDiscipline: (c,e) => c.hasChosenWeaponDiscipline, | |
"else": (c,e) => !c.hasChosenWeaponDiscipline | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment