feedback5 WI: server toasts and ticker lines carry msgid + params so the client shows them in the player's language
messaging.js: a toast / CUSTOM ticker line is a string (its own msgid) or a shared/i18n.js msg(); frames keep
the Chinese `text` (older clients) and add `msgid` / `params`; config.broadcasts lines carry their `args`
(the client fills the localized broadcast template; the player name {0} is never translated). Templated call
sites send msg(): the grant toast 「X:获得Y」, the summon-range and terrain withdrawals, the 联防 line,
eliminated / left lines, the 远见 / 奇迹 stack payouts and the 维多利亚 hammers; game-data names go as dn().
The protocol stays backward compatible (new fields optional). Tests that captured m.toast's argument render
it with renderMessage. No gameplay change: golden unchanged.
This commit is contained in:
1 parent
a12a539e4d
commit
5398a0cfc5
12 files changed
+166
-18
No files matched your search
@@ -41,6 +41,7 @@ import { boardOrder, parseKey, tileKey } from './board.js';
|
||||
import { pieceBonds as bondsOfPiece } from './bondsMeta.js';
|
||||
import { registerAllMeta } from '../sim/content/index.js';
|
||||
import { registerBuiltins } from './builtinMeta.js';
|
||||
import { msg, dn } from '../../shared/i18n.js';
|
||||
|
||||
export const HOOKS = Object.freeze([
|
||||
'onRoundStart', 'onIncome', 'onPrepStart', 'onPrepEnd', 'onGain', 'onSold', 'onRefresh', 'onPrice', 'onBuy',
|
||||
@@ -525,7 +526,7 @@ export function makeCtx(m, ps, source, hook, ev = null) {
|
||||
const name = got && got.name;
|
||||
if (name) {
|
||||
const who = grantSpeaker(gd, source);
|
||||
m.toast(ps, 'info', who ? `${who}:获得${name}` : `获得${name}`);
|
||||
m.toast(ps, 'info', who ? msg('{who}:获得{name}', { who: dn(who), name: dn(name) }) : msg('获得{name}', { name: dn(name) }));
|
||||
}
|
||||
}
|
||||
return p ? view(p) : null;
|
||||
@@ -635,8 +636,9 @@ export function makeCtx(m, ps, source, hook, ev = null) {
|
||||
addBounty: (card) => m.addBounty(ps, card),
|
||||
|
||||
// ---- messaging
|
||||
toast: (text, kind = 'info') => m.toast(ps, kind, String(text)),
|
||||
ticker: (text) => m.tickerText(String(text)),
|
||||
// a string or a shared/i18n.js msg(msgid, params)
|
||||
toast: (text, kind = 'info') => m.toast(ps, kind, text && typeof text === 'object' ? text : String(text)),
|
||||
ticker: (text) => m.tickerText(text && typeof text === 'object' ? text : String(text)),
|
||||
/** CHAR_GIFT broadcast to this player: "{0}博士给你赠送了{1}". */
|
||||
giftTicker: (fromName, chessId) => { const c = gd.chess(chessId); m.tickerFor('CHAR_GIFT', [String(fromName), c ? c.name : String(chessId)], { to: ps.playerId }); },
|
||||
|
||||
|
||||
Reference in new issue
Block a user