@@ -10,15 +10,15 @@ import {
1010 PLAY_ACTION_PATTERN ,
1111 RACK_SIZE ,
1212 SELECT_ACTION_PATTERN ,
13+ ScrabbleMods ,
1314} from '@/ps/games/scrabble/constants' ;
1415import { ScrabbleModData } from '@/ps/games/scrabble/mods' ;
1516import { render , renderMove } from '@/ps/games/scrabble/render' ;
16- import { createGrid } from '@/ps/games/utils' ;
17+ import { checkUGO , createGrid } from '@/ps/games/utils' ;
1718import { 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' ;
2021import type { BaseContext } from '@/ps/games/game' ;
21- import type { ScrabbleMods } from '@/ps/games/scrabble/constants' ;
2222import type { Log } from '@/ps/games/scrabble/logs' ;
2323import type { BoardTile , Bonus , BonusReducer , Points , RenderCtx , State , WinCtx , Word , WordScore } from '@/ps/games/scrabble/types' ;
2424import 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