Skip to content

Commit 26ac52e

Browse files
committed
games: Add a way to view mods
1 parent 6a410a2 commit 26ac52e

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

src/ps/commands/games/core.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ChatError } from '@/utils/chatError';
99

1010
import type { NoTranslate, ToTranslate, TranslationFn } from '@/i18n/types';
1111
import type { CommonGame } from '@/ps/games/game';
12+
import type { BaseModEntry } from '@/ps/games/mods';
1213
import type { PSCommand } from '@/types/chat';
1314
import type { Room } from 'ps-client';
1415
import type { HTMLopts } from 'ps-client/classes/common';
@@ -399,6 +400,31 @@ export const command: PSCommand[] = Object.entries(Games).map(([_gameId, Game]):
399400
if (applied.success) message.reply(applied.data);
400401
},
401402
},
403+
mods: {
404+
name: 'mods',
405+
aliases: ['modslist', 'listmods', 'modoptions'],
406+
help: `Lists the mods available for ${Game.meta.name}.`,
407+
syntax: 'CMD',
408+
async run({ broadcastHTML }) {
409+
const mods = Game.meta.mods!;
410+
broadcastHTML(
411+
<div>
412+
{Object.values(mods.data)
413+
.filter((mod): mod is BaseModEntry => !!mod)
414+
.map(mod => (
415+
<details>
416+
<summary>
417+
<b>{mod.name}</b>
418+
{mod.aliases?.length ? ` (${mod.aliases.join('/')})` : null}
419+
</summary>
420+
{mod.desc}
421+
</details>
422+
))
423+
.space(<br />)}
424+
</div>
425+
);
426+
},
427+
},
402428
} satisfies PSCommand['children'])
403429
: {}),
404430
...(Game.meta.themes

src/ps/games/mods.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { toId } from '@/tools';
22

33
export type ModEnum<Mod extends string> = Record<string, Mod>;
4-
export type ModData<Mod extends string> = Partial<Record<Mod, { aliases?: string[] | undefined }>>;
4+
export type BaseModEntry = { id: string; name: string; desc: string; aliases?: string[] | undefined };
5+
export type ModData<Mod extends string> = Partial<Record<Mod, BaseModEntry>>;
56

67
export function parseMod<Mod extends string>(input: string, mods: ModEnum<Mod>, modData: ModData<Mod>): Mod | null {
78
const query = toId(input);

src/ps/games/scrabble/mods.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
import { DICTIONARY, ScrabbleMods } from '@/ps/games/scrabble/constants';
22

3+
import type { BaseModEntry } from '@/ps/games/mods';
34
import type { LetterMetadata, WordScore } from '@/ps/games/scrabble/types';
45

56
export const ScrabbleModData: Record<
67
ScrabbleMods,
7-
{ name: string; dict: DICTIONARY; aliases?: string[]; points?: LetterMetadata; counts?: LetterMetadata }
8+
BaseModEntry & { dict: DICTIONARY; points?: LetterMetadata; counts?: LetterMetadata }
89
> = {
910
[ScrabbleMods.CSW19]: {
11+
id: ScrabbleMods.CSW19,
1012
name: 'CSW19',
13+
desc: 'Base Scrabble with the CSW19 dictionary.',
1114
dict: DICTIONARY.CSW19,
1215
},
1316
[ScrabbleMods.CSW21]: {
17+
id: ScrabbleMods.CSW21,
1418
name: 'CSW21',
19+
desc: 'Base Scrabble with the CSW21 dictionary.',
1520
dict: DICTIONARY.CSW21,
1621
},
1722
[ScrabbleMods.CSW24]: {
23+
id: ScrabbleMods.CSW24,
1824
name: 'CSW24',
25+
desc: 'Base Scrabble with the CSW24 dictionary.',
1926
dict: DICTIONARY.CSW24,
2027
aliases: ['current'],
2128
},
2229
[ScrabbleMods.ODS8]: {
30+
id: ScrabbleMods.ODS8,
2331
name: 'ODS8',
32+
desc: 'French variant of Scrabble.',
2433
dict: DICTIONARY.ODS8,
2534
counts: {
2635
A: 9,
@@ -83,16 +92,22 @@ export const ScrabbleModData: Record<
8392
aliases: ['ods', 'french', 'francais', 'franais'],
8493
},
8594
[ScrabbleMods.CLABBERS]: {
95+
id: ScrabbleMods.CLABBERS,
8696
name: 'Clabbers',
97+
desc: 'Scrabble, but all anagrams are valid, too!',
8798
dict: DICTIONARY.CLABBERS,
8899
},
89100
[ScrabbleMods.POKEMON]: {
101+
id: ScrabbleMods.POKEMON,
90102
name: 'Pokémon',
103+
desc: 'Scrabble but Pokéwords are allowed (with bonus scoring)!',
91104
dict: DICTIONARY.CSW24,
92105
aliases: ['pokemod', 'pokmon', 'pkmn', 'mons'],
93106
},
94107
[ScrabbleMods.CRAZYMONS]: {
108+
id: ScrabbleMods.CRAZYMONS,
95109
name: 'CRAZYMONS',
110+
desc: 'PokéScrabble, but INsANe BONuSEs!',
96111
dict: DICTIONARY.CSW24,
97112
aliases: ['crazy'],
98113
},

0 commit comments

Comments
 (0)