Skip to content

Commit

Permalink
Merge pull request #221 from computas/SP24-688-fix-your-drawing-looke…
Browse files Browse the repository at this point in the history
…d-like

Now wont show same label twice on loss intermediary screen
  • Loading branch information
ComputasAlex authored Jul 24, 2024
2 parents fb9f6d4 + 6576fa9 commit ecc016c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/app/game/game-draw/game-draw.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export class GameDrawComponent implements OnInit, OnDestroy {
this.prediction = prediction;
const sortedCertaintyArr = this.sortOnCertainty(prediction);
this.updateAiGuess(sortedCertaintyArr);
this.drawingService.sortedCertainty = sortedCertaintyArr;
if (this.prediction && this.prediction.hasWon && !this.hasAddedResult) {
this.soundService.playResultSound(this.prediction.hasWon);
this.updateResult(true);
Expand Down Expand Up @@ -348,7 +349,7 @@ export class GameDrawComponent implements OnInit, OnDestroy {
this.updateAiGuess(sortedCertaintyArr);
if (this.drawingService.roundIsDone(res.hasWon, res.gameState)) {
this.gameStateService.goToPage(GAMESTATE.intermediateResult);

this.drawingService.sortedCertainty = sortedCertaintyArr;
this.soundService.playResultSound(res.hasWon);
const score = this.score > 0 ? this.score : 0;
this.drawingService.lastResult.score = Math.round(score);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { SpeechBubbleComponent } from '@/app/game/speech-bubble/speech-bubble.component';
import { OAvatarComponent } from '@/assets/avatars/o-avatar/o-avatar.component';
import { ArrowAlignment, PointerSide } from '@/app/shared/models/interfaces';
import { ArrowAlignment, Certainty, PointerSide } from '@/app/shared/models/interfaces';
import { CustomColorsIO } from '@/app/shared/customColors';
import { TranslatePipe } from '@/app/core/translation.pipe';
import { ExampleDrawingService } from '@/app/game/services/example-drawing.service';
Expand Down Expand Up @@ -39,7 +39,7 @@ export class WrongGuessComponent implements OnInit, OnDestroy {

ngOnInit(): void {
this.label = this.drawingService.lastResult.word;
this.guess = this.drawingService.lastResult.guess;
this.updateAiGuess(this.drawingService.sortedCertainty);

if (this.gameStateService.isSingleplayer()) {
this.exampleDrawings = this.exampleDrawingService.getExampleDrawings(2);
Expand Down Expand Up @@ -80,4 +80,10 @@ export class WrongGuessComponent implements OnInit, OnDestroy {
})
);
}
updateAiGuess(sortedCertaintyArr: Certainty[]) {
if (sortedCertaintyArr && sortedCertaintyArr.length > 1) {
const bestGuess = sortedCertaintyArr[0].label;
this.guess = bestGuess === this.label ? sortedCertaintyArr[1].label : bestGuess;
}
}
}
3 changes: 2 additions & 1 deletion src/app/game/services/drawing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
PredictionData,
Score,
} from '@/app/shared/models/backend-interfaces';
import { Result } from '@/app/shared/models/interfaces';
import { Certainty, Result } from '@/app/shared/models/interfaces';
import { ResultsMock } from '@/app/shared/mocks/results.mock';
import { endpoints } from '@/app/shared/models/endpoints';
import { TranslationService } from '@/app/core/translation.service';
Expand All @@ -30,6 +30,7 @@ export class DrawingService {
classificationDone = false;
guess = '';
secondsUsedOnLastRound = 0;
sortedCertainty: Certainty[] = [];

private readonly _guessUsed = new BehaviorSubject<number>(1);
private readonly _gameOver = new BehaviorSubject<boolean>(false);
Expand Down

0 comments on commit ecc016c

Please sign in to comment.