src/app/models/scenario-galaxiedescalculs.ts
constructor(cabri: CabriDataService, accountService: AccountService, globalService: GlobalService, page: any, cd: ChangeDetectorRef, ttsService: any)
|
| populateScenario |
populateScenario(randomize: boolean)
|
|
Creates feedbacks for calcul mental on top of general feedbacks
Returns:
void
|
| dynamicFeedback |
dynamicFeedback(answerStatus: AnswerStatus, responseTimeInSeconds: number, feedBackNeedsHelp: AnswerNeedsHelp, award: string)
|
|
Bonne réponse / Mauvaise 1rst
Returns:
any
|
| playSoundWithAward |
playSoundWithAward(award: string)
|
|
Returns:
void
|
| endOfActivity |
endOfActivity()
|
|
Returns:
void
|
| badResponse |
badResponse(endAnimationPromise: any, answerStatus: AnswerStatus, responseTimeInSeconds: number, award: string)
|
|
Mauvaise réponse sur deuxième tentative.
Returns:
void
|
| playIntro |
playIntro()
|
|
Introduction
Returns:
void
|
| restartActivity |
restartActivity()
|
|
Recommencer l’activité
Returns:
void
|
| nextPlayerInit |
nextPlayerInit()
|
|
Lancement de l’activité / 1er joueur
Returns:
void
|
| nextPlayerSwitch |
nextPlayerSwitch()
|
|
Joueur suivant.
Returns:
void
|
| help |
help()
|
|
Aide après une erreur.
Returns:
void
|
| moonEliminated |
moonEliminated()
|
|
Returns:
void
|
| Public page |
page: |
| ttsService |
ttsService: |
import { PlayTTSService } from "src/app/services/play-tts.service";
import { ChangeDetectorRef } from "@angular/core";
import { GalaxieDesCalculsPage } from "../page/galaxiedescalculs/galaxiedescalculs.page";
import { AccountService } from "../services/account.service";
import { CabriDataService } from "../services/cabri-data.service";
import { GlobalService } from "../services/global.service";
import { ScenarioPhrase } from "./scenario-phrase";
import { ScenarioCabri } from "./scenario-cabri";
import { AnswerStatus, AnswerSpeed, AnswerAverage, AnswerNeedsHelp } from "./activity-answer";
import { AppUtils } from "../app-utils";
export class ScenarioGalaxiedescalculs extends ScenarioCabri {
public page: GalaxieDesCalculsPage;
constructor(
cabri: CabriDataService,
accountService: AccountService,
globalService: GlobalService,
page: any,
cd: ChangeDetectorRef,
public ttsService: PlayTTSService
) {
super(cabri, accountService, globalService, page, cd, ttsService);
}
/**
* Creates feedbacks for calcul mental on top of general feedbacks
*/
populateScenario(randomize?: boolean) {
super.populateScenario(randomize);
// SUCCESS 1ST TRY
// SLOW
this.addFeedbacks(
{ status: AnswerStatus.VALID1ST, speed: AnswerSpeed.SLOW },
2,
[
$localize`Oui ! Très bon calcul #playerName !`,
$localize`Un petit pas pour toi, un grand pas pour ton apprentissage !`,
$localize`Youpi, tu as trouvé la solution !`
],
2
);
// NORMAL
this.addFeedbacks(
{ success: true },
1,
[
$localize`Bravo #playerName ! Tu as gagné une #award !`,
$localize`Et encore une #award ! Youpi !`,
$localize`Quelle giga-réponse ! Bravo`,
$localize`Hop ! Une #award ! Super !`,
$localize`Oui #playerName, bien joué !`,
$localize`Youpi ! Une #award !`,
$localize`Une #award de plus au tableau ! Super !`,
$localize`Oui ! Bravo #playerName !`,
$localize`Et hop ! Une #award en plus !`,
$localize`Méga-boulonique cette réponse !`,
$localize`Youpi ! Une #award de gagnée !`,
$localize`Et une #award en plus pour ta collection !`,
$localize`Oui ! Une nouvelle constellation en vue !`,
$localize`Tiens ! Voila une #award pour compléter ta collection !`
],
2
);
// FAST
this.addFeedbacks(
{ status: AnswerStatus.VALID1ST, speed: AnswerSpeed.FAST },
2,
[
$localize`Wahou ! Aussi rapide qu’une étoile filante !`,
$localize`Tu réfléchis plus vite que la lumière !`,
$localize`Lumino-fantastique !`,
$localize`Supra-luminique !`,
$localize`Vitesse lumière !`,
$localize`Tu réfléchis plus vite que la lumière !`,
$localize`Quelle cosmo-réponse ! Tu es supra-luminique !`,
$localize`Tu maîtrises les nombres à la perfection #playerName !`,
$localize`Par Toutatis ! Quelle maîtrise !`
],
2
);
// PROGRESSION ABOVE AVERAGE
this.addFeedbacks(
{ status: AnswerStatus.VALID1ST, progressionAverage: AnswerAverage.ABOVE },
3,
[$localize`Je suis impressionnée ! Tu as l’air à l’aise dans cette galaxie de calculs !`],
2
);
// SUCCESS 2ND TRY
this.addFeedbacks(
{ status: AnswerStatus.VALID2ND },
3,
[$localize`Oui ! Tu as trouvé ! Bravo #playerName !`],
2
);
// ERRORS
// FIRST ERROR - retry without help
this.addFeedbacks(
{ status: AnswerStatus.ERROR1ST, needsHelp: AnswerNeedsHelp.NO },
2,
[
$localize`Appel à la base ! Il y a des turbulences sur le chemin ! Reprenons le cap !`,
$localize`Oups ! Ce n’est pas ça.`,
$localize`Tu y es presque #playerName !`,
$localize`Oups, ce n’est pas la bonne réponse...`,
$localize`Tu t’es trompé mais ce n’est pas grave, c’est comme ça qu’on apprend !`,
$localize`Oups... La fusée bug !`,
$localize`Ouloulou ! Ce n’est pas ça...`,
$localize`Oups... J’aimerais pouvoir te dire que tu as trouvé, mais ce n’est pas ça !`,
$localize`Tu y es presque #playerName !`,
$localize`Oups ! Ce n’est pas ça !`,
$localize`Sauve qui peut ! Le vaisseau part à la dérive, reprenons vite la barre !`
],
2
);
this.addFeedbacks(
{ status: AnswerStatus.ERROR1ST, needsHelp: AnswerNeedsHelp.NO, speed: AnswerSpeed.FAST },
3,
[
$localize`Ce n’est pas ça. Et si nous ralentissions un peu ?`,
$localize`Oula ! Tu devrais aller moins vite !`,
$localize`Ce n’est pas ça ! N’hésite pas à prendre ton temps avant de répondre !`,
$localize`Pas si vite ! Ce n’est pas ça !`,
$localize`Oula non ! Tu as répondu un peu vite !`,
$localize`Oups, tu es allé un peu vite !`
],
2
);
// TODO => special class for not answer phrases using same mechanism :
// this.addFeedbacks({ status: FuretSpecial.VARIABLECHANGE }, 2, [
// $localize`Oh ! Attention les nombres ont changé !`,
// $localize`Oh ! Les nombres ont encore changé !`
// ], 2);
// console.error("feedbacks unshuffled = ", this.feedbacks);
if (randomize) {
AppUtils.shuffleArray(this.feedbacks);
// console.error("feedbacks shuffled = ", this.feedbacks);
}
}
/**
* Bonne réponse / Mauvaise 1rst
*/
async dynamicFeedback(
answerStatus: AnswerStatus,
responseTimeInSeconds: number,
feedBackNeedsHelp: AnswerNeedsHelp,
award?: string
): Promise<any> {
const phrase = this.getContextualFeedbackPhrase(answerStatus, responseTimeInSeconds, award, 20, 5, 5, 3, feedBackNeedsHelp);
console.error("galaxy dynamicFeedback phrase = ", phrase);
const speechSequence = [new ScenarioPhrase([phrase]).setRandomMode().showAward(award)];
await this.runMathiaSpeech(speechSequence);
}
async playSoundWithAward(award?: string) {
let speechSequence;
this.page.hideBubbleText = true;
let awardSoundPromise;
if (award) {
if (award === "moon") {
awardSoundPromise = this.page.audioService.playAwardMoonSound();
} else {
awardSoundPromise = this.page.audioService.playStarSound();
}
speechSequence = [new ScenarioPhrase(" ", async() => {
// await awardSoundPromise;
await this.timeOut(1500);
}).showAward(award)];
await this.runMathiaSpeech(speechSequence);
} else {
this.page.audioService.playAwardMoonSound();
await this.timeOut(1500);
}
this.page.hideBubbleText = false;
}
async endOfActivity() {
const phrase: Array<any> = [new ScenarioPhrase([$localize`Quelle expédition !`, $localize`Quel voyage !`]).setRandomMode()];
this.page.starboardToggle = false;
this.detectChanges();
await this.runMathiaSpeech(phrase);
}
/**
* Mauvaise réponse sur deuxième tentative.
*/
async badResponse(endAnimationPromise, answerStatus: AnswerStatus, responseTimeInSeconds: number, award?: string) {
let result = this.page.cabri.castelGrid.getCellById(this.page.cabri.selectedCellNumber).value.toString();
if (result === "1") {
result = result.replace("1", $localize`un`);
}
const phrase = this.getContextualFeedbackPhrase(answerStatus, responseTimeInSeconds, award, 20, 5, 5, 3);
let speechSequence = new Array();
if (this.page.sonicAward) {
speechSequence.push(
new ScenarioPhrase([" "], async () => {
await endAnimationPromise;
}).hideBubble()
);
} else {
speechSequence.push(
new ScenarioPhrase([phrase], async () => {
await endAnimationPromise;
})
);
}
speechSequence.push(
new ScenarioPhrase(
[
$localize`La réponse était ${result}`,
$localize`Regarde, la bonne réponse était ${result}`,
$localize`La bonne réponse était ${result}`,
$localize`Regarde, la réponse était ${result}`
],
async () => {
await this.timeOut(3000);
// this.page.showHideAward();
}
).setRandomMode()
)
speechSequence.push(
new ScenarioPhrase([$localize`Tu as quand même trouvé une lune !`, $localize`On a quand même gagné une lune !`], async () => {
this.page.starboardToggle = true;
this.page.detectChanges();
this.page.starboardSortStarsEventSubject.next();
this.page.detectChanges();
await this.timeOut(500);
this.page.updatePlayerAndTeamStarboards("moon");
await this.timeOut(1500);
this.page.starboardToggle = false;
this.detectChanges();
})
.setRandomMode()
.showAward("moon")
);
if (this.page.endOfActivity()) {
speechSequence = [
new ScenarioPhrase(
[
// $localize`${this.appName} ! Il faut rallumer la soucoupe !`,
$localize`Oups... J’aimerais pouvoir te dire que tu as trouvé, mais ce n’est toujours pas ça. Terminus !`,
$localize`Tu t’es trompé mais ce n’est pas grave, c’est comme ça qu’on apprend !`,
$localize`Ce n’est pas ça mais nous avons tout de même décroché une lune !`,
$localize`Et non... On va devoir se contenter d’une lune, mais c’est bien aussi !`
],
async () => {
// await this.page.showHideAward();
await endAnimationPromise;
this.page.starboardToggle = true;
this.page.detectChanges();
this.page.starboardSortStarsEventSubject.next();
this.page.detectChanges();
await this.timeOut(500);
this.page.updatePlayerAndTeamStarboards("moon");
await this.timeOut(1500);
this.page.starboardToggle = false;
this.detectChanges();
}
)
.setRandomMode()
.speechOnly()
.hideBubble(),
new ScenarioPhrase(
[
$localize`La réponse était ${result}`,
$localize`Regarde, la bonne réponse était ${result}`,
$localize`La bonne réponse était ${result}`,
$localize`Regarde, la réponse était ${result}`
],
async () => {
await this.timeOut(3000);
}
).setRandomMode(),
new ScenarioPhrase([
$localize`Continue de t’entrainer, il y a encore plein d’étoiles à gagner !`,
$localize`Continue comme ça, tu es sur le bon chemin !`
])
];
}
await this.runMathiaSpeech(speechSequence);
}
/**
* Introduction
*/
async playIntro() {
const players: any = this.accountService.team.map(student => student.name).join(" ! ");
let verbOperation = "";
switch (this.page.cabri.castelGrid.mode) {
case "addition":
verbOperation = $localize`additionner`;
break;
case "addition-classic":
verbOperation = $localize`additionner`;
break;
case "soustraction":
verbOperation = $localize`soustraire`;
break;
case "multiplication":
verbOperation = $localize`multiplier`;
break;
}
// SEQUENCE:
if (this.accountService.team.length > 1) {
// MULTI:
const introTeam: Array<any> = [
new ScenarioPhrase([
$localize`${players} ! Bienvenue dans la galaxie des calculs !`
]),
new ScenarioPhrase([
$localize`Dans ce jeu, vous allez devoir trouver les nombres qui se cachent sous les étoiles !`
]),
new ScenarioPhrase(
[$localize`Pour trouver un nombre caché, vous devez ${verbOperation} le nombre de sa colonne`],
async () => {
if (!this.skipSequence) {
await this.page.showCol();
await this.timeOut(1000);
}
}
),
new ScenarioPhrase([$localize`à celui de sa ligne`], async () => {
if (!this.skipSequence) {
await this.page.showLine();
await this.timeOut(1000);
}
this.page.hideRowAndCol();
})
];
await this.runMathiaSpeech(introTeam);
// scenario multi continues in this.nextPlayerInit()
} else {
// SOLO:
const introSolo: Array<any> = [
new ScenarioPhrase([
$localize`${this.page.currentUser.name} ! Bienvenue dans la galaxie des calculs !`
]).setRandomMode(),
new ScenarioPhrase([$localize`Dans ce jeu, tu vas devoir trouver les nombres qui se cachent sous les étoiles !`]),
new ScenarioPhrase([$localize`Pour trouver un nombre caché, tu dois ${verbOperation} le nombre de sa colonne`], async () => {
if (!this.skipSequence) {
await this.page.showCol();
}
await this.timeOut(1000);
}),
new ScenarioPhrase([$localize`à celui de sa ligne`], async () => {
if (!this.skipSequence) {
await this.page.showLine();
await this.timeOut(1000);
}
this.page.hideRowAndCol();
}),
new ScenarioPhrase([$localize`A toi de jouer !`]),
new ScenarioPhrase($localize`3... 2... 1...`),
new ScenarioPhrase(
[
$localize`C’est parti !`,
$localize`Décollage !`,
$localize`Allumage des réacteurs !`,
$localize`Vers l’infini et au-delà !`,
$localize`Que la force soit avec toi !`
]
).setRandomMode()
];
await this.runMathiaSpeech(introSolo);
}
}
/**
* Recommencer l’activité
*/
async restartActivity() {
const playRestart: Array<any> = [
new ScenarioPhrase([$localize`Une nouvelle expédition est parée au lancement ? Youpi !`]),
new ScenarioPhrase([$localize`C’est reparti pour la galaxie des calculs !`]).setRandomMode()
];
await this.runMathiaSpeech(playRestart);
}
/**
* Lancement de l’activité / 1er joueur
*/
async nextPlayerInit() {
const nextPlayerInit: Array<any> = [
new ScenarioPhrase([
$localize`C’est toi qui commences ${this.page.currentUser.name} !`,
$localize`A toi de commencer ${this.page.currentUser.name} !`,
$localize`${this.page.currentUser.name}, à toi l’honneur de répondre en premier !`,
$localize`${this.page.currentUser.name}, c’est à toi de commencer !`
]).setRandomMode(),
new ScenarioPhrase($localize`3... 2... 1...`),
new ScenarioPhrase([
$localize`C’est parti !`,
$localize`Décollage !`,
$localize`Allumage des réacteurs !`,
$localize`Vers l’infini et au-delà !`,
$localize`Que la force soit avec toi !`
]).setRandomMode()
];
await this.runMathiaSpeech(nextPlayerInit);
}
/**
* Joueur suivant.
*/
async nextPlayerSwitch() {
const nextPlayerContent: Array<any> = [
new ScenarioPhrase([
$localize`Maintenant c’est à ${this.page.currentUser.name} de piloter ! Vas-y ${this.page.currentUser.name} !`,
$localize`Maintenant à toi ${this.page.currentUser.name} ! Vas-y !`,
$localize`A ton tour ${this.page.currentUser.name} !`,
$localize`A toi ${this.page.currentUser.name} !`,
$localize`${this.page.currentUser.name} Tu es là ? A toi !`,
$localize`Ok, à ton tour ${this.page.currentUser.name} ! Vas-y !`,
$localize`${this.page.currentUser.name} ? A toi de jouer !`,
$localize`A ${this.page.currentUser.name} maintenant !`,
$localize`${this.page.currentUser.name}, à toi !`,
$localize`Quel voyage ! A toi ${this.page.currentUser.name} !`
]).setRandomMode()
];
await this.runMathiaSpeech(nextPlayerContent);
}
/**
* Aide après une erreur.
* Affichage en vert de la ligne et de la colonne de l’opération à résoudre.
*/
async help() {
let advice = [];
this.page.switchCastleLeft(true);
const currentOperation = this.page.cabri.getCurrentOperation();
let currentOperationTTS = currentOperation.replace("+", $localize`plus`);
currentOperationTTS = currentOperationTTS.replace("-", $localize`moins`);
currentOperationTTS = currentOperationTTS.replace("×", $localize`fois`);
advice = [
new ScenarioPhrase([$localize`Regarde bien la colonne, elle indique le premier nombre`], async () => {
if (!this.skipSequence) {
await this.page.showCol();
await this.timeOut(1000);
}
}),
new ScenarioPhrase([$localize`et la ligne, elle indique le deuxième nombre`], async () => {
if (!this.skipSequence) {
await this.page.showLine();
await this.timeOut(1000);
}
}),
new ScenarioPhrase(
$localize`L’opération est donc : ${currentOperation}`,
async () => {
if (!this.skipSequence) {
await this.timeOut(1000);
await this.page.hideRowAndCol();
} else {
this.page.hideRowAndCol();
}
},
$localize`L’opération est donc : ${currentOperationTTS}`
)
];
this.cd.detectChanges();
await this.runMathiaSpeech(advice);
}
async moonEliminated() {
const moon: Array<any> = [
new ScenarioPhrase([
$localize`Tu as quand même gagné une lune !`,
]).setRandomMode().showAward("moon")
];
await this.runMathiaSpeech(moon);
}
}