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

Show different cards

parent 76299016
......@@ -38,4 +38,9 @@ export class TabuMiddlewareService {
console.log(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 @@
<p>Punktestand: {{points}}</p>
<mat-card>
<h1>
{{word}}
{{cardInfo.solution}}
</h1>
</mat-card>
<br>
<mat-card>
<h2>
{{forbidden1}}
{{cardInfo.tabu1}}
</h2>
</mat-card>
<mat-card>
<h2>
{{forbidden2}}
{{cardInfo.tabu2}}
</h2>
</mat-card>
<mat-card>
<h2>
{{forbidden3}}
{{cardInfo.tabu3}}
</h2>
</mat-card>
<mat-card>
<h2>
{{forbidden4}}
{{cardInfo.tabu4}}
</h2>
</mat-card>
<mat-card>
<h2>
{{forbidden5}}
{{cardInfo.tabu5}}
</h2>
</mat-card>
<br>
......
import { Component, OnInit } from '@angular/core';
import {ProgressSpinnerMode} from '@angular/material/progress-spinner';
import {CardInfo} from '../interface/cardInfo';
import {TabuMiddlewareService} from '../dao/TabuMiddlewareService';
import {ActivatedRoute} from '@angular/router';
@Component({
selector: 'app-game',
templateUrl: './game.component.html',
......@@ -7,21 +10,45 @@ import {ProgressSpinnerMode} from '@angular/material/progress-spinner';
})
export class GameComponent implements OnInit {
word = 'Hund';
forbidden1 = 'Haustier';
forbidden2 = 'Katze';
forbidden3 = 'Gassi';
forbidden4 = 'Leine';
forbidden5 = 'Welpe';
sessionName = '';
cardInfo: CardInfo = {
cardID: -1,
solution: '',
tabu1: '',
tabu2: '',
tabu3: '',
tabu4: '',
tabu5: ''
};
points = 0;
color = 'primary';
mode: ProgressSpinnerMode = 'determinate';
value = 50;
constructor() { }
constructor(private service: TabuMiddlewareService,
private activatedRoute: ActivatedRoute) {}
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{
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 {
ngOnInit(): void {
this.activatedRoute.paramMap.subscribe(params => {
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);
if (status) {
this.gameStatus.sessionID = JSON.parse(value.sessionID);
......@@ -44,6 +43,6 @@ export class OverviewComponent implements OnInit {
}
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 {
buttonCreateGameDisabled = true;
buttonJoinGameDisabled = true;
constructor(private router: Router,
private server: TabuMiddlewareService) { }
private service: TabuMiddlewareService) { }
ngOnInit(): void {
}
getSpielSessions(): any {
console.log('Start');
const response = this.server.getSessions();
const response = this.service.getSessions();
console.log('Response:', response);
}
createGame(sessionName: string): void {
this.server.addSession({"spielname": sessionName}).then(value => {
this.service.addSession({spielname: sessionName}).then(value => {
console.log(value);
const status = JSON.parse(value.status);
if (status) {
......@@ -55,7 +55,7 @@ export class SelectGameComponent implements OnInit {
this.buttonJoinGameDisabled = true;
return;
} else {
this.server.isSession({'spielname': sessionName}).then(value => {
this.service.isSession({'spielname': sessionName}).then(value => {
console.log('Response: ', value.status);
const status = JSON.parse(value.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