Skip to content

Commit 37ab16d

Browse files
committed
games: Add bot as a meme trainer card
1 parent 8f7bed7 commit 37ab16d

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/ps/commands/games/other.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Small } from '@/ps/games/render';
88
import { checkWord } from '@/ps/games/scrabble/checker';
99
import { ScrabbleMods } from '@/ps/games/scrabble/constants';
1010
import { ScrabbleModData } from '@/ps/games/scrabble/mods';
11+
import { TOKEN_TYPE } from '@/ps/games/splendor/constants';
1112
import metadata from '@/ps/games/splendor/metadata.json';
1213
import { PokemonCard, TrainerCard } from '@/ps/games/splendor/render';
1314
import { LB_STYLES } from '@/ps/other/leaderboardStyles';
@@ -21,6 +22,7 @@ import { rankedSort } from '@/utils/rankedSort';
2122
import type { UGOUserPoints } from '@/cache/ugo';
2223
import type { ScrabbleDexEntry } from '@/database/games';
2324
import type { ToTranslate, TranslationFn } from '@/i18n/types';
25+
import type { Trainer } from '@/ps/games/splendor/types';
2426
import type { GamesList } from '@/ps/games/types';
2527
import type { PSCommand } from '@/types/chat';
2628
import type { ReactElement } from 'react';
@@ -114,7 +116,7 @@ export const command: PSCommand[] = [
114116
help: 'Shows the card info for a Splendor card.',
115117
syntax: 'CMD [card name]',
116118
categories: ['game'],
117-
async run({ broadcastHTML, arg, $T }) {
119+
async run({ message, broadcastHTML, arg, $T }) {
118120
const id = toId(arg);
119121
if (id === 'constructor') throw new ChatError($T('SCREW_YOU'));
120122
if (id in metadata.pokemon) {
@@ -131,6 +133,19 @@ export const command: PSCommand[] = [
131133
<TrainerCard data={card} />
132134
</Small>
133135
);
136+
} else if (id === message.parent.status.userid) {
137+
const card: Trainer = {
138+
id,
139+
name: message.parent.status.username ?? '-',
140+
points: 15,
141+
types: { [TOKEN_TYPE.DRAGON]: 4 },
142+
art: 'https://play.pokemonshowdown.com/sprites/trainers/supernerd.png',
143+
};
144+
broadcastHTML(
145+
<Small>
146+
<TrainerCard data={card} />
147+
</Small>
148+
);
134149
} else throw new ChatError($T('ENTRY_NOT_FOUND'));
135150
},
136151
},

src/ps/games/splendor/render.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { CSSProperties, ReactElement, ReactNode } from 'react';
1414
type This = { msg: string };
1515

1616
function getArtUrl(type: 'pokemon' | 'trainers' | 'type' | 'other', path: string, tag: 'img' | 'bg' = 'bg'): string {
17-
const baseURL = `${process.env.WEB_URL}/static/splendor/${type}/${path}`;
17+
const baseURL = path.startsWith('http') ? path : `${process.env.WEB_URL}/static/splendor/${type}/${path}`;
1818
return tag === 'bg' ? `url(${baseURL})` : baseURL;
1919
}
2020

0 commit comments

Comments
 (0)