Skip to content

Feature/completed #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix setting of stages
  • Loading branch information
ShMcK committed Jul 23, 2019
commit 52eca5598fea45a04b98fa50a6f1d759b5dde067
16 changes: 10 additions & 6 deletions src/state/guards/index.ts
Original file line number Diff line number Diff line change
@@ -4,23 +4,27 @@ export default {
hasNextStep: (context: CR.MachineContext): boolean => {
const { data, position, progress } = context
const steps = data.stages[position.stageId].stepList
// isn't final step yet
const stageIncomplete = !progress.stages[position.stageId]
const hasNext = stageIncomplete && (!!position.stepId && (steps[steps.length - 1] !== position.stepId))
const isNotFinalStep = (!!position.stepId && (steps[steps.length - 1] !== position.stepId))
const hasNext = stageIncomplete || isNotFinalStep
console.log('GUARD: hasNextStep', hasNext)
return hasNext
},
hasNextStage: (context: CR.MachineContext): boolean => {
const { data, position } = context
const { data, position, progress } = context
const stages = data.levels[position.levelId].stageList
const hasNext = !!position.stageId && stages[stages.length - 1] !== position.stageId
const stageComplete = progress.stages[position.stageId]
const isNotFinalStage = !!position.stageId && stages[stages.length - 1] !== position.stageId
const hasNext = stageComplete && isNotFinalStage
console.log('GUARD: hasNextStage', hasNext)
return hasNext
},
hasNextLevel: (context: CR.MachineContext): boolean => {
const { data, position } = context
const { data, position, progress } = context
const levels = data.summary.levelList
const hasNext = !!position.levelId && levels[levels.length - 1] !== position.levelId
const levelComplete = progress.levels[position.levelId]
const isNotFinalLevel = !!position.levelId && levels[levels.length - 1] !== position.levelId
const hasNext = levelComplete && isNotFinalLevel
console.log('GUARD: hasNextLevel', hasNext)
return hasNext
},