Skip to content

Commit

Permalink
Fixes and additions to show hero icons in ban score reports
Browse files Browse the repository at this point in the history
  • Loading branch information
slmnio committed Nov 2, 2024
1 parent 51c21d6 commit b8fcfe9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
21 changes: 18 additions & 3 deletions server/src/action-utils/ts-action-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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}>`);
Expand Down
27 changes: 25 additions & 2 deletions server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
// */
Expand Down Expand Up @@ -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 {

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions website/src/components/website/dashboard/MatchEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions website/src/utils/content-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
}
Expand Down

0 comments on commit b8fcfe9

Please sign in to comment.