Add "Announcements" page to "Add game" component
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user