Skip to content

Commit

Permalink
Merge branch 'develop' into docker_frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan-Computas authored Oct 11, 2024
2 parents de18473 + ecf5c39 commit 370c76b
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 29 deletions.
9 changes: 7 additions & 2 deletions src/app/game/game-draw/game-draw.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ export class GameDrawComponent implements OnInit, OnDestroy {
if (this.gameStateService.isSingleplayer() && !this.drawingService.hasAddedSingleplayerResult) {
let res;
let hasWon = false;

if (this.isBlankImage) {
return;
}

if (!this.drawingService.pred) {
res = this.drawingService.createDefaultResult();
} else {
Expand Down Expand Up @@ -338,12 +343,13 @@ export class GameDrawComponent implements OnInit, OnDestroy {
if (sortedCertaintyArr && sortedCertaintyArr.length > 1) {
const guess = sortedCertaintyArr[0].label;
this.AI_GUESS = guess === this.guessWord ? sortedCertaintyArr[1].label : guess;
} else if (sortedCertaintyArr[0].label === "blank") {
this.AI_GUESS = "";
}
}

handleSinglePlayerClassification(dataUrl: string, croppedCoordinates: number[]) {
const formData: FormData = this.createFormData(dataUrl);

this.drawingService.classify(formData).subscribe((res) => {
const sortedCertaintyArr = this.sortOnCertainty(res);
this.updateAiGuess(sortedCertaintyArr);
Expand Down Expand Up @@ -375,7 +381,6 @@ export class GameDrawComponent implements OnInit, OnDestroy {
}

classify(isMultiplayer = false) {
//TODO: rename?
this.drawnPixelsAtLastGuess = this.drawnPixels;
const b64Image = this.canvas.nativeElement.toDataURL('image/png');
const croppedCoordinates: number[] = this.imageService.crop(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export class WrongGuessComponent implements OnInit, OnDestroy {
ngOnInit(): void {
this.label = this.drawingService.lastResult.word;
this.updateAiGuess(this.drawingService.sortedCertainty);

if (this.gameStateService.isSingleplayer()) {
this.exampleDrawings = this.exampleDrawingService.getExampleDrawings(2);
this.getSingleplayerExamples();
Expand All @@ -55,6 +54,9 @@ export class WrongGuessComponent implements OnInit, OnDestroy {
}

getSingleplayerExamples() {
if (this.guess === "") {
return
}
this.aiGuessSubscription.add(
this.exampleDrawingService
.getExampleDrawingsFromLabel(2, this.guess, this.translationService.getCurrentLang())
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../variables.scss';
@import '../../../variables.scss';

.container {
position: relative;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { Component, OnInit, OnDestroy, inject } from '@angular/core';
import { MultiplayerService } from '../game/services/multiplayer.service';
import { DrawingService } from '../game/services/drawing.service';
import { MultiplayerService } from '../services/multiplayer.service';
import { DrawingService } from '../services/drawing.service';
import { Router, RouterLink, RouterLinkActive } from '@angular/router';
import { MatIcon } from '@angular/material/icon';
import { MatButton } from '@angular/material/button';
import { TranslationService } from '../core/translation.service';
import { TranslatePipe } from '../core/translation.pipe';
import { TranslationService } from '../../core/translation.service';
import { TranslatePipe } from '../../core/translation.pipe';
import { Observable, Subject, takeUntil } from 'rxjs';
import { CommonModule } from '@angular/common';
import { GAMESTATE } from '../shared/models/interfaces';
import { GameStateService } from '../game/services/game-state-service';
import { SupportedLanguages } from '../shared/models/interfaces';
import { GAMESTATE } from '../../shared/models/interfaces';
import { GameStateService } from '../services/game-state-service';
import { SupportedLanguages } from '../../shared/models/interfaces';
import { ArrowAlignment, PointerSide } from '@/app/shared/models/interfaces';
import { trigger, state, style, animate, transition } from '@angular/animations';
import { SpeechBubbleComponent } from '../game/shared-components/speech-bubble/speech-bubble.component';
import { CustomColorsIO } from '../shared/customColors';
import { CustomButtonComponent } from '../game/shared-components/custom-button/custom-button.component';
import { SpeechBubbleComponent } from '../shared-components/speech-bubble/speech-bubble.component';
import { CustomColorsIO } from '../../shared/customColors';
import { CustomButtonComponent } from '../shared-components/custom-button/custom-button.component';
import { ButtonStyleClass } from '@/app/shared/buttonStyles';

@Component({
selector: 'app-welcome',
templateUrl: './welcome.component.html',
styleUrls: ['./welcome.component.scss'],
selector: 'app-game-welcome',
templateUrl: './game-welcome.component.html',
styleUrls: ['./game-welcome.component.scss'],
standalone: true,
imports: [
RouterLink,
Expand Down Expand Up @@ -53,7 +53,7 @@ import { ButtonStyleClass } from '@/app/shared/buttonStyles';
]),
],
})
export class WelcomeComponent implements OnInit, OnDestroy {
export class GameWelcomeComponent implements OnInit, OnDestroy {
currentLang$: Observable<string>;
private destroy$ = new Subject<void>();
private animationTimeouts: NodeJS.Timeout[] = [];
Expand Down
4 changes: 2 additions & 2 deletions src/app/game/game-word-to-draw/game-word-to-draw.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export class GameWordToDrawComponent implements OnInit, OnDestroy {
if (this.drawingService.gameHasStarted) {
this.subscriptions.add(
this.drawingService.getLabel().subscribe({
next: (res) => {
this.label = res.label;
next: () => {
this.label = this.drawingService.label;
this.loading = false;
},
error: (error) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/game/game.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
</div>
} @case (GAMESTATE.lobby) {
<div [@enterAnimation]>
<app-welcome></app-welcome>
<app-game-welcome></app-game-welcome>
</div>
} }
4 changes: 2 additions & 2 deletions src/app/game/game.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { GameInfoComponent } from './game-info/game-info.component';
import { GamePickDifficultyComponent } from './game-pick-difficulty/game-pick-difficulty.component';
import { GameStateService } from './services/game-state-service';
import { LobbyComponent } from './game-multiplayer/lobby/lobby.component';
import { WelcomeComponent } from '../welcome/welcome.component';
import { GameWelcomeComponent } from '../game/game-welcome/game-welcome.component';

@Component({
selector: 'app-game',
Expand Down Expand Up @@ -49,7 +49,7 @@ import { WelcomeComponent } from '../welcome/welcome.component';
GameResultComponent,
GameWordToDrawComponent,
LobbyComponent,
WelcomeComponent,
GameWelcomeComponent,
],
})
export class GameComponent implements OnInit {
Expand Down
4 changes: 0 additions & 4 deletions src/app/game/services/drawing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export class DrawingService {
config = this.gameConfigService.getConfig;

playerid = '';
labels = [];
label = '';
gameHasStarted = false;
classificationDone = false;
Expand Down Expand Up @@ -142,9 +141,6 @@ export class DrawingService {
);
}




getLabel(): Observable<GameLabel> {
const currentLang = this.translationService.getCurrentLang();
return this.http
Expand Down
4 changes: 2 additions & 2 deletions src/app/routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Routes } from '@angular/router';
import { SplashComponent } from './splash/splash.component';
import { WelcomeComponent } from './welcome/welcome.component';
import { GameWelcomeComponent } from './game/game-welcome/game-welcome.component';
import { GameComponent } from './game/game.component';
import { routes as r } from './shared/models/routes';
import { GameResultComponent } from './game/game-result/game-result.component';
Expand All @@ -18,7 +18,7 @@ export const routes: Routes = [
},
{
path: r.WELCOME,
component: WelcomeComponent,
component: GameWelcomeComponent,
data: { animationState: 'welcome' },
},
{
Expand Down

0 comments on commit 370c76b

Please sign in to comment.