优化角色评分计算;评分权重预定义模板规则,多流派选择 close #144 #145; fix #146

This commit is contained in:
UCPr 2025-09-08 16:06:49 +08:00
parent e9ca415922
commit bc3c641928
10 changed files with 640 additions and 575 deletions

View file

@ -1,46 +1,37 @@
import { getMapData } from '../utils/file.js';
import { charNameToID } from './convert/char.js';
import { IDToCharData } from './convert/char.js';
import { nameToId } from './convert/property.js';
/** @type {{ [propID: string]: number }} */
export const baseValueData = getMapData('EquipBaseValue');
const equipScore = getMapData('EquipScore');
/** @type {{ [charID: string]: { [propID: string]: number } }} */
export const scoreWeight = {};
const elementType2propId = (elementType) => [31503, 31603, 31703, 31803, , 31903][elementType - 200];
/**
* 将权重数据格式化为ID格式权重数据并处理小词条
* @returns {{ [propID: string]: number }}
* 将权重数据格式化为ID格式权重数据
* @returns {{ rules?: string[], [propID: string]: number }}
*/
export function formatScoreWeight(oriScoreWeight) {
export function formatScoreWeight(oriScoreWeight, charID) {
if (!oriScoreWeight) return false;
if (Array.isArray(oriScoreWeight)) return oriScoreWeight;
if (typeof oriScoreWeight !== 'object') return false;
const weight = {};
for (const propName in oriScoreWeight) {
if (!oriScoreWeight[propName] && oriScoreWeight[propName] !== 0)
continue;
const propID = +propName || nameToId(propName);
let propID;
if (charID && propName === '属性伤害加成') {
propID = elementType2propId(IDToCharData(charID)?.ElementType);
} else {
propID = +propName || nameToId(propName);
}
if (!propID)
continue;
weight[propID] = oriScoreWeight[propName];
};
/** 小生命、小攻击、小防御映射为大生命、大攻击、大防御的1/3 */
for (const [small, big] of [[11103, 11102], [12103, 12102], [13103, 13102]]) {
if (weight[big]) {
weight[small] ??= weight[big] / 3;
};
};
return weight;
}
for (const charName in equipScore) {
// 兼容原ID格式
const charID = +charName || charNameToID(charName);
if (!charID)
continue;
scoreWeight[charID] = formatScoreWeight(equipScore[charName]);
};
/**
* 获取词条强化次数
* @param {string} propertyID 属性id