Commit e5288479 authored by Dennis Willers's avatar Dennis Willers 🏀

Show different cards

parent 76299016
...@@ -38,4 +38,9 @@ export class TabuMiddlewareService { ...@@ -38,4 +38,9 @@ export class TabuMiddlewareService {
console.log(req); console.log(req);
return this.request('POST', `${environment.tabuMiddlewareURL}getGamestatus`, req); return this.request('POST', `${environment.tabuMiddlewareURL}getGamestatus`, req);
} }
getS2C(req: any): Promise<any> {
console.log(req);
return this.request('POST', `${environment.tabuMiddlewareURL}getS2C`, req);
}
} }
...@@ -2,34 +2,34 @@ ...@@ -2,34 +2,34 @@
<p>Punktestand: {{points}}</p> <p>Punktestand: {{points}}</p>
<mat-card> <mat-card>
<h1> <h1>
{{word}} {{cardInfo.solution}}
</h1> </h1>
</mat-card> </mat-card>
<br> <br>
<mat-card> <mat-card>
<h2> <h2>
{{forbidden1}} {{cardInfo.tabu1}}
</h2> </h2>
</mat-card> </mat-card>
<mat-card> <mat-card>
<h2> <h2>
{{forbidden2}} {{cardInfo.tabu2}}
</h2> </h2>
</mat-card> </mat-card>
<mat-card> <mat-card>
<h2> <h2>
{{forbidden3}} {{cardInfo.tabu3}}
</h2> </h2>
</mat-card> </mat-card>
<mat-card> <mat-card>
<h2> <h2>
{{forbidden4}} {{cardInfo.tabu4}}
</h2> </h2>
</mat-card> </mat-card>
<mat-card> <mat-card>
<h2> <h2>
{{forbidden5}} {{cardInfo.tabu5}}
</h2> </h2>
</mat-card> </mat-card>
<br> <br>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {ProgressSpinnerMode} from '@angular/material/progress-spinner'; import {ProgressSpinnerMode} from '@angular/material/progress-spinner';
import {CardInfo} from '../interface/cardInfo';
import {TabuMiddlewareService} from '../dao/TabuMiddlewareService';
import {ActivatedRoute} from '@angular/router';
@Component({ @Component({
selector: 'app-game', selector: 'app-game',
templateUrl: './game.component.html', templateUrl: './game.component.html',
...@@ -7,21 +10,45 @@ import {ProgressSpinnerMode} from '@angular/material/progress-spinner'; ...@@ -7,21 +10,45 @@ import {ProgressSpinnerMode} from '@angular/material/progress-spinner';
}) })
export class GameComponent implements OnInit { export class GameComponent implements OnInit {
word = 'Hund'; sessionName = '';
forbidden1 = 'Haustier'; cardInfo: CardInfo = {
forbidden2 = 'Katze'; cardID: -1,
forbidden3 = 'Gassi'; solution: '',
forbidden4 = 'Leine'; tabu1: '',
forbidden5 = 'Welpe'; tabu2: '',
tabu3: '',
tabu4: '',
tabu5: ''
};
points = 0; points = 0;
color = 'primary'; color = 'primary';
mode: ProgressSpinnerMode = 'determinate'; mode: ProgressSpinnerMode = 'determinate';
value = 50; value = 50;
constructor() { } constructor(private service: TabuMiddlewareService,
private activatedRoute: ActivatedRoute) {}
ngOnInit(): void { ngOnInit(): void {
this.activatedRoute.paramMap.subscribe(params => {
this.sessionName = String(params.get('sessionName'));
this.service.getS2C({spielname: this.sessionName}).then(value => {
console.log('Test1:', value);
const status = JSON.parse(value.status);
if (status) {
console.log('Test2:', value);
this.cardInfo.cardID = JSON.parse(value.cardID);
this.cardInfo.solution = value.solution;
this.cardInfo.tabu1 = value.tabu1;
this.cardInfo.tabu2 = value.tabu2;
this.cardInfo.tabu3 = value.tabu3;
this.cardInfo.tabu4 = value.tabu4;
this.cardInfo.tabu5 = value.tabu5;
}
console.log(this.cardInfo);
}).catch(reason => console.log(reason));
});
} }
rightAnswer(): void{ rightAnswer(): void{
this.points += 1; this.points += 1;
} }
......
export interface CardInfo {
cardID: number;
solution: string;
tabu1: string;
tabu2: string;
tabu3: string;
tabu4: string;
tabu5: string;
}
...@@ -27,8 +27,7 @@ export class OverviewComponent implements OnInit { ...@@ -27,8 +27,7 @@ export class OverviewComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
this.sessionName = String(params.get('sessionName')); this.sessionName = String(params.get('sessionName'));
console.log('SessionName: ', this.sessionName); this.service.getGamestatus({'spielname': this.sessionName}).then(value => {
this.service.getGamestatus({"spielname": this.sessionName}).then(value => {
const status = JSON.parse(value.status); const status = JSON.parse(value.status);
if (status) { if (status) {
this.gameStatus.sessionID = JSON.parse(value.sessionID); this.gameStatus.sessionID = JSON.parse(value.sessionID);
...@@ -44,6 +43,6 @@ export class OverviewComponent implements OnInit { ...@@ -44,6 +43,6 @@ export class OverviewComponent implements OnInit {
} }
startGame(): void { startGame(): void {
this.router.navigate([this.router.url+'/red/watchdog']); this.router.navigate([this.router.url + '/red/watchdog']);
} }
} }
...@@ -12,19 +12,19 @@ export class SelectGameComponent implements OnInit { ...@@ -12,19 +12,19 @@ export class SelectGameComponent implements OnInit {
buttonCreateGameDisabled = true; buttonCreateGameDisabled = true;
buttonJoinGameDisabled = true; buttonJoinGameDisabled = true;
constructor(private router: Router, constructor(private router: Router,
private server: TabuMiddlewareService) { } private service: TabuMiddlewareService) { }
ngOnInit(): void { ngOnInit(): void {
} }
getSpielSessions(): any { getSpielSessions(): any {
console.log('Start'); console.log('Start');
const response = this.server.getSessions(); const response = this.service.getSessions();
console.log('Response:', response); console.log('Response:', response);
} }
createGame(sessionName: string): void { createGame(sessionName: string): void {
this.server.addSession({"spielname": sessionName}).then(value => { this.service.addSession({spielname: sessionName}).then(value => {
console.log(value); console.log(value);
const status = JSON.parse(value.status); const status = JSON.parse(value.status);
if (status) { if (status) {
...@@ -55,7 +55,7 @@ export class SelectGameComponent implements OnInit { ...@@ -55,7 +55,7 @@ export class SelectGameComponent implements OnInit {
this.buttonJoinGameDisabled = true; this.buttonJoinGameDisabled = true;
return; return;
} else { } else {
this.server.isSession({'spielname': sessionName}).then(value => { this.service.isSession({'spielname': sessionName}).then(value => {
console.log('Response: ', value.status); console.log('Response: ', value.status);
const status = JSON.parse(value.status); const status = JSON.parse(value.status);
if (status) { if (status) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment