You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.2 KiB
62 lines
2.2 KiB
|
3 weeks ago
|
import { Weapon2TileType } from 'db://assets/mx/module/merge';
|
||
|
|
import type { BagRollEntry } from '../bag/BagWeaponPool';
|
||
|
|
import { textDisplayName } from '../config/BattleHeroTable';
|
||
|
|
import { WeaponComposeConfigProvider } from '../bag/WeaponComposeConfigProvider';
|
||
|
|
import { isDesignDebugEnabled } from './DesignDebug';
|
||
|
|
|
||
|
|
const TAG = '[BagRefreshDebug]';
|
||
|
|
const STYLE = 'color:#E6A23C;font-weight:bold';
|
||
|
|
|
||
|
|
/** 策划验算法开关(默认关,随 DesignDebug 或单独开启) */
|
||
|
|
let _enabled = false;
|
||
|
|
|
||
|
|
export function setBagRefreshDebugEnabled(enabled: boolean): void {
|
||
|
|
_enabled = enabled;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function isBagRefreshDebugEnabled(): boolean {
|
||
|
|
return _enabled || isDesignDebugEnabled();
|
||
|
|
}
|
||
|
|
|
||
|
|
export function logBagRefreshDebug(message: string, ...args: unknown[]): void {
|
||
|
|
if (!_enabled) return;
|
||
|
|
console.debug(`%c${TAG} ${message}`, STYLE, ...args);
|
||
|
|
}
|
||
|
|
|
||
|
|
export function logBagRefreshSection(title: string): void {
|
||
|
|
logBagRefreshDebug(`──────── ${title} ────────`);
|
||
|
|
}
|
||
|
|
|
||
|
|
const TILE_TYPE_LABEL: Record<number, string> = {
|
||
|
|
[Weapon2TileType.Single]: '单字',
|
||
|
|
[Weapon2TileType.Combo]: '组合字',
|
||
|
|
[Weapon2TileType.Grid]: '格子',
|
||
|
|
[Weapon2TileType.Shovel]: '铲',
|
||
|
|
};
|
||
|
|
|
||
|
|
export function formatWeapon2Brief(
|
||
|
|
weapon2Id: number,
|
||
|
|
provider: WeaponComposeConfigProvider = WeaponComposeConfigProvider.instance,
|
||
|
|
): string {
|
||
|
|
const row = provider.getWeapon2Config(weapon2Id);
|
||
|
|
const type = provider.getWeapon2Type(weapon2Id);
|
||
|
|
const typeLabel = TILE_TYPE_LABEL[type] ?? `type${type}`;
|
||
|
|
if (!row) return `id=${weapon2Id}(${typeLabel})`;
|
||
|
|
const name = textDisplayName(row);
|
||
|
|
return `${name}(id=${weapon2Id},${typeLabel})`;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function formatBagRollEntries(
|
||
|
|
entries: readonly BagRollEntry[],
|
||
|
|
provider: WeaponComposeConfigProvider = WeaponComposeConfigProvider.instance,
|
||
|
|
): string {
|
||
|
|
if (entries.length === 0) return '[]';
|
||
|
|
return `[${entries.map((e, i) => `${i}:${formatWeapon2Brief(e.weapon2Id, provider)}`).join(', ')}]`;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function formatIdList(ids: readonly number[] | null | undefined): string {
|
||
|
|
if (!ids?.length) return '[]';
|
||
|
|
const provider = WeaponComposeConfigProvider.instance;
|
||
|
|
return `[${ids.map((id) => formatWeapon2Brief(id, provider)).join(', ')}]`;
|
||
|
|
}
|