forked from WikiDeck/wikideck
41 lines
2.6 KiB
TypeScript
41 lines
2.6 KiB
TypeScript
// Display names and one-line reminder text (DESIGN §10.2, §10.3). The engine registry wins when it
|
||
// has an entry; this table covers keywords and Portals whose registry entry hasn't landed yet.
|
||
import { KEYWORDS, PORTALS, type Ruleset, type Stat } from '../../shared/game/index.ts';
|
||
|
||
const KW: Record<string, [string, string]> = {
|
||
viral: ['Viral', 'On reveal: +{amount} power for each other card you revealed earlier this turn (max +{cap}).'],
|
||
rising: ['Rising', 'End of turn: +{amount} power (max +{cap} total).'],
|
||
local: ['Local', 'Ongoing: +{amount} power while on-topic.'],
|
||
encyclopedic: ['Encyclopedic', 'On reveal: +{amount} power if there are no other cards here.'],
|
||
nostalgic: ['Nostalgic', 'On reveal: +{amount} power if you are losing here.'],
|
||
translated: ['Translated', 'On reveal: +{amount} power to your most recent card in each other Topic.'],
|
||
edition: ['Edition', '+{amount} power for each other copy of this article on your side.'],
|
||
obscure: ['Obscure', 'Your opponent sees this face down until the match ends.'],
|
||
wildcard: ['Wildcard', 'On reveal: its home stat becomes this Topic’s stat.'],
|
||
};
|
||
const PORTAL: Record<string, [string, string]> = {
|
||
'main-page': ['Main Page', 'At scoring, each card here gets +1 power.'],
|
||
trending: ['Trending', 'Trend arrows count double here.'],
|
||
'featured-article': ['Featured Article', 'At scoring, whoever has the single strongest card here gets +2.'],
|
||
stub: ['Stub', 'Only 2 cards per player fit here.'],
|
||
interwiki: ['Interwiki', '+1 here if you have a card in all 3 Topics.'],
|
||
disambiguation: ['Disambiguation', 'Every card here counts as on-topic.'],
|
||
};
|
||
const fill = (text: string, params: Record<string, number> = {}) => text.replace(/\{(\w+)\}/g, (_, k) => String(params[k] ?? k));
|
||
|
||
export const STAT_LABEL: Record<Stat, string> = { attention: 'Attention', depth: 'Depth', reach: 'Reach' };
|
||
export const STAT_HINT: Record<Stat, string> = {
|
||
attention: 'how many people read it', depth: 'how long the article is', reach: 'how many languages it’s in',
|
||
};
|
||
|
||
export function keywordInfo(id: string | null, rules?: Ruleset) {
|
||
if (!id) return undefined;
|
||
const reg = KEYWORDS[id], fb = KW[id];
|
||
return { id, name: reg?.name ?? fb?.[0] ?? id, text: fill(reg?.text ?? fb?.[1] ?? '', rules?.keywordParams[id]) };
|
||
}
|
||
export function portalInfo(portalId: string | null, topicId: string, rules?: Ruleset) {
|
||
if (!portalId) return undefined;
|
||
const reg = PORTALS[portalId], fb = PORTAL[portalId];
|
||
return { name: reg?.name ?? fb?.[0] ?? portalId, text: fill(reg?.text ?? fb?.[1] ?? '', rules?.portalParams[topicId] ?? rules?.portalParams[portalId]) };
|
||
}
|