@@ -21,136 +21,132 @@ export const playTutorialMachine = Machine<CR.PlayMachineContext, CR.PlayTutoria
2121 } ,
2222 processes : [ ] ,
2323 } ,
24+ id : 'tutorial' ,
25+ initial : 'Initialize' ,
26+ on : {
27+ // track commands
28+ COMMAND_START : {
29+ actions : [ 'commandStart' ] ,
30+ } ,
31+ COMMAND_SUCCESS : {
32+ actions : [ 'commandSuccess' ] ,
33+ } ,
34+ COMMAND_FAIL : {
35+ actions : [ 'commandFail' ] ,
36+ } ,
37+ ERROR : {
38+ actions : [ 'setError' ] ,
39+ } ,
40+ } ,
2441 states : {
25- Tutorial : {
26- id : 'tutorial' ,
27- initial : 'Initialize' ,
42+ // TODO move Initialize into New Tutorial setup
43+ Initialize : {
44+ onEntry : [ 'initializeTutorial' ] ,
2845 on : {
29- // track commands
30- COMMAND_START : {
31- actions : [ 'commandStart' ] ,
32- } ,
33- COMMAND_SUCCESS : {
34- actions : [ 'commandSuccess' ] ,
46+ TUTORIAL_CONFIGURED : 'Summary' ,
47+ // TUTORIAL_CONFIG_ERROR: 'Start' // TODO should handle error
48+ } ,
49+ } ,
50+ Summary : {
51+ on : {
52+ LOAD_TUTORIAL : {
53+ target : 'Level' ,
54+ actions : [ 'initPosition' , 'initTutorial' ] ,
3555 } ,
36- COMMAND_FAIL : {
37- actions : [ 'commandFail' ] ,
56+ } ,
57+ } ,
58+ LoadNext : {
59+ id : 'tutorial-load-next' ,
60+ onEntry : [ 'loadNext' ] ,
61+ on : {
62+ NEXT_STEP : {
63+ target : 'Level' ,
64+ actions : [ 'updatePosition' ] ,
3865 } ,
39- ERROR : {
40- actions : [ 'setError' ] ,
66+ NEXT_LEVEL : {
67+ target : 'Level' , // TODO should return to levels summary page
68+ actions : [ 'updatePosition' ] ,
4169 } ,
70+ COMPLETED : '#completed-tutorial' ,
4271 } ,
72+ } ,
73+ Level : {
74+ initial : 'Load' ,
4375 states : {
44- // TODO move Initialize into New Tutorial setup
45- Initialize : {
46- onEntry : [ 'initializeTutorial' ] ,
47- on : {
48- TUTORIAL_CONFIGURED : 'Summary' ,
49- // TUTORIAL_CONFIG_ERROR: 'Start' // TODO should handle error
76+ Load : {
77+ onEntry : [ 'loadLevel' , 'loadStep' ] ,
78+ after : {
79+ 0 : 'Normal' ,
5080 } ,
5181 } ,
52- Summary : {
82+ Normal : {
83+ id : 'tutorial-level' ,
5384 on : {
54- LOAD_TUTORIAL : {
55- target : 'Level' ,
56- actions : [ 'initPosition' , 'initTutorial '] ,
85+ TEST_RUNNING : 'TestRunning' ,
86+ STEP_SOLUTION_LOAD : {
87+ actions : [ 'editorLoadSolution ' ] ,
5788 } ,
5889 } ,
5990 } ,
60- LoadNext : {
61- id : 'tutorial-load-next' ,
62- onEntry : [ 'loadNext' ] ,
91+ TestRunning : {
92+ onEntry : [ 'testStart' ] ,
6393 on : {
64- NEXT_STEP : {
65- target : 'Level' ,
66- actions : [ 'updatePosition' ] ,
67- } ,
68- NEXT_LEVEL : {
69- target : 'Level' , // TODO should return to levels summary page
70- actions : [ 'updatePosition' ] ,
94+ TEST_PASS : {
95+ target : 'TestPass' ,
96+ actions : [ 'updateStepProgress' ] ,
7197 } ,
72- COMPLETED : '#completed-tutorial' ,
98+ TEST_FAIL : 'TestFail' ,
99+ TEST_ERROR : 'TestError' ,
73100 } ,
74101 } ,
75- Level : {
76- initial : 'Load' ,
77- states : {
78- Load : {
79- onEntry : [ 'loadLevel' , 'loadStep' ] ,
80- after : {
81- 0 : 'Normal' ,
82- } ,
83- } ,
84- Normal : {
85- id : 'tutorial-level' ,
86- on : {
87- TEST_RUNNING : 'TestRunning' ,
88- STEP_SOLUTION_LOAD : {
89- actions : [ 'editorLoadSolution' ] ,
90- } ,
91- } ,
92- } ,
93- TestRunning : {
94- onEntry : [ 'testStart' ] ,
95- on : {
96- TEST_PASS : {
97- target : 'TestPass' ,
98- actions : [ 'updateStepProgress' ] ,
99- } ,
100- TEST_FAIL : 'TestFail' ,
101- TEST_ERROR : 'TestError' ,
102- } ,
103- } ,
104- TestError : {
105- onEntry : [ 'testFail' ] ,
106- after : {
107- 0 : 'Normal' ,
108- } ,
109- } ,
110- TestPass : {
111- onExit : [ 'updateStepPosition' ] ,
112- after : {
113- 1000 : 'StepNext' ,
114- } ,
115- } ,
116- TestFail : {
117- onEntry : [ 'testFail' ] ,
118- after : {
119- 0 : 'Normal' ,
120- } ,
121- } ,
122- StepNext : {
123- onEntry : [ 'stepNext' ] ,
124- on : {
125- LOAD_NEXT_STEP : {
126- target : 'Normal' ,
127- actions : [ 'loadStep' ] ,
128- } ,
129- LEVEL_COMPLETE : {
130- target : 'LevelComplete' ,
131- actions : [ 'updateLevelProgress' ] ,
132- } ,
133- } ,
102+ TestError : {
103+ onEntry : [ 'testFail' ] ,
104+ after : {
105+ 0 : 'Normal' ,
106+ } ,
107+ } ,
108+ TestPass : {
109+ onExit : [ 'updateStepPosition' ] ,
110+ after : {
111+ 1000 : 'StepNext' ,
112+ } ,
113+ } ,
114+ TestFail : {
115+ onEntry : [ 'testFail' ] ,
116+ after : {
117+ 0 : 'Normal' ,
118+ } ,
119+ } ,
120+ StepNext : {
121+ onEntry : [ 'stepNext' ] ,
122+ on : {
123+ LOAD_NEXT_STEP : {
124+ target : 'Normal' ,
125+ actions : [ 'loadStep' ] ,
134126 } ,
135- LevelComplete : {
136- on : {
137- LEVEL_NEXT : '#tutorial-load-next' ,
138- } ,
127+ LEVEL_COMPLETE : {
128+ target : 'LevelComplete' ,
129+ actions : [ 'updateLevelProgress' ] ,
139130 } ,
140131 } ,
141132 } ,
142- Completed : {
143- id : 'completed-tutorial' ,
144- onEntry : [ 'userTutorialComplete' ] ,
133+ LevelComplete : {
145134 on : {
146- SELECT_TUTORIAL : {
147- target : '#start-new-tutorial' ,
148- actions : [ 'reset' ] ,
149- } ,
135+ LEVEL_NEXT : '#tutorial-load-next' ,
150136 } ,
151137 } ,
152138 } ,
153139 } ,
140+ Completed : {
141+ id : 'completed-tutorial' ,
142+ onEntry : [ 'userTutorialComplete' ] ,
143+ on : {
144+ SELECT_TUTORIAL : {
145+ type : 'final' ,
146+ actions : [ 'reset' ] ,
147+ } ,
148+ } ,
149+ } ,
154150 } ,
155151 } ,
156152 options ,
0 commit comments