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

Commit7c21cf1

Browse files
committed
fix cross stage continue
1 parent5eceee3 commit7c21cf1

File tree

2 files changed

+39
-20
lines changed

2 files changed

+39
-20
lines changed

‎src/state/actions/index.ts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ let currentProgress: CR.Progress = {
1414
complete:false,
1515
}
1616

17+
constcalculatePosition=({ data, progress}:{data:CR.TutorialData,progress:CR.Progress}):CR.Position=>{
18+
const{ levelList}=data.summary
19+
// take next incomplete level or the final step
20+
constlevelId=levelList.find((id:string)=>!progress.levels[id])||levelList[levelList.length-1]
21+
const{ stageList}=data.levels[levelId]
22+
conststageId=stageList.find((id:string)=>!progress.stages[id])||stageList[stageList.length-1]
23+
const{ stepList}=data.stages[stageId]
24+
conststepId=stepList.find((id:string)=>!progress.steps[id])||stepList[stepList.length-1]
25+
26+
constnextPosition:CR.Position={
27+
levelId,
28+
stageId,
29+
stepId,
30+
}
31+
32+
returnnextPosition
33+
}
34+
1735
exportdefault(dispatch:CR.EditorDispatch)=>({
1836
createWebview(){
1937
dispatch('coderoad.open_webview')
@@ -79,24 +97,9 @@ export default (dispatch: CR.EditorDispatch) => ({
7997
if(!currentTutorial){
8098
thrownewError('No Tutorial loaded')
8199
}
82-
83100
const{ data}=currentTutorial
101+
constposition=calculatePosition({ data,progress:currentProgress})
84102

85-
const{ levelList}=data.summary
86-
// take next incomplete level or the final step
87-
constlevelId=levelList.find((id:string)=>!currentProgress.levels[id])||levelList[levelList.length-1]
88-
const{ stageList}=data.levels[levelId]
89-
conststageId=stageList.find((id:string)=>!currentProgress.stages[id])||stageList[stageList.length-1]
90-
console.log('position stepList')
91-
console.log(data.stages[stageId])
92-
const{ stepList}=data.stages[stageId]
93-
conststepId=stepList.find((id:string)=>!currentProgress.steps[id])||stepList[stepList.length-1]
94-
95-
constposition={
96-
levelId,
97-
stageId,
98-
stepId,
99-
}
100103
console.log('position',position)
101104
returnposition
102105
},
@@ -113,6 +116,7 @@ export default (dispatch: CR.EditorDispatch) => ({
113116
//@ts-ignore
114117
progressUpdate:assign({
115118
progress:(context:CR.MachineContext):CR.Progress=>{
119+
console.log('progress update')
116120
const{ progress, position, data}=context
117121
constnextProgress=progress
118122

@@ -156,9 +160,23 @@ export default (dispatch: CR.EditorDispatch) => ({
156160
loadLevel(){
157161
console.log('loadLevel')
158162
},
159-
loadStage(){
163+
stageLoadNext(context:CR.MachineContext){
164+
console.log('stageLoadNext')
165+
const{ position}=context
166+
console.log(position)
167+
},
168+
loadStage(context:CR.MachineContext):void{
160169
console.log('loadStage')
170+
const{ position}=context
171+
console.log(position)
161172
},
173+
//@ts-ignore
174+
updatePosition:assign({
175+
position:(context:CR.MachineContext)=>calculatePosition({
176+
data:context.data,
177+
progress:context.progress,
178+
}),
179+
}),
162180
stepLoadCommits(context:CR.MachineContext):void{
163181
const{ data, position}=context
164182
const{ setup}=data.steps[position.stepId].actions

‎src/state/machine.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ export const machine = (dispatch: CR.EditorDispatch) =>
7171
after:{
7272
0:[{
7373
target:'Stage',
74-
internal:true,
7574
cond:'hasNextStep',
7675
},
7776
{
7877
target:'Stage',
79-
internal:false,
8078
cond:'hasNextStage',
8179
},
8280
{
@@ -150,7 +148,10 @@ export const machine = (dispatch: CR.EditorDispatch) =>
150148
},
151149
StageComplete:{
152150
on:{
153-
STAGE_NEXT:'#tutorial-load-next',
151+
STAGE_NEXT:{
152+
target:'#tutorial-load-next',
153+
actions:['updatePosition'],
154+
},
154155
},
155156
},
156157
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp