diff --git a/src/app/components/combat/endround-banner/endround-banner.component.html b/src/app/components/combat/endround-banner/endround-banner.component.html index 338bb7b1..afef6101 100644 --- a/src/app/components/combat/endround-banner/endround-banner.component.html +++ b/src/app/components/combat/endround-banner/endround-banner.component.html @@ -1,4 +1,4 @@ -@if (dataModel.tournamentInfo().enabled) { +@if (dataModel.roundWinBox().type !== "disabled") {
- @if (tournamentBackgroundUrl()) { + @if (bannerBackgroundUrl()) { } @else { @@ -26,7 +26,7 @@ [src]="dataModel.teams()[0].teamUrl" alt="" /> - +

{{ roundWonType() | translate }}

@@ -45,10 +45,10 @@
- @if (tournamentBackgroundUrl()) { + @if (bannerBackgroundUrl()) { } @else { @@ -75,7 +75,7 @@
}
- +

{{ TranslateKeys.Endround_Round | translate: { rounds: dataModel.match().roundNumber } diff --git a/src/app/components/combat/endround-banner/endround-banner.component.ts b/src/app/components/combat/endround-banner/endround-banner.component.ts index ee84dcfd..6096fc04 100644 --- a/src/app/components/combat/endround-banner/endround-banner.component.ts +++ b/src/app/components/combat/endround-banner/endround-banner.component.ts @@ -1,7 +1,8 @@ -import { Component, computed, effect, inject, signal, WritableSignal } from "@angular/core"; +import { Component, computed, effect, inject, Signal, signal, WritableSignal } from "@angular/core"; import { TranslatePipe } from "@ngx-translate/core"; import { TranslateKeys } from "../../../services/i18nHelper"; import { DataModelService } from "../../../services/dataModel.service"; +import { IRoundWinBox, IRoundWinBoxSponsors } from "../../../services/Types"; @Component({ selector: "app-endround", @@ -26,6 +27,9 @@ export class EndroundBannerComponent { clutch: number[] = [-1, -1]; + roundWinBox: Signal = computed(() => this.dataModel.roundWinBox()); + roundWonSponsor: Signal = computed(() => this.calculateSponsor()); + private calculateClutch(): void { const teamOne = this.dataModel.match().teams[0]; const teamTwo = this.dataModel.match().teams[1]; @@ -58,12 +62,15 @@ export class EndroundBannerComponent { if (player.isAlive) flawless = false; }); for (const player of wonTeam.players) { - const killsFromLostTeam = player.killedPlayerNames.filter((playerName) => - lostTeamPlayerNames.has(playerName), - ); - if (new Set(killsFromLostTeam).size >= 5) { - ace = true; - break; + if (player.killedPlayerNames) { + const killsFromLostTeam = player.killedPlayerNames.filter((playerName) => + lostTeamPlayerNames.has(playerName), + ); + + if (new Set(killsFromLostTeam).size >= 5) { + ace = true; + break; + } } if (player.deathsThisRound >= 1) flawless = false; if (!(player.killsThisRound >= 1)) teamAce = false; @@ -77,15 +84,70 @@ export class EndroundBannerComponent { return TranslateKeys.Endround_RoundWin; } - tournamentBackgroundUrl = computed(() => { - const backdrop = this.dataModel.tournamentInfo().backdropUrl; - if (backdrop && backdrop !== "") return backdrop; + private calculateSponsor(): IRoundWinBoxSponsors { + const teamwon = this.teamWon(); + const roundWonType = this.roundWonType(); + + const initialSponsor: IRoundWinBoxSponsors = { + wonTeam: "all", + roundCeremonie: ["all"], + iconUrl: "", + backdropUrl: "", + }; + + if (this.roundWinBox().sponsors.length == 0) return initialSponsor; + + const sponsor: IRoundWinBoxSponsors = this.roundWinBox().sponsors[0]; + + for (const spons of this.roundWinBox().sponsors) { + if ( + spons.wonTeam == "all" || + (spons.wonTeam == "left" && teamwon == 0) || + (spons.wonTeam == "right" && teamwon == 1) + ) { + if ( + spons.roundCeremonie.includes("all") || + (spons.roundCeremonie.includes("normal") && + roundWonType == TranslateKeys.Endround_RoundWin) || + (spons.roundCeremonie.includes("ace") && + roundWonType == TranslateKeys.Endround_RoundAce) || + (spons.roundCeremonie.includes("clutch") && + roundWonType == TranslateKeys.Endround_RoundClutch) || + (spons.roundCeremonie.includes("teamAce") && + roundWonType == TranslateKeys.Endround_RoundTeamAce) || + (spons.roundCeremonie.includes("flawless") && + roundWonType == TranslateKeys.Endround_RoundFlawless) || + (spons.roundCeremonie.includes("thrifty") && + roundWonType == TranslateKeys.Endround_RoundThrifty) + ) { + return spons; + } + } + } + return sponsor; + } + + bannerBackgroundUrl = computed(() => { + const backdropSponsor = this.roundWonSponsor().backdropUrl; + const backdropTournament = this.dataModel.tournamentInfo().backdropUrl; + if (this.roundWinBox().type == "sponsors" && backdropSponsor && backdropSponsor !== "") + return backdropSponsor; + if ( + this.roundWinBox().type == "tournamentInfo" && + backdropTournament && + backdropTournament !== "" + ) + return backdropTournament; else return false; }); - tournamentIconUrl = computed(() => { - const logo = this.dataModel.tournamentInfo().logoUrl; - if (logo && logo !== "") return logo; + bannerTopIconUrl = computed(() => { + const logoSponsor = this.roundWonSponsor().iconUrl; + const logoTournament = this.dataModel.tournamentInfo().logoUrl; + if (this.roundWinBox().type == "sponsors" && logoSponsor && logoSponsor !== "") + return logoSponsor; + if (this.roundWinBox().type == "tournamentInfo" && logoTournament && logoTournament !== "") + return logoTournament; else return "assets/misc/logo.webp"; }); @@ -102,15 +164,14 @@ export class EndroundBannerComponent { }); readonly waitingBackgroundClass = computed(() => { - const test = `gradient-head-to-head-${this.dataModel.teams()[0].isAttacking ? "attacker" : "defender"}`; - return test; + return `gradient-head-to-head-${this.dataModel.teams()[0].isAttacking ? "attacker" : "defender"}`; }); readonly winningTeamBackgroundClass = computed(() => { return `gradient-${this.leftWon() ? "left" : "right"}-${this.dataModel.match().attackersWon ? "attacker" : "defender"}`; }); - ref = effect(() => { + _ref = effect(() => { const roundPhase = this.dataModel.match().roundPhase; const roundNumber = this.dataModel.match().roundNumber; diff --git a/src/app/overlays/testing-agent-select/testing-agent-select.component.ts b/src/app/overlays/testing-agent-select/testing-agent-select.component.ts index 346868f3..657d6163 100644 --- a/src/app/overlays/testing-agent-select/testing-agent-select.component.ts +++ b/src/app/overlays/testing-agent-select/testing-agent-select.component.ts @@ -59,7 +59,6 @@ export class TestingAgentSelectComponent implements OnInit { right: "Group B", }, tournamentInfo: { - enabled: true, name: "", logoUrl: "", backdropUrl: "", @@ -86,6 +85,10 @@ export class TestingAgentSelectComponent implements OnInit { nameOverrides: { overrides: [], }, + roundWinBox: { + type: "tournamentInfo", + sponsors: [], + }, }, timeoutState: { techPause: false, diff --git a/src/app/overlays/testing/testing.component.ts b/src/app/overlays/testing/testing.component.ts index a7af318f..aa1932e1 100644 --- a/src/app/overlays/testing/testing.component.ts +++ b/src/app/overlays/testing/testing.component.ts @@ -68,7 +68,6 @@ export class TestingComponent implements OnInit { right: "Group B", }, tournamentInfo: { - enabled: true, name: "", logoUrl: "", backdropUrl: "", @@ -95,6 +94,10 @@ export class TestingComponent implements OnInit { removeTricodes: false, }, nameOverrides: { overrides: [] }, + roundWinBox: { + type: "tournamentInfo", + sponsors: [], + }, }, teams: [ { diff --git a/src/app/services/Types.ts b/src/app/services/Types.ts index ea7ed158..597a53e9 100644 --- a/src/app/services/Types.ts +++ b/src/app/services/Types.ts @@ -97,6 +97,7 @@ export interface IToolsData { watermarkInfo: IWatermarkInfo; playercamsInfo: IPlayercamsInfo; nameOverrides: INameOverrides; + roundWinBox: IRoundWinBox; } export interface ISeriesInfo { @@ -115,7 +116,6 @@ export interface ITournamentInfo { name: string; logoUrl: string; backdropUrl: string; - enabled: boolean; } export interface ITimeoutInfo { @@ -149,6 +149,18 @@ export interface INameOverrides { overrides: string[]; } +export interface IRoundWinBox { + type: "disabled" | "tournamentInfo" | "sponsors"; + sponsors: IRoundWinBoxSponsors[]; +} + +export interface IRoundWinBoxSponsors { + wonTeam: "all" | "left" | "right"; + roundCeremonie: ("all" | "normal" | "ace" | "clutch" | "teamAce" | "flawless" | "thrifty")[]; + iconUrl: string; + backdropUrl: string; +} + export interface IOverridesPlayercamsData { nameOverrides: string[]; enabledPlayers: string[]; diff --git a/src/app/services/dataModel.service.ts b/src/app/services/dataModel.service.ts index daa4652e..43150052 100644 --- a/src/app/services/dataModel.service.ts +++ b/src/app/services/dataModel.service.ts @@ -109,6 +109,7 @@ export class DataModelService { public readonly playercamsInfo = computed(() => this.match().tools.playercamsInfo, { equal: () => false, }); + public readonly roundWinBox = computed(() => this.match().tools.roundWinBox); public readonly mapban = signal(initialMapbanData, { equal: () => false }); @@ -166,7 +167,6 @@ export const initialMatchData: IMatchData = { right: "", }, tournamentInfo: { - enabled: false, name: "", logoUrl: "", backdropUrl: "", @@ -190,6 +190,10 @@ export const initialMatchData: IMatchData = { }, playercamsInfo: { enable: false }, nameOverrides: { overrides: [] }, + roundWinBox: { + type: "disabled", + sponsors: [], + }, }, timeoutState: { techPause: false,