Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit04653e2

Browse files
committed
setup tutorial initialization
1 parent6993147 commit04653e2

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

‎src/state/actions/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ let initialProgress: CR.Progress = {
1313

1414
exportdefault{
1515
start:async()=>{
16+
// verify that the user has a tutorial & progress
17+
// verify git is setup with a coderoad remote
1618
const[tutorial,progress,hasGit,hasGitRemote]=awaitPromise.all([
1719
storage.getTutorial(),
1820
storage.getProgress(),
@@ -22,9 +24,11 @@ export default {
2224
initialTutorial=tutorial
2325
initialProgress=progress
2426
constcanContinue=!!(tutorial&&progress&&hasGit&&hasGitRemote)
27+
// if a tutorial exists, "CONTINUE"
28+
// otherwise start from "NEW"
2529
send(canContinue ?'CONTINUE' :'NEW')
2630
},
27-
loadTutorial:assign({
31+
tutorialLoad:assign({
2832
// load initial data, progress & position
2933
data():CR.TutorialData{
3034
if(!initialTutorial){
@@ -33,7 +37,9 @@ export default {
3337
returninitialTutorial.data
3438

3539
},
36-
progress():CR.Progress{returninitialProgress},
40+
progress():CR.Progress{
41+
returninitialProgress
42+
},
3743
position(){
3844
if(!initialTutorial){
3945
thrownewError('No Tutorial loaded')
@@ -53,4 +59,5 @@ export default {
5359
returnposition
5460
}
5561
}),
62+
5663
}

‎src/state/guards/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
import*asCRfrom'typings'
12

23
exportdefault{
3-
4+
// skip to the stage if the level has already been started
5+
hasNoNextLevelProgress:(context:CR.MachineContext):boolean=>{
6+
returnfalse
7+
},
48
}

‎src/state/machine.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{Machine}from'xstate'
1+
import{Machine,send}from'xstate'
22
import*asCRfrom'typings'
33

44
importactionsfrom'./actions'
@@ -43,28 +43,25 @@ export const tutorialMachine = Machine<
4343

4444
},
4545
ContinueTutorial:{
46-
onEntry:'loadTutorial',
46+
onEntry:'tutorialLoad',
4747
on:{
4848
TUTORIAL_START:{
49-
target:'Tutorial',
49+
target:'Tutorial.LoadNext',
5050
}
5151
}
5252
},
5353
}
5454
},
5555
Tutorial:{
56-
initial:'Initialize',
56+
initial:'Summary',
5757
states:{
58-
Initialize:{
58+
LoadNext:{
59+
onEntry:()=>send('LOAD_NEXT'),
5960
on:{
60-
TUTORIAL_LOADED:[
61-
{
62-
target:'Summary',
63-
cond:'hasNoProgress',
64-
},
61+
LOAD_NEXT:[
6562
{
6663
target:'Level',
67-
cond:'hasNoLevelProgress',
64+
cond:'hasNoNextLevelProgress',
6865
},
6966
{
7067
target:'Stage',

‎src/typings/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export interface MachineStateSchema {
143143
}
144144
Tutorial:{
145145
states:{
146-
Initialize:{}
146+
LoadNext:{}
147147
Summary:{}
148148
Level:{}
149149
Stage:{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp