Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tsa96 committed Nov 19, 2024
1 parent f90effc commit d1e60cf
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 5 deletions.
80 changes: 80 additions & 0 deletions libs/constants/src/consts/map-tags.const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { Gamemode, GamemodeCategory, GamemodeToGamemodeCategory } from '../';
import { ElementOf, ValueOf } from '../types/utils/util.type';

const GLOBAL_TAGS = ['Portals', 'Multiroute'] as const;

// prettier-ignore
const GAMEMODE_TAGS = {
[GamemodeCategory.SURF]: [
'Unit',
'Tech',
'Spins',
'Booster',
'Headhit',
'Bhop'
] as const,
[GamemodeCategory.BHOP]: [
'Strafe',
'Tech',
'Fly',
'Surf',
'Weapons',
'Spins'
] as const,
[GamemodeCategory.CLIMB]: [
'Ladder'
] as const,
[GamemodeCategory.RJ]: [
'Sync',
'Wallpogo',
'Speedshot',
'Bounce',
'Jurf',
'Edgebug',
'Wallbug',
'Wallshot'
] as const,
[GamemodeCategory.SJ]: [
'Airpogo',
'Wallpogo',
'Vert'
] as const,
[GamemodeCategory.AHOP]: [
'HL2'
] as const,
[GamemodeCategory.CONC]: [
'Prec',
'Juggle',
'Limited Ammo'
] as const,
[GamemodeCategory.DEFRAG]: [
'Strafe',
'Rocket Launcher',
'Grenade Launcher',
'Plasma Gun',
'BFG',
'Combo',
'Haste',
'Damageboost',
'Climb',
'Trick'
] as const
};

// We could add support for individual subcategories (Gamemodes), but don't
// have a single example of one yet.

/**
* Union of every possible tag in Momentum.
*/
export type MapTag =
| (typeof GLOBAL_TAGS)[number]
| ElementOf<ValueOf<typeof GAMEMODE_TAGS>>;

// TODO: BUMP DEPS, REMOVE SPREAD!!
export const MapTags: Map<Gamemode, Set<MapTag>> = new Map(
[...GamemodeToGamemodeCategory.entries()].map(([gamemode, category]) => [
gamemode,
new Set([...GLOBAL_TAGS, ...(GAMEMODE_TAGS[category] ?? [])]) as any
])
) as any;
29 changes: 29 additions & 0 deletions libs/constants/src/enums/gamemode.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,32 @@ export enum GamemodeCategory {
CONC = 7,
DEFRAG = 8
}

// prettier-ignore
export const GamemodeCategoryToGamemode = new Map<GamemodeCategory, Gamemode[]>([
[GamemodeCategory.SURF, [Gamemode.SURF]],
[GamemodeCategory.BHOP, [Gamemode.BHOP, Gamemode.BHOP_HL1]],
[GamemodeCategory.CLIMB, [Gamemode.CLIMB_MOM, Gamemode.CLIMB_KZT, Gamemode.CLIMB_16]],
[GamemodeCategory.RJ, [Gamemode.RJ]],
[GamemodeCategory.SJ, [Gamemode.SJ]],
[GamemodeCategory.AHOP, [Gamemode.AHOP]],
[GamemodeCategory.CONC, [Gamemode.CONC]],
[GamemodeCategory.DEFRAG, [Gamemode.DEFRAG_CPM, Gamemode.DEFRAG_VQ3, Gamemode.DEFRAG_VTG]]
]);

// prettier-ignore
export const GamemodeToGamemodeCategory = new Map<Gamemode, GamemodeCategory>([
[Gamemode.SURF, GamemodeCategory.SURF],
[Gamemode.BHOP, GamemodeCategory.BHOP],
[Gamemode.BHOP_HL1, GamemodeCategory.BHOP],
[Gamemode.CLIMB_MOM, GamemodeCategory.CLIMB],
[Gamemode.CLIMB_KZT, GamemodeCategory.CLIMB],
[Gamemode.CLIMB_16, GamemodeCategory.CLIMB],
[Gamemode.RJ, GamemodeCategory.RJ],
[Gamemode.SJ, GamemodeCategory.SJ],
[Gamemode.AHOP, GamemodeCategory.AHOP],
[Gamemode.CONC, GamemodeCategory.CONC],
[Gamemode.DEFRAG_CPM, GamemodeCategory.DEFRAG],
[Gamemode.DEFRAG_VQ3, GamemodeCategory.DEFRAG],
[Gamemode.DEFRAG_VTG, GamemodeCategory.DEFRAG]
]);
1 change: 1 addition & 0 deletions libs/constants/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './consts/map-tags.const';
export * from './consts/jwt.const';
export * from './consts/appids.const';
export * from './consts/file-store-paths.const';
Expand Down
10 changes: 5 additions & 5 deletions libs/constants/src/types/models/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import {
AdminActivityType,
KillswitchType,
ReportType,
ReportCategory
ReportCategory,
MapTag,
Flags,
DateString
} from '../../';
import { Flags, DateString } from '../../';

// Collection of models used throughout the codebase, as well as in Panorama.
//
Expand Down Expand Up @@ -352,8 +354,6 @@ export interface MapSubmissionSuggestion {
// TODO: Tags!
}

export type MapTags = string[];

export interface MapTestInvite {
mapID: number;
userID: number;
Expand Down Expand Up @@ -456,7 +456,7 @@ export interface Leaderboard {
tier: number | null;
style: Style;
type: LeaderboardType;
tags: MapTags;
tags: MapTag[];
linear: boolean;
}

Expand Down
13 changes: 13 additions & 0 deletions libs/constants/src/types/utils/util.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Trivial types that are useful in many places.
* This package is exported to Panorama, which doesn't support type-fest, add
* here if needed.
*/

export type ValueOf<T> = T[keyof T];
export type ElementOf<T> = T extends (infer E)[] ? E : never;

export type KeyOfMap<T> = T extends Map<infer K, any> ? K : never;
export type ValueOfMap<T> = T extends Map<any, infer V> ? V : never;

export type ElementOfSet<T> = T extends Set<infer K> ? K : never;

0 comments on commit d1e60cf

Please sign in to comment.