Skip to content

Commit a628301

Browse files
committed
games: Force Scrabble to have Pokémod during UGO
1 parent d2960a3 commit a628301

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/ps/games/scrabble/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import {
1010
PLAY_ACTION_PATTERN,
1111
RACK_SIZE,
1212
SELECT_ACTION_PATTERN,
13+
ScrabbleMods,
1314
} from '@/ps/games/scrabble/constants';
1415
import { ScrabbleModData } from '@/ps/games/scrabble/mods';
1516
import { render, renderMove } from '@/ps/games/scrabble/render';
16-
import { createGrid } from '@/ps/games/utils';
17+
import { checkUGO, createGrid } from '@/ps/games/utils';
1718
import { type Point, coincident, flipPoint, multiStepPoint, rangePoints, stepPoint } from '@/utils/grid';
1819

19-
import type { TranslatedText } from '@/i18n/types';
20+
import type { ToTranslate, TranslatedText } from '@/i18n/types';
2021
import type { BaseContext } from '@/ps/games/game';
21-
import type { ScrabbleMods } from '@/ps/games/scrabble/constants';
2222
import type { Log } from '@/ps/games/scrabble/logs';
2323
import type { BoardTile, Bonus, BonusReducer, Points, RenderCtx, State, WinCtx, Word, WordScore } from '@/ps/games/scrabble/types';
2424
import type { ActionResponse, EndType } from '@/ps/games/types';
@@ -48,12 +48,22 @@ export class Scrabble extends BaseGame<State> {
4848
}
4949

5050
applyMod(mod: ScrabbleMods): ActionResponse<TranslatedText> {
51+
// UGO-CODE
52+
if (checkUGO(this) && ![ScrabbleMods.POKEMON, ScrabbleMods.CRAZYMONS].includes(mod))
53+
return { success: false, error: 'The only mods allowed during UGO are Pokémon and Crazymons!' as ToTranslate };
5154
this.mod = mod;
5255
this.points = ScrabbleModData[mod].points ?? LETTER_POINTS;
5356
return { success: true, data: this.$T('GAME.APPLIED_MOD', { mod: ScrabbleModData[mod].name, id: this.id }) };
5457
}
5558

5659
onStart(): ActionResponse {
60+
// UGO-CODE
61+
if (checkUGO(this) && !this.mod) {
62+
const defaultMod = ScrabbleMods.POKEMON;
63+
const applyMons = this.applyMod(defaultMod);
64+
if (!applyMons.success) throw new Error(applyMons.error);
65+
this.room.send(`Game #${this.id} had ${ScrabbleModData[defaultMod].name} applied automatically!` as ToTranslate);
66+
}
5767
this.state.baseBoard = BaseBoard;
5868
this.state.board = createGrid<BoardTile | null>(BaseBoard.length, BaseBoard[0].length, () => null);
5969
this.state.bag = Object.entries((this.mod ? ScrabbleModData[this.mod].counts : null) ?? LETTER_COUNTS)

0 commit comments

Comments
 (0)