Add ov score

This commit is contained in:
Dennis Schoepf 2021-08-07 22:44:21 +02:00
parent 2be130aedc
commit 63896d10c8
7 changed files with 55 additions and 2 deletions

View file

@ -23,13 +23,15 @@ export interface State {
finishedGame: boolean;
revealablesFinished: number;
showScore: boolean;
showOvScore: boolean;
uid: string;
}
const store = create<State>((set) => ({
uid: null,
showScore: false,
currentIntroStep: 1,
showOvScore: true,
currentIntroStep: 0,
revealablesFinished: 0,
currentScene: Scenes.OVERVIEW,
currentSubproject: null,

View file

@ -173,6 +173,7 @@ export class Intro {
if (currentStep === 6) {
this.sendGeneralQuestionAnswers();
window.scrollTo(0);
}
if (currentStep === 5) {

41
src/ui/ov-score.ts Normal file
View file

@ -0,0 +1,41 @@
import store from '../store';
export class OvScore {
showScore: boolean;
scoreFound: number;
scoreTotal: number;
scoreRef: HTMLElement;
scoreFoundRef: HTMLElement;
scoreTotalRef: HTMLElement;
constructor() {
this.scoreRef = document.querySelector('#ov-score');
this.scoreFoundRef = document.querySelector('#ov-score-found');
this.scoreTotalRef = document.querySelector('#ov-score-total');
this.scoreFound = 0;
this.scoreTotal = 3;
this.scoreFoundRef.innerHTML = this.scoreFound.toString();
this.scoreTotalRef.innerHTML = this.scoreTotal.toString();
if (store.getState().showOvScore) {
this.scoreRef.style.display = 'flex';
}
store.subscribe((state) => {
if (state.showOvScore) {
this.scoreRef.style.display = 'flex';
} else {
this.scoreRef.style.display = 'none';
}
this.scoreFound = state.finishedSubProjects.length;
this.scoreFoundRef.innerHTML = this.scoreFound.toString();
this.scoreTotalRef.innerHTML = this.scoreTotal.toString();
});
}
}