Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions ui/analyse/src/study/practice/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface StudyPracticeCtrl {
onLoad(): void;
onJump(): void;
onCeval(): void;
onComplete(): void;
data: StudyPracticeData;
goal: Prop<Goal>;
success: Prop<boolean | null>;
Expand Down
10 changes: 7 additions & 3 deletions ui/analyse/src/study/practice/studyPracticeCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Prop, prop } from 'common';
import { storedBooleanProp } from 'common/storage';
import makeSuccess from './studyPracticeSuccess';
import { readOnlyProp } from '../../util';
import { StudyPracticeData, Goal } from './interfaces';
import { StudyPracticeData, Goal, StudyPracticeCtrl } from './interfaces';
import { StudyData } from '../interfaces';
import AnalyseCtrl from '../../ctrl';

export default class StudyPractice {
export default class StudyPractice implements StudyPracticeCtrl {
goal: Prop<Goal>;
nbMoves = prop(0);
// null = ongoing, true = win, false = fail
Expand Down Expand Up @@ -55,12 +55,16 @@ export default class StudyPractice {
};

onVictory = (): void => {
this.saveNbMoves();
site.sound.play('practiceSuccess');
this.onComplete();
if (this.studyData.chapter.practice && this.autoNext())
setTimeout(this.root.study!.goToNextChapter, 1000);
};

onComplete = (): void => {
this.saveNbMoves();
};

saveNbMoves = (): void => {
const chapterId = this.root.study!.currentChapter().id,
former = this.data.completion[chapterId];
Expand Down
1 change: 1 addition & 0 deletions ui/analyse/src/study/studyCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ export default class StudyCtrl {
if (chapter) this.setChapter(chapter.id);
};
goToNextChapter = () => {
this.practice?.onComplete();
const chapter = this.nextChapter();
if (chapter) this.setChapter(chapter.id);
};
Expand Down