0.2.5-dev: an optional 「官方伤害数字」 setting (default off) shows only the numbers the official game shows per the PRTS red-number rule (#412, the owner's decision of 2026-10-12); a small link to the project's GitHub repository on the title page (#543); golden: unchanged

This commit is contained in:
sganggs committed 2026-10-12 14:59:20 +08:00
1 parent 7fd0478dc0
commit a3e8460bb0
26 files changed
+555 -43

No files matched your search

+28 -6
View File
@@ -60,6 +60,30 @@ export function fallbackTileClass(stage, row, col) {
return 'floor';
}
/**
* The simplified board's floating label for one event, or null when that event draws no digits.
* Official mode keeps only a marked red integer (including 0) and a yellow MISS. The slot stays above the unit;
* the random offset of the Pixi numbers is not repeated here [ASSUMED].
* @param {any[]} e
* @param {{ damageNumbers?: boolean, officialDamageNumbers?: boolean }} settings
* @returns {{ id: any, text: string, type: string }|null}
*/
export function fallbackFloat(e, settings) {
if (!settings?.damageNumbers || !Array.isArray(e)) return null;
if (settings.officialDamageNumbers === true) {
if (e[0] === 'fx' && e[1] === 'dodge' && e[4] && e[4].num === 'm') return { id: e[4].id, text: 'MISS', type: 'miss' };
if (e[0] !== 'dmg' || e[4] !== 'r') return null;
const amount = Math.round(Number(e[2]) || 0);
if (!Number.isFinite(amount) || amount < 0) return null;
return { id: e[1], text: String(amount), type: 'crit' };
}
if (e[0] !== 'dmg' && e[0] !== 'heal') return null;
const amount = Math.round(Number(e[2]) || 0);
if (amount <= 0) return null;
const type = e[0] === 'heal' ? 'heal' : (e[3] === 'arts' ? 'arts' : e[3] === 'true' ? 'true' : 'phys');
return { id: e[1], text: e[0] === 'heal' ? `+${amount}` : String(amount), type };
}
/**
* Create the DOM fallback view.
* @param {HTMLElement} host
@@ -78,7 +102,7 @@ export function createFallbackView(host, opts = {}) {
stage: null, camera: 'prep', rect: { ...GEO.NORMAL_RECT }, side: 'L', deployField: 'normal',
mode: 'prep', priv: null, editable: false, canPlace: null,
field: null, units: new Map(), snapUnits: new Map(), highlight: new Map(), hlGroups: new Map(), held: new Map(), dirs: new Map(),
drag: null, hoverTarget: null, floats: [], settings: { damageNumbers: true, ...(opts.settings || {}) },
drag: null, hoverTarget: null, floats: [], settings: { damageNumbers: true, officialDamageNumbers: false, ...(opts.settings || {}) },
size: { w: 0, h: 0 }, destroyed: false, pen: [],
};
@@ -456,11 +480,9 @@ export function createFallbackView(host, opts = {}) {
if (e[0] === 'spawn' && e[1] && e[1].id != null) {
st.units.set(e[1].id, e[1]);
if (!st.snapUnits.has(e[1].id)) st.snapUnits.set(e[1].id, [e[1].id, e[1].x, e[1].y, e[1].maxHp, e[1].maxHp, 0, 0, 0, 6]);
} else if ((e[0] === 'dmg' || e[0] === 'heal') && st.settings.damageNumbers && st.floats.length < 60) {
const amount = Math.round(Number(e[2]) || 0);
if (amount <= 0) continue;
const type = e[0] === 'heal' ? 'heal' : (e[3] === 'arts' ? 'arts' : e[3] === 'true' ? 'true' : 'phys');
st.floats.push({ key: `${now}:${Math.random()}`, id: e[1], text: e[0] === 'heal' ? `+${amount}` : String(amount), type, at: now });
} else if (st.floats.length < 60) {
const spec = fallbackFloat(e, st.settings);
if (spec) st.floats.push({ key: `${now}:${Math.random()}`, id: spec.id, text: spec.text, type: spec.type, at: now });
}
}
schedule();