|
| 1 | +import { GOData } from '@/cache/pokemonGo'; |
| 2 | +import { toId } from '@/tools'; |
| 3 | +import { ChatError } from '@/utils/chatError'; |
| 4 | +import { PSIcon } from '@/utils/components/ps/psicon'; |
| 5 | +import { getCP } from '@/utils/pokemonGo'; |
| 6 | + |
| 7 | +import type { PSCommand } from '@/types/chat'; |
| 8 | + |
| 9 | +function getPokemonGen(num: number): number { |
| 10 | + return [0, 152, 252, 387, 495, 650, 722, 810, 906, 1011].findIndex(firstOfGen => num < firstOfGen); |
| 11 | +} |
| 12 | + |
| 13 | +export const command: PSCommand[] = [ |
| 14 | + { |
| 15 | + name: 'dt', |
| 16 | + help: 'Shows the data for a Pokémon.', |
| 17 | + syntax: 'CMD [mon/move]', |
| 18 | + // TODO: Keep this GO-only |
| 19 | + async run({ broadcastHTML, arg, $T }) { |
| 20 | + const query = toId(arg); |
| 21 | + if (query === 'constructor') throw new ChatError($T('SCREW_YOU')); |
| 22 | + if (query in GOData.pokedex) { |
| 23 | + const mon = GOData.pokedex[query]; |
| 24 | + const stats = mon.baseStats; |
| 25 | + |
| 26 | + return broadcastHTML( |
| 27 | + <> |
| 28 | + <div className="message"> |
| 29 | + <ul className="utilichart"> |
| 30 | + <li className="result"> |
| 31 | + <span className="col numcol">{mon.unreleased ? 'UR' : 'GO'}</span>{' '} |
| 32 | + <span className="col iconcol"> |
| 33 | + <PSIcon pokemon={toId(mon.name)} /> |
| 34 | + </span>{' '} |
| 35 | + <span className="col pokemonnamecol" style={{ whiteSpace: 'nowrap' }}> |
| 36 | + <a href={`https://dex.pokemonshowdown.com/pokemon/${toId(mon.name)}`} target="_blank"> |
| 37 | + {mon.name} |
| 38 | + </a> |
| 39 | + </span>{' '} |
| 40 | + <span className="col typecol"> |
| 41 | + {mon.types.map(type => ( |
| 42 | + <img src={`https://play.pokemonshowdown.com/sprites/types/${type}.png`} alt={type} height="14" width="32" /> |
| 43 | + ))} |
| 44 | + </span>{' '} |
| 45 | + <span style={{ float: 'left', minHeight: 26 }}> |
| 46 | + <span className="col statcol"> |
| 47 | + <em>Atk</em> |
| 48 | + <br /> |
| 49 | + {stats.atk} |
| 50 | + </span>{' '} |
| 51 | + <span className="col statcol"> |
| 52 | + <em>Def</em> |
| 53 | + <br /> |
| 54 | + {stats.def} |
| 55 | + </span>{' '} |
| 56 | + <span className="col statcol"> |
| 57 | + <em>Sta</em> |
| 58 | + <br /> |
| 59 | + {stats.sta} |
| 60 | + </span>{' '} |
| 61 | + <span className="col bstcol" style={{ marginLeft: 10 }}> |
| 62 | + <em>40</em> |
| 63 | + <br /> |
| 64 | + {getCP(stats, 40)} |
| 65 | + </span>{' '} |
| 66 | + <span className="col bstcol" style={{ marginLeft: 10 }}> |
| 67 | + <em>50</em> |
| 68 | + <br /> |
| 69 | + {getCP(stats, 50)} |
| 70 | + </span>{' '} |
| 71 | + <span className="col bstcol" style={{ marginLeft: 10 }}> |
| 72 | + <em>MCP</em> |
| 73 | + <br /> |
| 74 | + {getCP(stats, 51)} |
| 75 | + </span>{' '} |
| 76 | + </span> |
| 77 | + </li> |
| 78 | + <li style={{ clear: 'both' }}></li> |
| 79 | + </ul> |
| 80 | + </div> |
| 81 | + <font size={1}> |
| 82 | + <font color="#686868">Dex#:</font> {mon.num} | <font color="#686868">Gen:</font> {getPokemonGen(mon.num)} |
| 83 | + |  |
| 84 | + <font color="#686868">Height:</font> {mon.heightm} m | <font color="#686868">Weight:</font> {mon.weightkg} kg |
| 85 | + {mon.shiny ? <> |  ✓ Can be shiny</> : null} |
| 86 | + {mon.shinyLocked ? <> | Shiny-locked</> : null} | <font color="#686868">Evolution:</font>{' '} |
| 87 | + {mon.evos?.join(', ') || 'None'} |
| 88 | + </font> |
| 89 | + <br /> |
| 90 | + <hr /> |
| 91 | + <details style={{ marginBottom: -10 }}> |
| 92 | + <summary title={mon.unreleased ? 'Moves are for an unreleased Pokémon and may not be accurate' : undefined}> |
| 93 | + Moves{mon.unreleased ? '*' : ''} |
| 94 | + </summary> |
| 95 | + Fast: {[...mon.moves.fast, ...mon.moves.fast_elite.map(move => `${move}*`)].sort().join(', ')} |
| 96 | + <br /> |
| 97 | + Charged: {[...mon.moves.charged, ...mon.moves.charged_elite.map(move => `${move}*`)].sort().join(', ')} |
| 98 | + </details> |
| 99 | + </> |
| 100 | + ); |
| 101 | + } |
| 102 | + |
| 103 | + throw new ChatError($T('ENTRY_NOT_FOUND')); |
| 104 | + }, |
| 105 | + }, |
| 106 | +]; |
0 commit comments