From b8fcfe9ad125b7c5c10d3db92a3d225fe04ff8af Mon Sep 17 00:00:00 2001 From: Solomon Cammack Date: Sat, 2 Nov 2024 03:53:38 +0000 Subject: [PATCH] Fixes and additions to show hero icons in ban score reports --- server/src/action-utils/ts-action-utils.ts | 21 ++++++++++++--- server/src/types.ts | 27 +++++++++++++++++-- .../website/dashboard/MatchEditor.vue | 4 +-- website/src/utils/content-utils.js | 1 + 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/server/src/action-utils/ts-action-utils.ts b/server/src/action-utils/ts-action-utils.ts index 65cc3119..9fc7b7ca 100644 --- a/server/src/action-utils/ts-action-utils.ts +++ b/server/src/action-utils/ts-action-utils.ts @@ -87,9 +87,12 @@ export async function generateMatchReportText(match: Match) { }); lines.push(teamText.join(` ${scores.join("-")} `)); + if (match.forfeit) { + lines.push("*Match forfeited*"); + } - - maps.filter(map => !map.banner).forEach((map, i) => { + for (const map of maps.filter(map => !map.banner)) { + const i = maps.filter(map => !map.banner).indexOf(map); const mapLine : string[] = []; mapLine.push(`Map ${i+1}`); if (map.map?.name) mapLine.push(map.map.name); @@ -125,7 +128,19 @@ export async function generateMatchReportText(match: Match) { lines.push(mapLine.join(" - ")); - }); + + if (map.team_1_bans?.length || map.team_2_bans?.length) { + const teamBans = []; + + for (const teamI of [0, 1]) { + const team = teams[teamI]; + const bannedHeroes = await Promise.all(([map.team_1_bans, map.team_2_bans][teamI] || []).map(id => get(id))); + teamBans.push(`${team.code || team.name} ban: ${bannedHeroes.map(hero => hero.icon_emoji_text || hero.name).join(" | ")}`); + } + + lines.push(`> ${teamBans.join("")}`); + } + } lines.push(`<${matchLink}>`); diff --git a/server/src/types.ts b/server/src/types.ts index 02d6b08c..28268503 100644 --- a/server/src/types.ts +++ b/server/src/types.ts @@ -89,6 +89,8 @@ export type WebsiteSettings = | "Can edit any auction" | "No profile editing" +export type Game = "Overwatch" | "Valorant" | "League of Legends" | "Counter-Strike" | "Deadlock"; + // /** // * @property member_of - Teams this player is a player of // */ @@ -189,8 +191,29 @@ export interface Report extends Base { interface LogFile extends Base { } -interface Hero extends Base { +export interface Hero extends Base { + id: HeroResolvableID; + __tableName: "Heroes"; + + name?: string; + role?: string; + game?: Game; + icon_emoji_text?: string; + broadcasts?: BroadcastResolvableID[]; + players?: PlayerResolvableID[]; + + maps?: MatchMapResolvableID[]; + maps_2?: MatchMapResolvableID[]; + maps_3?: MatchMapResolvableID[]; + maps_4?: MatchMapResolvableID[]; + + icon?: CacheAttachment[]; + symbol?: CacheAttachment[]; + main_image?: CacheAttachment[]; + alternate_set_image?: CacheAttachment[]; + recolor_base?: CacheAttachment[]; + recolor_layers?: CacheAttachment[]; } interface Social extends Base { @@ -221,7 +244,7 @@ export interface GameMap extends Base { * events - as part of a map pool */ events?: EventResolvableID[]; - game?: "Overwatch" | "Valorant" | "League of Legends" | "Counter-Strike"; + game?: Game; maps?: MatchMapResolvableID[]; name?: string; short_name?: string; diff --git a/website/src/components/website/dashboard/MatchEditor.vue b/website/src/components/website/dashboard/MatchEditor.vue index 86efc4e4..5be02f65 100644 --- a/website/src/components/website/dashboard/MatchEditor.vue +++ b/website/src/components/website/dashboard/MatchEditor.vue @@ -654,8 +654,8 @@ export default { this.availableMaps.forEach(m => { if (this.restrictToMapPool && mapType && mapType.includes("/")) { - if (mapType.split("/").map(t => t.trim()).some(t => t === m.type)) return; - } else { + if (mapType.split("/").map(t => t.trim()).every(t => t !== m.type)) return; + } else if (this.restrictToMapPool && mapType) { if (mapType !== m.type) return; } diff --git a/website/src/utils/content-utils.js b/website/src/utils/content-utils.js index 10ae72c5..60d9da0f 100644 --- a/website/src/utils/content-utils.js +++ b/website/src/utils/content-utils.js @@ -724,6 +724,7 @@ export function getScoreReportingBadge(state, report, eventSettings) { return { variant: "dark", text: "Needs opponent", + small: "Need opp", title: "Waiting for opponent to approve this report" }; }