Compare commits
10 Commits
7c3404acb0
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
8d6129590a
|
|||
|
13aa2c29b0
|
|||
|
5f256e1983
|
|||
|
4dbc6a2a4d
|
|||
|
e26cd21cc6
|
|||
|
139fb20814
|
|||
|
1027011447
|
|||
|
b09b683727
|
|||
|
aec84dca5d
|
|||
|
7082abcdf7
|
@@ -47,10 +47,23 @@
|
|||||||
<button (click)="switchToNextPage()" [disabled]="!calculatePointSum()">Next</button>
|
<button (click)="switchToNextPage()" [disabled]="!calculatePointSum()">Next</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="which-solo" class="visible-{{this.currentPage === 4}}">
|
<div id="which-solo" class="visible-{{this.currentPage === 4}}">
|
||||||
|
<p>Select the Solo that has been played:</p>
|
||||||
|
<div class="togglebtn active-{{isSoloActive(solo)}}" *ngFor="let solo of getAllPossibleSolos()" (click)="toggleSolo(solo)">{{solo.toString()}}</div>
|
||||||
|
<p id="solo-warn" *ngIf="noSoloSelectedYet()">Please select a solo to continue</p>
|
||||||
|
<button (click)="switchToNextPage()" [disabled]="noSoloSelectedYet()">Next</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="extra-points" class="visible-{{this.currentPage === 5}}">
|
<div id="extra-points" class="visible-{{this.currentPage === 5}}">
|
||||||
|
<p>Extra Points</p>
|
||||||
|
<div *ngFor="let player of actualPlayers">
|
||||||
|
<p>{{player.firstName}}</p>
|
||||||
|
<input type="number" [(ngModel)]="player.foxesCaught" (change)="this.calculateCurrentScores()"/>
|
||||||
|
</div>
|
||||||
|
<p id="foxes-warn" *ngIf="!checkTotalFoxPoints()">Please check the number of caught foxes!</p>
|
||||||
|
<button (click)="switchToNextPage()" [disabled]="!checkAllExtraPoints()">Next</button>
|
||||||
|
</div>
|
||||||
|
<div id="summary" class="visible-{{this.currentPage === 6}}">
|
||||||
|
<p>Game Summary</p>
|
||||||
|
<button (click)="saveGame()">Save Game</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="scores">
|
<div id="scores">
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
color: $inactive;
|
color: $inactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
#player-amount-warn, #announcement-warn, #team-warn, #score-warn {
|
#player-amount-warn, #announcement-warn, #team-warn, #score-warn, #solo-warn {
|
||||||
color: $warn;
|
color: $warn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { AddGameComponent } from './add-game.component';
|
import { AddGameComponent } from './add-game.component';
|
||||||
|
import {Team} from '../../models/doppelkopf/enums/team';
|
||||||
|
|
||||||
describe('AddGameComponent', () => {
|
describe('AddGameComponent', () => {
|
||||||
let component: AddGameComponent;
|
let component: AddGameComponent;
|
||||||
@@ -20,4 +21,49 @@ describe('AddGameComponent', () => {
|
|||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should have the correct score for a normal game', () => {
|
||||||
|
// Set up testing data
|
||||||
|
component.actualPlayers = [
|
||||||
|
{
|
||||||
|
firebonkId: 1,
|
||||||
|
uuid: 'abc-def-ghi-j',
|
||||||
|
firstName: 'Patrick',
|
||||||
|
team: Team.RE,
|
||||||
|
gamePoints: 0,
|
||||||
|
finalCardScore: 123,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
firebonkId: 1,
|
||||||
|
uuid: 'abc-def-ghi-k',
|
||||||
|
firstName: 'Julian',
|
||||||
|
team: Team.RE,
|
||||||
|
gamePoints: 17,
|
||||||
|
finalCardScore: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
firebonkId: 1,
|
||||||
|
uuid: 'abc-def-ghi-l',
|
||||||
|
firstName: 'Yanick',
|
||||||
|
team: Team.CONTRA,
|
||||||
|
gamePoints: 50,
|
||||||
|
finalCardScore: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
firebonkId: 1,
|
||||||
|
uuid: 'abc-def-ghi-m',
|
||||||
|
firstName: 'Janina',
|
||||||
|
team: Team.CONTRA,
|
||||||
|
gamePoints: 50,
|
||||||
|
finalCardScore: 0,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
component.calculateCurrentScores();
|
||||||
|
|
||||||
|
expect(component.actualPlayers[0].gamePoints).toEqual(1);
|
||||||
|
expect(component.actualPlayers[1].gamePoints).toEqual(1);
|
||||||
|
expect(component.actualPlayers[2].gamePoints).toEqual(-1);
|
||||||
|
expect(component.actualPlayers[3].gamePoints).toEqual(-1);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {Player} from '../../models/doppelkopf/player';
|
import {Player} from '../../models/doppelkopf/player';
|
||||||
import * as announcements from '../../models/doppelkopf/enums/announcement';
|
import * as announcements from '../../models/doppelkopf/enums/announcement';
|
||||||
|
import * as solos from '../../models/doppelkopf/enums/solo';
|
||||||
import {Team} from '../../models/doppelkopf/enums/team';
|
import {Team} from '../../models/doppelkopf/enums/team';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -13,6 +14,7 @@ export class AddGameComponent implements OnInit {
|
|||||||
actualPlayers: Player[] = [];
|
actualPlayers: Player[] = [];
|
||||||
|
|
||||||
selectedAnnouncements: announcements.Announcement[] = [];
|
selectedAnnouncements: announcements.Announcement[] = [];
|
||||||
|
soloPlayed?: solos.Solo;
|
||||||
|
|
||||||
currentPage: number = 0;
|
currentPage: number = 0;
|
||||||
|
|
||||||
@@ -34,8 +36,8 @@ export class AddGameComponent implements OnInit {
|
|||||||
team: Team.CONTRA,
|
team: Team.CONTRA,
|
||||||
gamePoints: 0,
|
gamePoints: 0,
|
||||||
finalCardScore: 0,
|
finalCardScore: 0,
|
||||||
foxesCaught: 1,
|
// foxesCaught: 1,
|
||||||
wonLastTrickWithCharlie: true
|
// wonLastTrickWithCharlie: true
|
||||||
});
|
});
|
||||||
this.potentialPlayers.push({
|
this.potentialPlayers.push({
|
||||||
firebonkId: 2,
|
firebonkId: 2,
|
||||||
@@ -81,6 +83,11 @@ export class AddGameComponent implements OnInit {
|
|||||||
this.calculateCurrentScores();
|
this.calculateCurrentScores();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.currentPage === 3 && !this.checkIfSolo()) {
|
||||||
|
// If we don't play a solo, we can skip the solo page
|
||||||
|
this.currentPage++;
|
||||||
|
}
|
||||||
|
|
||||||
this.currentPage++;
|
this.currentPage++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,17 +391,23 @@ export class AddGameComponent implements OnInit {
|
|||||||
calculateCurrentScores(): void {
|
calculateCurrentScores(): void {
|
||||||
let gameScore: number = 0;
|
let gameScore: number = 0;
|
||||||
|
|
||||||
let winningTeamScore = this.getWinningTeamAndScore().score;
|
|
||||||
let winningTeam = this.getWinningTeamAndScore().team;
|
let winningTeam = this.getWinningTeamAndScore().team;
|
||||||
let unfulfilledAnnouncements = this.checkUnfulfilledAnnouncements(winningTeam, winningTeamScore);
|
let winningTeamScore = this.getWinningTeamAndScore().score;
|
||||||
let isSoloPlay = false;
|
let unfulfilledAnnouncementPoints = this.checkUnfulfilledAnnouncements(winningTeam, winningTeamScore);
|
||||||
|
let isSoloPlay = this.checkIfSolo();
|
||||||
|
|
||||||
// We are going to calculate the points for the winning team and then set all players points accordingly
|
// We are going to calculate the points for the winning team and then set all players points accordingly
|
||||||
|
|
||||||
if(!unfulfilledAnnouncements) {
|
if (unfulfilledAnnouncementPoints === 0) {
|
||||||
gameScore += this.calculateNormalScore(winningTeamScore, winningTeam);
|
gameScore += this.calculateNormalScore(winningTeamScore, winningTeam);
|
||||||
} else {
|
} else {
|
||||||
// TODO method to calculate game score for unfulfilled announcements
|
gameScore += unfulfilledAnnouncementPoints;
|
||||||
|
winningTeam = winningTeam === Team.RE ? Team.CONTRA : Team.RE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(winningTeam === Team.CONTRA) {
|
||||||
|
// Against the elders
|
||||||
|
gameScore++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Double Score in case of announcement
|
// Double Score in case of announcement
|
||||||
@@ -406,15 +419,20 @@ export class AddGameComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bonus points
|
// Bonus points
|
||||||
if(!isSoloPlay) {
|
if (!isSoloPlay) {
|
||||||
gameScore += this.getFinalFoxPoints(winningTeam);
|
gameScore += this.getFinalFoxPoints(winningTeam);
|
||||||
gameScore += this.getCharliePoints(winningTeam);
|
gameScore += this.getCharliePoints(winningTeam);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Game score in case of a solo
|
this.setGameScores(gameScore, winningTeam, isSoloPlay);
|
||||||
this.setGameScores(gameScore, winningTeam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the score according to card points and announcements in case of a "normal" game, so without unfulfilled announcements
|
||||||
|
* @param winningTeamScore
|
||||||
|
* @param winningTeam
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
private calculateNormalScore(winningTeamScore: number, winningTeam: Team): number {
|
private calculateNormalScore(winningTeamScore: number, winningTeam: Team): number {
|
||||||
let gameScore = 1; // 1 Point for Winning
|
let gameScore = 1; // 1 Point for Winning
|
||||||
|
|
||||||
@@ -430,24 +448,24 @@ export class AddGameComponent implements OnInit {
|
|||||||
// Announcements
|
// Announcements
|
||||||
if (winningTeam === Team.RE) {
|
if (winningTeam === Team.RE) {
|
||||||
if (this.checkAnnouncementActive(announcements.Announcement.RE_NO_NINETY) && winningTeamScore > 150) {
|
if (this.checkAnnouncementActive(announcements.Announcement.RE_NO_NINETY) && winningTeamScore > 150) {
|
||||||
gameScore += 1;
|
gameScore++;
|
||||||
}
|
}
|
||||||
if (this.checkAnnouncementActive(announcements.Announcement.RE_NO_SIXTY) && winningTeamScore > 180) {
|
if (this.checkAnnouncementActive(announcements.Announcement.RE_NO_SIXTY) && winningTeamScore > 180) {
|
||||||
gameScore += 1;
|
gameScore++;
|
||||||
}
|
}
|
||||||
if (this.checkAnnouncementActive(announcements.Announcement.RE_NO_THIRTY) && winningTeamScore > 210) {
|
if (this.checkAnnouncementActive(announcements.Announcement.RE_NO_THIRTY) && winningTeamScore > 210) {
|
||||||
gameScore += 1;
|
gameScore++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (winningTeam === Team.CONTRA) {
|
if (winningTeam === Team.CONTRA) {
|
||||||
if (this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_NINETY) && winningTeamScore > 150) {
|
if (this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_NINETY) && winningTeamScore > 150) {
|
||||||
gameScore += 1;
|
gameScore++;
|
||||||
}
|
}
|
||||||
if (this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_SIXTY) && winningTeamScore > 180) {
|
if (this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_SIXTY) && winningTeamScore > 180) {
|
||||||
gameScore += 1;
|
gameScore++;
|
||||||
}
|
}
|
||||||
if (this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_THIRTY) && winningTeamScore > 210) {
|
if (this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_THIRTY) && winningTeamScore > 210) {
|
||||||
gameScore += 1;
|
gameScore++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,10 +520,14 @@ export class AddGameComponent implements OnInit {
|
|||||||
* @param score The score to set
|
* @param score The score to set
|
||||||
* @param winningTeam The team that won
|
* @param winningTeam The team that won
|
||||||
*/
|
*/
|
||||||
setGameScores(score: number, winningTeam: Team) {
|
setGameScores(score: number, winningTeam: Team, isSolo: boolean) {
|
||||||
for (let player of this.actualPlayers) {
|
for (let player of this.actualPlayers) {
|
||||||
if (player.team === winningTeam) {
|
if (player.team === winningTeam) {
|
||||||
player.gamePoints = score;
|
if(isSolo) {
|
||||||
|
player.gamePoints = score * 3;
|
||||||
|
} else {
|
||||||
|
player.gamePoints = score;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
player.gamePoints = -score;
|
player.gamePoints = -score;
|
||||||
}
|
}
|
||||||
@@ -557,8 +579,8 @@ export class AddGameComponent implements OnInit {
|
|||||||
* @param winningTeam The winning team
|
* @param winningTeam The winning team
|
||||||
*/
|
*/
|
||||||
getCharliePoints(winningTeam: Team): number {
|
getCharliePoints(winningTeam: Team): number {
|
||||||
for(let player of this.actualPlayers) {
|
for (let player of this.actualPlayers) {
|
||||||
if(player.wonLastTrickWithCharlie) {
|
if (player.wonLastTrickWithCharlie) {
|
||||||
return player.team === winningTeam ? 1 : -1;
|
return player.team === winningTeam ? 1 : -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -566,34 +588,136 @@ export class AddGameComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the winning team has made announcements that have not been fulfilled
|
* Checks if the winning team has made announcements that have not been fulfilled.
|
||||||
|
* If so, returns the points that the "losing" team gets for these unfulfilled announcements
|
||||||
* @param normalWinningTeam The team that would have won under normal circumstances
|
* @param normalWinningTeam The team that would have won under normal circumstances
|
||||||
* @param normalWinningTeamScore The card score of said team
|
* @param normalWinningTeamScore The card score of said team
|
||||||
*/
|
*/
|
||||||
checkUnfulfilledAnnouncements(normalWinningTeam: Team, normalWinningTeamScore: number): boolean {
|
checkUnfulfilledAnnouncements(normalWinningTeam: Team, normalWinningTeamScore: number): number {
|
||||||
if(normalWinningTeam === Team.RE) {
|
let gamePoints = 0;
|
||||||
if(this.checkAnnouncementActive(announcements.Announcement.RE_NO_NINETY) && normalWinningTeamScore < 151) {
|
|
||||||
return true;
|
if (normalWinningTeam === Team.RE) {
|
||||||
|
if (this.checkAnnouncementActive(announcements.Announcement.RE_NO_NINETY) && normalWinningTeamScore < 151) {
|
||||||
|
gamePoints++;
|
||||||
}
|
}
|
||||||
if(this.checkAnnouncementActive(announcements.Announcement.RE_NO_SIXTY) && normalWinningTeamScore < 181) {
|
if (this.checkAnnouncementActive(announcements.Announcement.RE_NO_SIXTY) && normalWinningTeamScore < 181) {
|
||||||
return true;
|
gamePoints++;
|
||||||
}
|
}
|
||||||
if(this.checkAnnouncementActive(announcements.Announcement.RE_NO_THIRTY) && normalWinningTeamScore < 211) {
|
if (this.checkAnnouncementActive(announcements.Announcement.RE_NO_THIRTY) && normalWinningTeamScore < 211) {
|
||||||
return true;
|
gamePoints++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(normalWinningTeam === Team.CONTRA) {
|
if (normalWinningTeam === Team.CONTRA) {
|
||||||
if(this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_NINETY) && normalWinningTeamScore < 151) {
|
if (this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_NINETY) && normalWinningTeamScore < 151) {
|
||||||
return true;
|
gamePoints++;
|
||||||
}
|
}
|
||||||
if(this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_SIXTY) && normalWinningTeamScore < 181) {
|
if (this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_SIXTY) && normalWinningTeamScore < 181) {
|
||||||
return true;
|
gamePoints++;
|
||||||
}
|
}
|
||||||
if(this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_THIRTY) && normalWinningTeamScore < 211) {
|
if (this.checkAnnouncementActive(announcements.Announcement.CONTRA_NO_THIRTY) && normalWinningTeamScore < 211) {
|
||||||
return true;
|
gamePoints++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return gamePoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _____ __
|
||||||
|
* / ___/____ / /___
|
||||||
|
* \__ \/ __ \/ / __ \
|
||||||
|
* ___/ / /_/ / / /_/ /
|
||||||
|
* /____/\____/_/\____/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks, according to the assigned Teams, if this is a solo play
|
||||||
|
*/
|
||||||
|
checkIfSolo(): boolean {
|
||||||
|
let numberOfElders: number = 0;
|
||||||
|
|
||||||
|
for(let player of this.actualPlayers) {
|
||||||
|
if(player.team === Team.RE) {
|
||||||
|
numberOfElders++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return numberOfElders === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given solo is currently active
|
||||||
|
* @param solo The solo to check active status for
|
||||||
|
*/
|
||||||
|
isSoloActive(solo: solos.Solo): boolean {
|
||||||
|
return this.soloPlayed === solo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all possible solo values
|
||||||
|
*/
|
||||||
|
getAllPossibleSolos(): solos.Solo[] {
|
||||||
|
return solos.getAllSoloValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the given solo as the active one
|
||||||
|
* @param solo The solo to set as the active one
|
||||||
|
*/
|
||||||
|
toggleSolo(solo: solos.Solo): void {
|
||||||
|
this.soloPlayed = solo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if there is a solo selected, false otherwise
|
||||||
|
*/
|
||||||
|
noSoloSelectedYet(): boolean {
|
||||||
|
return this.soloPlayed === undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ______ __ ____ _ __
|
||||||
|
* / ____/ __/ /__________ _ / __ \____ (_)___ / /______
|
||||||
|
* / __/ | |/_/ __/ ___/ __ `/ / /_/ / __ \/ / __ \/ __/ ___/
|
||||||
|
* / /____> </ /_/ / / /_/ / / ____/ /_/ / / / / / /_(__ )
|
||||||
|
* /_____/_/|_|\__/_/ \__,_/ /_/ \____/_/_/ /_/\__/____/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the number of caught foxes checks out
|
||||||
|
*/
|
||||||
|
checkTotalFoxPoints(): boolean {
|
||||||
|
let totalFoxPoints: number = 0;
|
||||||
|
|
||||||
|
for (let player of this.actualPlayers) {
|
||||||
|
totalFoxPoints += player.foxesCaught ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalFoxPoints <= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if all extra point types have valid entries
|
||||||
|
*/
|
||||||
|
checkAllExtraPoints(): boolean {
|
||||||
|
return this.checkTotalFoxPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _____
|
||||||
|
* / ___/__ ______ ___ ____ ___ ____ ________ __
|
||||||
|
* \__ \/ / / / __ `__ \/ __ `__ \/ __ `/ ___/ / / /
|
||||||
|
* ___/ / /_/ / / / / / / / / / / / /_/ / / / /_/ /
|
||||||
|
* /____/\__,_/_/ /_/ /_/_/ /_/ /_/\__,_/_/ \__, /
|
||||||
|
* /____/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the game stats to the API to be saved
|
||||||
|
*/
|
||||||
|
saveGame(): void {
|
||||||
|
//TODO implement
|
||||||
|
// call api method, then return to gameNight page / close modal or sth like that
|
||||||
|
window.location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,24 @@
|
|||||||
export enum Solo {
|
export enum Solo {
|
||||||
QUEENS = 0,
|
QUEENS = 'Queens',
|
||||||
JACKS = 1,
|
JACKS = 'Jacks',
|
||||||
COLOR_CHECKS = 2,
|
COLOR_CHECKS = 'Checks',
|
||||||
COLOR_HEART = 3,
|
COLOR_HEART = 'Heart',
|
||||||
COLOR_SPADES = 4,
|
COLOR_SPADES = 'Spades',
|
||||||
COLOR_CROSS = 5,
|
COLOR_CROSS = 'Cross',
|
||||||
FLESHLESS = 6
|
FLESHLESS = 'Fleshless'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all available solo values
|
||||||
|
*/
|
||||||
|
export function getAllSoloValues(): Solo[] {
|
||||||
|
return [
|
||||||
|
Solo.QUEENS,
|
||||||
|
Solo.JACKS,
|
||||||
|
Solo.COLOR_CHECKS,
|
||||||
|
Solo.COLOR_HEART,
|
||||||
|
Solo.COLOR_SPADES,
|
||||||
|
Solo.COLOR_CROSS,
|
||||||
|
Solo.FLESHLESS
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,20 @@ export class HomeComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// TODO: First try to read existing session data
|
if(!HomeComponent.sessionDataAvailable()) {
|
||||||
this.authenticateUser();
|
this.authenticateUser();
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there is session data saved in the local storage
|
||||||
|
* @return If there is session data available
|
||||||
|
*/
|
||||||
|
private static sessionDataAvailable(): boolean {
|
||||||
|
let user = StorageService.getUserInfo();
|
||||||
|
|
||||||
|
return user !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,6 +47,10 @@ export class HomeComponent implements OnInit {
|
|||||||
sessionKey: ''
|
sessionKey: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(user.firebonkId === undefined || user.firstName === undefined || user.token === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let authenticatedUser = ApiService.performAuthentication(user);
|
let authenticatedUser = ApiService.performAuthentication(user);
|
||||||
StorageService.setUserInfo(authenticatedUser);
|
StorageService.setUserInfo(authenticatedUser);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user