Moved logic to backend
All checks were successful
Gitea/swiss-client/pipeline/head This commit looks good
All checks were successful
Gitea/swiss-client/pipeline/head This commit looks good
This commit is contained in:
@@ -130,9 +130,21 @@
|
|||||||
<mat-expansion-panel>
|
<mat-expansion-panel>
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<div class="col-md-2">Baan {{ activeMatch.match.court }}</div>
|
<div class="col-md-2">Baan {{ activeMatch.match.court }}</div>
|
||||||
<div class="col-md-3">{{ activeMatch.match.team1 | teamText }}</div>
|
<div class="col-md-3">
|
||||||
|
<app-team-display
|
||||||
|
[team]="activeMatch.match.team1"
|
||||||
|
[event]="activeMatch.event"
|
||||||
|
[tournament]="this.tournament">
|
||||||
|
</app-team-display>
|
||||||
|
</div>
|
||||||
<div class="col-md-1">-</div>
|
<div class="col-md-1">-</div>
|
||||||
<div class="col-md-3">{{ activeMatch.match.team2 | teamText }}</div>
|
<div class="col-md-3">
|
||||||
|
<app-team-display
|
||||||
|
[team]="activeMatch.match.team2"
|
||||||
|
[event]="activeMatch.event"
|
||||||
|
[tournament]="this.tournament">
|
||||||
|
</app-team-display>
|
||||||
|
</div>
|
||||||
<div class="col-md-3">{{ activeMatch.group.name }} {{ activeMatch.round.name }}</div>
|
<div class="col-md-3">{{ activeMatch.group.name }} {{ activeMatch.round.name }}</div>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ import {TeamDisplayComponent} from "../team-display/team-display.component";
|
|||||||
TournamentValidateComponent,
|
TournamentValidateComponent,
|
||||||
TournamentPlayersComponent,
|
TournamentPlayersComponent,
|
||||||
MatExpansionPanelActionRow,
|
MatExpansionPanelActionRow,
|
||||||
MatTooltip,
|
|
||||||
TeamDisplayComponent,
|
TeamDisplayComponent,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
@@ -224,36 +223,43 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
matchContainsPlayersThatArePlaying(match: Match): boolean {
|
matchContainsPlayersThatArePlaying(match: Match): boolean {
|
||||||
let activePlayers: number[] = [];
|
|
||||||
for (let activeMatch of this.activeMatches()) {
|
|
||||||
activePlayers.push(activeMatch.match.team1.player1.id);
|
|
||||||
if (activeMatch.match.team1.player2) activePlayers.push(activeMatch.match.team1.player2.id);
|
|
||||||
activePlayers.push(activeMatch.match.team2.player1.id);
|
|
||||||
if (activeMatch.match.team2.player2) activePlayers.push(activeMatch.match.team2.player2.id);
|
|
||||||
}
|
|
||||||
let matchPlayers: number[] = [];
|
let matchPlayers: number[] = [];
|
||||||
matchPlayers.push(match.team1.player1.id);
|
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player1).id);
|
||||||
if (match.team1.player2) matchPlayers.push(match.team1.player2.id);
|
if (match.team1.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player2).id);
|
||||||
matchPlayers.push(match.team2.player1.id);
|
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player1).id);
|
||||||
if (match.team2.player2) matchPlayers.push(match.team2.player2.id);
|
if (match.team2.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player2).id);
|
||||||
let playersThatArePlaying = activePlayers.filter(Set.prototype.has, new Set(matchPlayers));
|
|
||||||
return playersThatArePlaying.length > 0;
|
let matchPlayersThatArePlaying = this.tournament.playersPlaying.filter(Set.prototype.has, new Set(matchPlayers));
|
||||||
|
return matchPlayersThatArePlaying.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
matchContainsPlayersThatAreCounting(match: Match): boolean {
|
matchContainsPlayersThatAreCounting(match: Match): boolean {
|
||||||
let currentCounters: number[] = [];
|
|
||||||
for (let activeMatch of this.activeMatches()) {
|
|
||||||
currentCounters.push(activeMatch.match.counter.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
let matchPlayers: number[] = [];
|
let matchPlayers: number[] = [];
|
||||||
matchPlayers.push(match.team1.player1.id);
|
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player1).id);
|
||||||
if (match.team1.player2) matchPlayers.push(match.team1.player2.id);
|
if (match.team1.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team1.player2).id);
|
||||||
matchPlayers.push(match.team2.player1.id);
|
matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player1).id);
|
||||||
if (match.team2.player2) matchPlayers.push(match.team2.player2.id);
|
if (match.team2.player2) matchPlayers.push(this.getTournamentPlayerFromPlayer(match.team2.player2).id);
|
||||||
|
|
||||||
let playersThatAreCounting = currentCounters.filter(Set.prototype.has, new Set(matchPlayers));
|
let matchPlayersThatAreCounting = this.tournament.playersCounting.filter(Set.prototype.has, new Set(matchPlayers));
|
||||||
return playersThatAreCounting.length > 0;
|
return matchPlayersThatAreCounting.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTournamentPlayerFromPlayer(player: Player): TournamentPlayer {
|
||||||
|
for (let tournamentPlayer of this.tournament.tournamentPlayers) {
|
||||||
|
if (tournamentPlayer.playerId == player.id) {
|
||||||
|
return tournamentPlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null!;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTournamentPlayerFromId(tournamentPlayerId: number): TournamentPlayer {
|
||||||
|
for (let tournamentPlayer of this.tournament.tournamentPlayers) {
|
||||||
|
if (tournamentPlayer.id == tournamentPlayerId) {
|
||||||
|
return tournamentPlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null!;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAvailableCourts(): number[] {
|
getAvailableCourts(): number[] {
|
||||||
@@ -267,28 +273,33 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAvailableCounters(match: Match): TournamentPlayer[] {
|
getAvailableCounters(match: Match): TournamentPlayer[] {
|
||||||
const activePlayerIds = new Set(
|
const matchPlayers: number[] = [];
|
||||||
this.activeMatches().flatMap(activeMatch => [
|
matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player1, match.type).id);
|
||||||
activeMatch.match.team1.player1.id,
|
if (match.team1.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team1.player2, match.type).id);
|
||||||
activeMatch.match.team1.player2?.id,
|
matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player1, match.type).id);
|
||||||
activeMatch.match.team2.player1.id,
|
if (match.team2.player2) matchPlayers.push(this.getPlayerOrSubstitute(match.team2.player2, match.type).id);
|
||||||
activeMatch.match.team2.player2?.id
|
|
||||||
].filter(id => id !== undefined))
|
|
||||||
);
|
|
||||||
|
|
||||||
const playerIdsInMatchToBeStarted = new Set([
|
const counterIds = this.tournament.playersAvailable.filter(player => !matchPlayers.includes(player));
|
||||||
match.team1.player1.id,
|
|
||||||
match.team1.player2?.id,
|
|
||||||
match.team2.player1.id,
|
|
||||||
match.team2.player2?.id
|
|
||||||
].filter(id => id !== undefined));
|
|
||||||
|
|
||||||
return this.tournament.tournamentPlayers.filter(
|
return counterIds.map(id => this.getTournamentPlayerFromId(id));
|
||||||
player =>
|
}
|
||||||
!player.counting
|
|
||||||
&& !activePlayerIds.has(player.playerId)
|
getPlayerOrSubstitute(player: Player, type: String): TournamentPlayer {
|
||||||
&& !playerIdsInMatchToBeStarted.has(player.playerId)
|
return this.getSubstituteForEvent(player, type) || this.getTournamentPlayerFromPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
getSubstituteForEvent(player: Player, type: String): TournamentPlayer | undefined {
|
||||||
|
const tournamentPlayer = this.tournament.tournamentPlayers.find(
|
||||||
|
tp => tp.playerId === player.id
|
||||||
);
|
);
|
||||||
|
if (!tournamentPlayer) return undefined;
|
||||||
|
|
||||||
|
const substitution = tournamentPlayer.substitutions.find(
|
||||||
|
s => s.event === type
|
||||||
|
);
|
||||||
|
if (!substitution) return undefined;
|
||||||
|
|
||||||
|
return this.getTournamentPlayerFromId(substitution.substitute);
|
||||||
}
|
}
|
||||||
|
|
||||||
stopMatch(match: Match) {
|
stopMatch(match: Match) {
|
||||||
@@ -326,7 +337,7 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
for (const round of group.rounds) {
|
for (const round of group.rounds) {
|
||||||
for (const match of round.matches) {
|
for (const match of round.matches) {
|
||||||
if (match.status == 'IN_PROGRESS') {
|
if (match.status == 'IN_PROGRESS') {
|
||||||
matches.push(new ActiveMatch(match, round, group));
|
matches.push(new ActiveMatch(match, round, group, event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -420,13 +431,15 @@ export class TournamentManageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ActiveMatch {
|
class ActiveMatch {
|
||||||
constructor(match: Match, round: Round, group: Group) {
|
constructor(match: Match, round: Round, group: Group, event: Event) {
|
||||||
this.match = match;
|
this.match = match;
|
||||||
this.round = round;
|
this.round = round;
|
||||||
this.group = group;
|
this.group = group;
|
||||||
|
this.event = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
match: Match;
|
match: Match;
|
||||||
round: Round;
|
round: Round;
|
||||||
group: Group;
|
group: Group;
|
||||||
|
event: Event;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ export class Tournament {
|
|||||||
costsPerEvent: number[] = [10, 20, 0];
|
costsPerEvent: number[] = [10, 20, 0];
|
||||||
courts: number;
|
courts: number;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
|
playersPlaying: number[];
|
||||||
|
playersCounting: number[];
|
||||||
|
playersAvailable: number[];
|
||||||
|
|
||||||
static getStatus(tournament: Tournament): string {
|
static getStatus(tournament: Tournament): string {
|
||||||
if (tournament.status == "CLOSED") return "Afgerond";
|
if (tournament.status == "CLOSED") return "Afgerond";
|
||||||
|
|||||||
Reference in New Issue
Block a user