File

src/app/models/chapter.ts

Methods

getTotalStar
getTotalStar()
Returns: number
getCurrentExerciseByPosition
getCurrentExerciseByPosition(level: number)
Returns: void
getExoStatus
getExoStatus(position: number)
Returns: void

Properties

background
background: string
cinematic
cinematic: string
cinematic2
cinematic2: any
conclusionFail
conclusionFail: string
conclusionWin
conclusionWin: string
exercicesChapterHistory
exercicesChapterHistory: ExerciceChapterHistory[]
hasExercices
hasExercices: boolean
id
id: string
interlude
interlude: string
introduction
introduction: string
maxExercices
maxExercices: number
minimumToWin
minimumToWin: number
name
name: string
order
order: number
planet
planet: string
systemName
systemName: string
unlocked
unlocked: boolean
import { ExerciceChapterHistory } from "./exercice-chapter-history";

export enum exoState {
	validated,
	notValidated,
	unlocked,
	locked
}

export enum systemName {
	cassiopee = "Cassiopée",
	olympe = "Olympe",
	etape3 = "etape3",
	etape4 = "etape4",
	etape5 = "etape5",
	tellurique = "Telluriques",
	enfant = "Enfants",
	aeriens = "Aériens",
	galaxie7 = "galaxie7",
	galaxie8 = "galaxie8",
	galaxie9 = "galaxie9",
	galaxie10 = "galaxie10"
}

export class Chapter {
	id: string;
	name: string;
	hasExercices: boolean;
	maxExercices: number;
	introduction: string;
	interlude: string;
	conclusionWin: string;
	conclusionFail: string;
	cinematic: string;
	minimumToWin: number;
	planet: string;
	background: string;
	unlocked: boolean;
	exercicesChapterHistory: ExerciceChapterHistory[];
	systemName: string;
	order: number;
	// tmp for new voice
	cinematic2: any;
	getTotalStar(): number {
		if (this.exercicesChapterHistory) {
			let total = 0;
			this.exercicesChapterHistory.forEach(element => (total += element.maxStarsWon().star));
			return total;
		} else return 0;
	}

	getCurrentExerciseByPosition(level: number) {
		return this.exercicesChapterHistory.find(exo => exo.position === level);
	}

	getExoStatus(position: number) {
		//position where we have historic
		if (this.exercicesChapterHistory.length >= position) {
			const exo = this.exercicesChapterHistory.find(exo => exo.position === position);
			if(exo){
				//for exo from bilan always validated
				if (exo.bilan){
					return exoState.validated;
				}
				const resultExo = exo.maxStarsWon();
				//or we parse result to verify if we have a result over the the minimal ratio
				if (resultExo.total !== 0 && resultExo.ratio >= this.minimumToWin / 10) {
					return exoState.validated;
				} else {
					return exoState.notValidated;
				}
		}
		} else if (this.exercicesChapterHistory.length + 1 === position) {
			return exoState.unlocked;
		} else {
			// else is locked
			return exoState.locked;
		}
	}
}

results matching ""

    No results matching ""