Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
+71
-24
@@ -36,14 +36,54 @@ export const T5_ZOMBIE_MAPS: readonly T5MapEntry[] = Object.freeze([
|
||||
// Rulesets from xerxes-at/T6ServerConfigs, also seeded by Plutainer.
|
||||
// Several selections share an engine map; slug preserves the selected variant.
|
||||
export const T6_ZOMBIE_MAPS: readonly ZombieMapEntry[] = Object.freeze([
|
||||
{ friendly: 'TranZit', slug: 'transit', canonical: 'zm_transit', gameSettings: 'zm_classic_transit.cfg' },
|
||||
{ friendly: 'Town Survival', slug: 'town', canonical: 'zm_transit', gameSettings: 'zm_standard_town.cfg' },
|
||||
{ friendly: 'Farm Survival', slug: 'farm', canonical: 'zm_transit', gameSettings: 'zm_standard_farm.cfg' },
|
||||
{ friendly: 'Bus Depot Survival', slug: 'busdepot', canonical: 'zm_transit', gameSettings: 'zm_standard_transit.cfg' },
|
||||
{ friendly: 'Nuketown', slug: 'nuked', canonical: 'zm_nuked', gameSettings: 'zm_standard_nuked.cfg' },
|
||||
{ friendly: 'Die Rise', slug: 'highrise', canonical: 'zm_highrise', gameSettings: 'zm_classic_rooftop.cfg' },
|
||||
{ friendly: 'Mob of the Dead', slug: 'prison', canonical: 'zm_prison', gameSettings: 'zm_classic_prison.cfg' },
|
||||
{ friendly: 'Buried', slug: 'buried', canonical: 'zm_buried', gameSettings: 'zm_classic_processing.cfg' },
|
||||
{
|
||||
friendly: 'TranZit',
|
||||
slug: 'transit',
|
||||
canonical: 'zm_transit',
|
||||
gameSettings: 'zm_classic_transit.cfg'
|
||||
},
|
||||
{
|
||||
friendly: 'Town Survival',
|
||||
slug: 'town',
|
||||
canonical: 'zm_transit',
|
||||
gameSettings: 'zm_standard_town.cfg'
|
||||
},
|
||||
{
|
||||
friendly: 'Farm Survival',
|
||||
slug: 'farm',
|
||||
canonical: 'zm_transit',
|
||||
gameSettings: 'zm_standard_farm.cfg'
|
||||
},
|
||||
{
|
||||
friendly: 'Bus Depot Survival',
|
||||
slug: 'busdepot',
|
||||
canonical: 'zm_transit',
|
||||
gameSettings: 'zm_standard_transit.cfg'
|
||||
},
|
||||
{
|
||||
friendly: 'Nuketown',
|
||||
slug: 'nuked',
|
||||
canonical: 'zm_nuked',
|
||||
gameSettings: 'zm_standard_nuked.cfg'
|
||||
},
|
||||
{
|
||||
friendly: 'Die Rise',
|
||||
slug: 'highrise',
|
||||
canonical: 'zm_highrise',
|
||||
gameSettings: 'zm_classic_rooftop.cfg'
|
||||
},
|
||||
{
|
||||
friendly: 'Mob of the Dead',
|
||||
slug: 'prison',
|
||||
canonical: 'zm_prison',
|
||||
gameSettings: 'zm_classic_prison.cfg'
|
||||
},
|
||||
{
|
||||
friendly: 'Buried',
|
||||
slug: 'buried',
|
||||
canonical: 'zm_buried',
|
||||
gameSettings: 'zm_classic_processing.cfg'
|
||||
},
|
||||
{ friendly: 'Origins', slug: 'tomb', canonical: 'zm_tomb', gameSettings: 'zm_classic_tomb.cfg' }
|
||||
]);
|
||||
|
||||
@@ -55,23 +95,29 @@ export function zombieMapBySlug(game: string, slug: string): ZombieMapEntry | un
|
||||
return zombieMaps(game).find((entry) => entry.slug === slug.toLowerCase());
|
||||
}
|
||||
|
||||
export function selectedZombieMap(game: string | null, map: string | null, slug?: string | null): ZombieMapEntry | undefined {
|
||||
export function selectedZombieMap(
|
||||
game: string | null,
|
||||
map: string | null,
|
||||
slug?: string | null
|
||||
): ZombieMapEntry | undefined {
|
||||
const maps = zombieMaps(game);
|
||||
// T5 maps are unambiguous, including legacy friendly slugs. T6 variants
|
||||
// require the stored selection; never fall back from an unknown variant.
|
||||
return maps.find((entry) => entry.canonical === map && (
|
||||
game !== 't6' || !slug || entry.slug === slug
|
||||
|| entry.friendly.toLowerCase().replace(/[^a-z0-9]/g, '') === slug
|
||||
));
|
||||
return maps.find(
|
||||
(entry) =>
|
||||
entry.canonical === map &&
|
||||
(game !== 't6' ||
|
||||
!slug ||
|
||||
entry.slug === slug ||
|
||||
entry.friendly.toLowerCase().replace(/[^a-z0-9]/g, '') === slug)
|
||||
);
|
||||
}
|
||||
|
||||
export function mapRotation(entry: ZombieMapEntry): string {
|
||||
return `${entry.gameSettings ? `execgts ${entry.gameSettings} ` : ''}map ${entry.canonical}`;
|
||||
}
|
||||
|
||||
const BY_SLUG: ReadonlyMap<string, T5MapEntry> = new Map(
|
||||
T5_ZOMBIE_MAPS.map((m) => [m.slug, m])
|
||||
);
|
||||
const BY_SLUG: ReadonlyMap<string, T5MapEntry> = new Map(T5_ZOMBIE_MAPS.map((m) => [m.slug, m]));
|
||||
|
||||
export function t5ZombieMapBySlug(slug: string): T5MapEntry | undefined {
|
||||
return BY_SLUG.get(slug.toLowerCase());
|
||||
@@ -80,10 +126,10 @@ export function t5ZombieMapBySlug(slug: string): T5MapEntry | undefined {
|
||||
export type GameMode = 'zombie' | 'mp' | 'sp';
|
||||
|
||||
export interface ParsedServerName {
|
||||
game: string; // 't5'
|
||||
gameMode: GameMode | null; // 'zombie' — null when the second segment isn't a known mode
|
||||
mapSlug: string; // 'cosmodrome' — joined without separators for lookup
|
||||
mapCanonical: string | null;// 'zombie_cosmodrome' — null when slug not in catalog
|
||||
game: string; // 't5'
|
||||
gameMode: GameMode | null; // 'zombie' — null when the second segment isn't a known mode
|
||||
mapSlug: string; // 'cosmodrome' — joined without separators for lookup
|
||||
mapCanonical: string | null; // 'zombie_cosmodrome' — null when slug not in catalog
|
||||
lobby: number | null;
|
||||
}
|
||||
|
||||
@@ -122,10 +168,11 @@ export function parseServerName(name: string): ParsedServerName | null {
|
||||
|
||||
const mapSlug = slugParts.join('').toLowerCase();
|
||||
const catalog = zombieMaps(game.toLowerCase());
|
||||
const entry = gameMode === null || gameMode === 'zombie'
|
||||
? catalog.find((m) => m.slug === mapSlug)
|
||||
?? catalog.find((m) => m.friendly.toLowerCase().replace(/[^a-z0-9]/g, '') === mapSlug)
|
||||
: undefined;
|
||||
const entry =
|
||||
gameMode === null || gameMode === 'zombie'
|
||||
? (catalog.find((m) => m.slug === mapSlug) ??
|
||||
catalog.find((m) => m.friendly.toLowerCase().replace(/[^a-z0-9]/g, '') === mapSlug))
|
||||
: undefined;
|
||||
const mapCanonical = entry?.canonical ?? null;
|
||||
return { game, gameMode, mapSlug, mapCanonical, lobby };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user