Commit fc9c0a6a authored by Isabell Heider's avatar Isabell Heider

Update

parent 8924c4d8
Pipeline #300 passed with stages
in 5 minutes and 35 seconds
...@@ -7,6 +7,10 @@ import {GameComponent} from './game/game.component'; ...@@ -7,6 +7,10 @@ import {GameComponent} from './game/game.component';
import {GuesserComponent} from './guesser/guesser.component'; import {GuesserComponent} from './guesser/guesser.component';
const routes: Routes = [ const routes: Routes = [
{
path: 'error',
component: ErrorComponent,
},
{ {
path: ':sessionName', path: ':sessionName',
component: OverviewComponent, component: OverviewComponent,
...@@ -34,7 +38,7 @@ const routes: Routes = [ ...@@ -34,7 +38,7 @@ const routes: Routes = [
{ {
path: '**', path: '**',
component: ErrorComponent, component: ErrorComponent,
} },
]; ];
@NgModule({ @NgModule({
......
<div fxLayout="column" fxFlexFill style="background-image: url(/assets/background.jpg)"> <div fxLayout="column" fxFlexFill style="background-image: url(/assets/background.jpg); background-repeat: repeat;" >
<app-header> <app-header>
</app-header> </app-header>
<div fxFlex> <div fxFlex>
......
<div style="text-align: center; margin-left: 15em; margin-right: 15em; margin-top: 5em;"> <div style="text-align: center; margin-left: 15em; margin-right: 15em; margin-top: 5em;">
<p>Punktestand: {{points}}</p>
<div id="app"></div> <div id="app"></div>
<mat-card> <mat-card>
<h1> <h1>
...@@ -35,6 +34,23 @@ ...@@ -35,6 +34,23 @@
</mat-card> </mat-card>
<br> <br>
<button mat-raised-button color="primary" (click)="rightAnswer()">Richtig &#10004;</button> <button mat-raised-button color="primary" (click)="rightAnswer()">Richtig &#10004;</button>
<button mat-raised-button color="accent" style="margin: 40px">Überspringen &#187;</button> <button mat-raised-button color="accent" style="margin: 40px" (click)="newCard()">Überspringen &#187;</button>
<button mat-raised-button color="warn" (click)="wrongAnswer()">Tabu &#10008;</button> <button mat-raised-button color="warn" (click)="wrongAnswer()">Tabu &#10008;</button>
<br>
<mat-card class="transparent">
<mat-card-title>Spielstand</mat-card-title>
<mat-card-content>
<br>
<table>
<tr>
<th>Team rot</th>
<th>Team blau</th>
</tr>
<tr>
<th>{{gameStatus.red}}</th>
<th>{{gameStatus.blue}}</th>
</tr>
</table>
</mat-card-content>
</mat-card>
</div> </div>
table {
width: 50%;
margin-left: auto;
margin-right: auto;
}
.transparent{
opacity: 0.9;
}
body { body {
font-family: sans-serif; font-family: sans-serif;
......
...@@ -3,6 +3,8 @@ import {ProgressSpinnerMode} from '@angular/material/progress-spinner'; ...@@ -3,6 +3,8 @@ import {ProgressSpinnerMode} from '@angular/material/progress-spinner';
import {CardInfo} from '../interface/cardInfo'; import {CardInfo} from '../interface/cardInfo';
import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {TabuMiddlewareService} from '../dao/TabuMiddlewareService';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {GameStatus} from '../interface/gameStatus';
@Component({ @Component({
selector: 'app-game', selector: 'app-game',
templateUrl: './game.component.html', templateUrl: './game.component.html',
...@@ -20,7 +22,16 @@ export class GameComponent implements OnInit { ...@@ -20,7 +22,16 @@ export class GameComponent implements OnInit {
tabu4: '', tabu4: '',
tabu5: '' tabu5: ''
}; };
points = 0;
gameStatus: GameStatus = {
sessionID: -1,
red: 0,
blue: 0,
redTurn: true,
activeExplainer: false,
activeWatchdog: false
};
team = '';
color = 'primary'; color = 'primary';
mode: ProgressSpinnerMode = 'determinate'; mode: ProgressSpinnerMode = 'determinate';
...@@ -31,6 +42,34 @@ export class GameComponent implements OnInit { ...@@ -31,6 +42,34 @@ export class GameComponent 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'));
this.service.getGamestatus({'spielname': this.sessionName}).then(value => {
const status = JSON.parse(value.status);
if (status) {
this.gameStatus.sessionID = JSON.parse(value.sessionID);
this.gameStatus.red = JSON.parse(value.red);
this.gameStatus.blue = JSON.parse(value.blue);
this.gameStatus.redTurn = JSON.parse(value.redTurn);
this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer);
this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog);
}
console.log(this.gameStatus);
}),
this.team = String(params.get('team'));
this.newCard();
});
}
rightAnswer(): void{
this.newCard();
this.service.addPoint({spielname: this.sessionName, team: this.team});
}
wrongAnswer(): void{
this.newCard();
this.service.removePoint({spielname: this.sessionName, team: this.team});
}
newCard(): void{
this.service.getS2C({spielname: this.sessionName}).then(value => { this.service.getS2C({spielname: this.sessionName}).then(value => {
console.log('Test1:', value); console.log('Test1:', value);
const status = JSON.parse(value.status); const status = JSON.parse(value.status);
...@@ -46,14 +85,5 @@ export class GameComponent implements OnInit { ...@@ -46,14 +85,5 @@ export class GameComponent implements OnInit {
} }
console.log(this.cardInfo); console.log(this.cardInfo);
}).catch(reason => console.log(reason)); }).catch(reason => console.log(reason));
});
}
rightAnswer(): void{
this.points += 1;
}
wrongAnswer(): void{
this.points -= 1;
} }
} }
<div style="text-align: center; margin-left: 15em; margin-right: 15em; margin-top: 5em;"> <div style="text-align: center; margin-left: 15em; margin-right: 15em; margin-top: 5em;">
<mat-card class="transparent"> <mat-card class="transparent">
<h1> <mat-card-title> Du musst raten!
Du musst raten!
</h1> Spielstand</mat-card-title>
<p>Punktestand: {{points}}</p> <mat-card-content>
</mat-card> <br>
<table>
<tr>
<th>Team rot</th>
<th>Team blau</th>
</tr>
<tr>
<th>{{gameStatus.red}}</th>
<th>{{gameStatus.blue}}</th>
</tr>
</table>
</mat-card-content>
<br> <br>
<mat-progress-spinner color="primary" mode="determinate" value="value"> <mat-progress-spinner color="primary" mode="determinate" value="value">
</mat-progress-spinner> </mat-progress-spinner>
</mat-card>
</div> </div>
<div id="app"></div> <div id="app"></div>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {TabuMiddlewareService} from '../dao/TabuMiddlewareService';
import {GameStatus} from '../interface/gameStatus';
declare function testJS(): any; declare function testJS(): any;
...@@ -9,11 +11,34 @@ declare function testJS(): any; ...@@ -9,11 +11,34 @@ declare function testJS(): any;
styleUrls: ['./guesser.component.scss'] styleUrls: ['./guesser.component.scss']
}) })
export class GuesserComponent implements OnInit { export class GuesserComponent implements OnInit {
points = 0; sessionName = '';
gameStatus: GameStatus = {
sessionID: -1,
red: 0,
blue: 0,
redTurn: true,
activeExplainer: false,
activeWatchdog: false
};
constructor() { } constructor(private activatedRoute: ActivatedRoute, private service: TabuMiddlewareService) { }
ngOnInit(): void { ngOnInit(): void {
this.activatedRoute.paramMap.subscribe(params => {
this.sessionName = String(params.get('sessionName'));
this.service.getGamestatus({'spielname': this.sessionName}).then(value => {
const status = JSON.parse(value.status);
if (status) {
this.gameStatus.sessionID = JSON.parse(value.sessionID);
this.gameStatus.red = JSON.parse(value.red);
this.gameStatus.blue = JSON.parse(value.blue);
this.gameStatus.redTurn = JSON.parse(value.redTurn);
this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer);
this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog);
}
console.log(this.gameStatus);
});
});
testJS(); testJS();
} }
} }
<div style="text-align: center; margin-left: 15em; margin-right: 15em; margin-top: 5em;"> <div style="text-align: center; margin-left: 15em; margin-right: 15em; margin-top: 5em;">
<mat-card class="transparent"> <mat-card class="transparent">
<h2>Wähle dein Team</h2> <h2>{{membership}}</h2>
<mat-icon color = "disabled" aria-hidden="false" aria-label="home icon blue">home</mat-icon> <button class = "red" (click)="joinTeam('red')">
Team grau <mat-slide-toggle color = "warn"> Team rot</mat-slide-toggle>
<mat-icon color = "warn" aria-hidden="false" aria-label="home icon red">home</mat-icon> <mat-icon color = "warn" aria-hidden="false" aria-label="home icon red">home</mat-icon>
</button>
<button class = "blue" (click)="joinTeam('blue')">
<mat-icon style="color: darkblue" aria-hidden="false" aria-label="home icon blue">home</mat-icon>
</button>
</mat-card> </mat-card>
<br> <br>
<br> <br>
...@@ -18,8 +22,8 @@ ...@@ -18,8 +22,8 @@
<th>Team blau</th> <th>Team blau</th>
</tr> </tr>
<tr> <tr>
<th>0</th> <th>{{gameStatus.red}}</th>
<th>0</th> <th>{{gameStatus.blue}}</th>
</tr> </tr>
</table> </table>
</mat-card-content> </mat-card-content>
......
...@@ -7,3 +7,21 @@ table { ...@@ -7,3 +7,21 @@ table {
.transparent { .transparent {
opacity: 0.9; opacity: 0.9;
} }
.blue{
border-color: darkblue;
margin: 5px;
cursor: pointer;
}
.red{
border-color: red;
margin: 5px;
cursor: pointer;
}
.button:active
{
background-color:darkred;
}
...@@ -9,8 +9,9 @@ import {GameStatus} from '../interface/gameStatus'; ...@@ -9,8 +9,9 @@ import {GameStatus} from '../interface/gameStatus';
styleUrls: ['./overview.component.scss'] styleUrls: ['./overview.component.scss']
}) })
export class OverviewComponent implements OnInit { export class OverviewComponent implements OnInit {
team = '';
sessionName = ''; sessionName = '';
membership = 'Wähle dein Team';
gameStatus: GameStatus = { gameStatus: GameStatus = {
sessionID: -1, sessionID: -1,
red: 0, red: 0,
...@@ -27,6 +28,21 @@ export class OverviewComponent implements OnInit { ...@@ -27,6 +28,21 @@ 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'));
this.team = String(params.get('team'));
console.log('Team:', this.team);
if (this.team === 'red'){
this.membership = 'Du gehörst zu Team rot!';
}
else if (this.team === 'blue'){
this.membership = 'Du gehörst zu Team blau!';
}
else if (this.team === 'null'){
this.membership = 'Wähle dein Team';
}
else {
this.router.navigate(['error']);
return;
}
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) {
...@@ -43,6 +59,13 @@ export class OverviewComponent implements OnInit { ...@@ -43,6 +59,13 @@ export class OverviewComponent implements OnInit {
} }
startGame(): void { startGame(): void {
this.router.navigate([this.router.url + '/red/watchdog']); if (this.team === 'red' || this.team === 'blue')
{
this.router.navigate([this.router.url + '/watchdog']);
}
}
joinTeam(team: string): void {
this.team = team;
this.router.navigate([this.sessionName + '/' + team]);
} }
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<form> <form>
<mat-form-field> <mat-form-field>
<mat-label>Spielname</mat-label> <mat-label>Spielname</mat-label>
<input #sessionName type="text" matInput (keyup)="checkSpielname(sessionName.value)" (keypress)="keyPressAlphaNumeric($event)"> <input #sessionName type="text" matInput (keyup)="checkSpielname(sessionName.value)" (keypress)="keyPressAlphaNumeric($event)" (keyup.enter)="enter(sessionName.value)">
</mat-form-field> </mat-form-field>
</form> </form>
</mat-card-content> </mat-card-content>
......
...@@ -49,6 +49,15 @@ export class SelectGameComponent implements OnInit { ...@@ -49,6 +49,15 @@ export class SelectGameComponent implements OnInit {
} }
} }
enter(sessionName: string): void{
if (!this.buttonCreateGameDisabled){
this.createGame(sessionName);
}
if (!this.buttonJoinGameDisabled){
this.joinGame(sessionName);
}
}
checkSpielname(sessionName: string): void { checkSpielname(sessionName: string): void {
if (sessionName.length === 0) { if (sessionName.length === 0) {
this.buttonCreateGameDisabled = true; this.buttonCreateGameDisabled = true;
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
export const environment = { export const environment = {
production: false, production: false,
tabuMiddlewareURL: 'http://localhost:8080/' // tabuMiddlewareURL: 'http://localhost:8080/'
//tabuMiddlewareURL: 'http://tabu-middleware.willers.digital/' tabuMiddlewareURL: 'http://tabu-middleware.willers.digital/'
}; };
/* /*
......
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