diff --git a/src/app/components/add-game/add-game.component.html b/src/app/components/add-game/add-game.component.html
index 25be637..5b48448 100644
--- a/src/app/components/add-game/add-game.component.html
+++ b/src/app/components/add-game/add-game.component.html
@@ -3,12 +3,16 @@
+
Select the active players for the game:
{{player.firstName}}
Illegal amount of players!
-
+
-
+
Select the announcements for this game:
+
{{announcement.toString()}}
+
Illegal set of announcements!
+
diff --git a/src/app/components/add-game/add-game.component.scss b/src/app/components/add-game/add-game.component.scss
index 06447c2..89272cd 100644
--- a/src/app/components/add-game/add-game.component.scss
+++ b/src/app/components/add-game/add-game.component.scss
@@ -31,3 +31,7 @@
.visible-true {
display: inherit;
}
+
+#announcement-warn {
+ color: $warn;
+}
diff --git a/src/app/components/add-game/add-game.component.ts b/src/app/components/add-game/add-game.component.ts
index ffd9c66..d8a118e 100644
--- a/src/app/components/add-game/add-game.component.ts
+++ b/src/app/components/add-game/add-game.component.ts
@@ -1,5 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {Player} from '../../models/doppelkopf/player';
+import * as Announcement from '../../models/doppelkopf/enums/announcement';
@Component({
selector: 'app-add-game',
@@ -10,6 +11,8 @@ export class AddGameComponent implements OnInit {
potentialPlayers: Player[] = [];
actualPlayers: Player[] = [];
+ selectedAnnouncements: Announcement.Announcement[] = [];
+
currentPage: number = 0;
constructor() {
@@ -80,4 +83,39 @@ export class AddGameComponent implements OnInit {
switchToNextPage(): void {
this.currentPage++;
}
+
+ /**
+ * Toggles the activity status for the given announcement
+ * @param announcement The announcement to toggle activity for
+ */
+ toggleAnnouncement(announcement: Announcement.Announcement): void {
+ let index = this.selectedAnnouncements.indexOf(announcement);
+ if(index !== -1){
+ this.selectedAnnouncements.splice(index, 1);
+ } else {
+ this.selectedAnnouncements.push(announcement);
+ }
+ }
+
+ /**
+ * Checks if the given announcement is already marked as selected
+ * @param announcement The announcement to check the status for
+ */
+ isAnnouncementActive(announcement: Announcement.Announcement): boolean {
+ return this.selectedAnnouncements.indexOf(announcement) !== -1;
+ }
+
+ /**
+ * Returns a list of all possible announcements
+ */
+ getAllPossibleAnnouncements(): Announcement.Announcement[] {
+ return Announcement.getAllAnnouncementValues();
+ }
+
+ /**
+ * Checks, if the currently selected announcements are a valid set of announcements
+ */
+ checkAnnouncementsValid(): boolean {
+ return Announcement.checkValidity(this.selectedAnnouncements);
+ }
}
diff --git a/src/app/models/doppelkopf/enums/announcement.ts b/src/app/models/doppelkopf/enums/announcement.ts
index 8e6b3e2..659f651 100644
--- a/src/app/models/doppelkopf/enums/announcement.ts
+++ b/src/app/models/doppelkopf/enums/announcement.ts
@@ -1,10 +1,71 @@
export enum Announcement {
- RE = 0,
- CONTRA = 1,
- RE_NO_NINETY = 2.1,
- CONTRA_NO_NINETY = 2.2,
- RE_NO_SIXTY = 3.1,
- CONTRA_NO_SIXTY = 3.2,
- RE_NO_THIRTY = 4.1,
- CONTRA_NO_THIRTY = 4.2
+ RE = 'Re',
+ CONTRA = 'Contra',
+ RE_NO_NINETY = 'Re: No ninety',
+ CONTRA_NO_NINETY = 'Contra: No ninety',
+ RE_NO_SIXTY = 'Re: No sixty',
+ CONTRA_NO_SIXTY = 'Contra: No sixty',
+ RE_NO_THIRTY = 'Re: No thirty',
+ CONTRA_NO_THIRTY = 'Contra: No thirty'
+}
+
+/**
+ * Returns all available announcement values
+ */
+export function getAllAnnouncementValues(): Announcement[] {
+ return [
+ Announcement.RE,
+ Announcement.CONTRA,
+ Announcement.RE_NO_NINETY,
+ Announcement.CONTRA_NO_NINETY,
+ Announcement.RE_NO_SIXTY,
+ Announcement.CONTRA_NO_SIXTY,
+ Announcement.RE_NO_THIRTY,
+ Announcement.CONTRA_NO_THIRTY
+ ];
+}
+
+/**
+ * Checks if the selected announcements are a valid set of announcements.
+ * E.g.: If RE_NO_NINETY is newly selected, RE also has to be selected
+ * @param alreadySelected
+ * @param newSelected
+ */
+export function checkValidity(selectedAnnouncements: Announcement[]): boolean {
+ // First check all "RE" Announcements
+ if(selectedAnnouncements.indexOf(Announcement.RE_NO_THIRTY) !== -1) {
+ if(selectedAnnouncements.indexOf(Announcement.RE_NO_SIXTY) === -1) {
+ return false;
+ }
+ }
+ if(selectedAnnouncements.indexOf(Announcement.RE_NO_SIXTY) !== -1) {
+ if(selectedAnnouncements.indexOf(Announcement.RE_NO_NINETY) === -1) {
+ return false;
+ }
+ }
+ if(selectedAnnouncements.indexOf(Announcement.RE_NO_NINETY) !== -1) {
+ if(selectedAnnouncements.indexOf(Announcement.RE) === -1) {
+ return false;
+ }
+ }
+
+ // Now same for "CONTRA"
+ if(selectedAnnouncements.indexOf(Announcement.CONTRA_NO_THIRTY) !== -1) {
+ if(selectedAnnouncements.indexOf(Announcement.CONTRA_NO_SIXTY) === -1) {
+ return false;
+ }
+ }
+ if(selectedAnnouncements.indexOf(Announcement.CONTRA_NO_SIXTY) !== -1) {
+ if(selectedAnnouncements.indexOf(Announcement.CONTRA_NO_NINETY) === -1) {
+ return false;
+ }
+ }
+ if(selectedAnnouncements.indexOf(Announcement.CONTRA_NO_NINETY) !== -1) {
+ if(selectedAnnouncements.indexOf(Announcement.CONTRA) === -1) {
+ return false;
+ }
+ }
+
+ // all fine, return true
+ return true
}