mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 21:27:47 +00:00
支持自定义评分规则、支持动态选用、更新相关文档
This commit is contained in:
parent
06ec5152a0
commit
504d2792a8
11 changed files with 217 additions and 114 deletions
54
lib/score.js
54
lib/score.js
|
|
@ -6,41 +6,39 @@ import { nameToId } from './convert/property.js';
|
|||
export const baseValueData = getMapData('EquipBaseValue');
|
||||
const equipScore = getMapData('EquipScore');
|
||||
/** @type {{ [charID: string]: { [propID: string]: number } }} */
|
||||
export const scoreData = Object.create(null);
|
||||
for (const charName in equipScore) {
|
||||
// 兼容原ID格式
|
||||
if (+charName) {
|
||||
scoreData[charName] = equipScore[charName];
|
||||
continue;
|
||||
};
|
||||
const charID = charNameToID(charName);
|
||||
if (!charID)
|
||||
continue;
|
||||
scoreData[charID] = Object.create(null);
|
||||
for (const propName in equipScore[charName]) {
|
||||
const propID = nameToId(propName);
|
||||
if (!propID || !equipScore[charName][propName])
|
||||
export const scoreWeight = Object.create(null);
|
||||
|
||||
/**
|
||||
* 将权重数据格式化为ID格式权重数据并处理小词条
|
||||
* @returns {{ [propID: string]: number }}
|
||||
*/
|
||||
export function formatScoreWeight(oriScoreWeight) {
|
||||
if (!oriScoreWeight) return false;
|
||||
if (typeof oriScoreWeight !== 'object') return false;
|
||||
const weight = Object.create(null);
|
||||
for (const propName in oriScoreWeight) {
|
||||
if (!oriScoreWeight[propName])
|
||||
continue;
|
||||
scoreData[charID][propID] = equipScore[charName][propName];
|
||||
const 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 (scoreData[charID][big]) {
|
||||
scoreData[charID][small] ??= scoreData[charID][big] / 3;
|
||||
if (weight[big]) {
|
||||
weight[small] ??= weight[big] / 3;
|
||||
};
|
||||
};
|
||||
};
|
||||
return weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有分数数据
|
||||
* @param {string} charID 角色id
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export const hasScoreData = charID => {
|
||||
return (
|
||||
scoreData[charID] &&
|
||||
Object.keys(scoreData[charID]).length > 0
|
||||
);
|
||||
for (const charName in equipScore) {
|
||||
// 兼容原ID格式
|
||||
const charID = +charName || charNameToID(charName);
|
||||
if (!charID)
|
||||
continue;
|
||||
scoreWeight[charID] = formatScoreWeight(equipScore[charName]);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue