mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-17 05:37:46 +00:00
删减部分冗余
This commit is contained in:
parent
cfb0c40765
commit
edc6472c10
2 changed files with 19 additions and 33 deletions
|
|
@ -58,7 +58,7 @@ const PERCENT_ID_LIST = Object.keys(ID_TO_PROP_NAME).filter(id => // IDs formatt
|
|||
['20103', '21103', '23103', '12203', '30502', '12202'].includes(id) // Explicitly add IDs known to be %
|
||||
);
|
||||
const ELEMENT_TO_EN = { '203': 'Thunder', '205': 'Ether', '202': 'Ice', '200': 'Phys', '201': 'Fire' };
|
||||
/
|
||||
|
||||
function formatEquipWeaponPropValue(value, prop_id) {
|
||||
const idStr = String(prop_id);
|
||||
const isPercentProp = PERCENT_ID_LIST.includes(idStr);
|
||||
|
|
@ -69,6 +69,7 @@ function formatEquipWeaponPropValue(value, prop_id) {
|
|||
else { return String(Math.floor(numericValue)); } // No special ER formatting for equips
|
||||
} catch (e) { logger.error(`Error formatting E/W prop value ${value} for ${prop_id}:`, e); return '0'; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates final weapon base and random stat values (raw, 1/10000 unit).
|
||||
* @param {object} weapon_meta Metadata for the weapon.
|
||||
|
|
@ -481,13 +482,13 @@ export async function _enka_data_to_mys_data(enka_data) {
|
|||
// Add the fully processed character object to the list
|
||||
result_list.push(result);
|
||||
|
||||
|
||||
// *** End of try block for individual character processing ***
|
||||
} catch (processingError) {
|
||||
logger.error(`[enka_to_mys.js] CRITICAL ERROR processing character ID ${char?.Id || 'Unknown'}:`, processingError.message);
|
||||
logger.error(processingError.stack); // Log the full stack trace
|
||||
}
|
||||
}
|
||||
} // --- End of character loop ---
|
||||
|
||||
logger.info(`[enka_to_mys.js] Finished conversion. Processed ${result_list.length} characters.`);
|
||||
return result_list;
|
||||
return result_list; // Return the list of converted data
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
// name_convert.js
|
||||
console.log('[name_convert.js] 文件开始执行'); // <--- 加入这行
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
import { fileURLToPath } from 'node:url'; // <--- 1. 导入 fileURLToPath
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
// Use import.meta.url WITH fileURLToPath
|
||||
const __filename = fileURLToPath(import.meta.url); // <--- 2. 获取当前文件的绝对路径
|
||||
const __dirname = path.dirname(__filename); // <--- 3. 获取当前文件所在的目录路径
|
||||
|
||||
const MAP_PATH = __dirname; // Data files are in the same directory
|
||||
const ALIAS_LIST_DIR = path.join(__dirname, 'alias'); // Alias directory path
|
||||
const CHAR_ALIAS_FILE = path.join(ALIAS_LIST_DIR, 'char_alias.json'); // Alias file path
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const MAP_PATH = __dirname;
|
||||
const ALIAS_LIST_DIR = path.join(__dirname, 'alias');
|
||||
const CHAR_ALIAS_FILE = path.join(ALIAS_LIST_DIR, 'char_alias.json');
|
||||
const BASE_IMAGE_URL = 'https://enka.network';
|
||||
const PartnerId2DataFile = 'PartnerId2Data.json';
|
||||
const WeaponId2DataFile = 'WeaponId2Data.json';
|
||||
|
|
@ -27,19 +25,17 @@ try {
|
|||
const skillParamContent = fs.readFileSync(skillParamPath, { encoding: 'utf-8' });
|
||||
PartnerId2SkillParam = JSON.parse(skillParamContent);
|
||||
logger.debug(`[name_convert.js] 成功加载并解析 ${SkillParamFile}。`);
|
||||
// 可以选择性地添加更多日志来确认加载内容
|
||||
// logger.debug(`[name_convert.js] 加载了 ${Object.keys(PartnerId2SkillParam).length} 个角色的技能数据。`);
|
||||
|
||||
} else {
|
||||
console.error(`${SkillParamFile} 文件未找到于: ${skillParamPath}`);
|
||||
// 或者使用 console.warn 如果你希望即使缺少技能数据也能继续运行
|
||||
// console.warn(`${SkillParamFile} 文件未找到于: ${skillParamPath}. 技能名称将使用默认值。`);
|
||||
logger.error(`${SkillParamFile} 文件未找到于: ${skillParamPath}`);
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`读取或解析 ${SkillParamFile} 时出错:`, error);
|
||||
// 考虑是否在此处设置 PartnerId2SkillParam = {} 以防止后续错误
|
||||
|
||||
PartnerId2SkillParam = {};
|
||||
}
|
||||
// --- End 新增:加载技能数据 ---
|
||||
|
||||
let char_alias_data = {};
|
||||
try {
|
||||
// Ensure the alias directory exists before trying to read the file
|
||||
|
|
@ -63,13 +59,7 @@ try {
|
|||
logger.debug(`[name_convert.js] 加载了 ${Object.keys(partner_data).length} 个伙伴条目。`);
|
||||
logger.debug(`[name_convert.js] 加载后是否存在 "1191"? ${partner_data.hasOwnProperty('1191')}`);
|
||||
logger.debug(`[name_convert.js] 加载后是否存在 "1021"? ${partner_data.hasOwnProperty('1021')}`);
|
||||
// Optional: Keep debug logs if needed during development
|
||||
// logger.debug('--- partner_data loaded successfully ---');
|
||||
// logger.debug(`Loaded ${Object.keys(partner_data).length} partner entries.`);
|
||||
// logger.debug('--- partner_data sample entry ---');
|
||||
// const sampleKey = Object.keys(partner_data)[0];
|
||||
// if (sampleKey) logger.debug({ [sampleKey]: partner_data[sampleKey] });
|
||||
// logger.debug('--- partner_data loading end ---');
|
||||
|
||||
} else {
|
||||
console.error(`Partner data file not found at: ${partnerDataPath}`);
|
||||
}
|
||||
|
|
@ -251,12 +241,7 @@ export function get_char_circle_icon_url(char_id) { // 使用 export function
|
|||
return undefined;
|
||||
}
|
||||
} else {
|
||||
// 可选日志:指示在 avatar_icon_data 中未找到
|
||||
// if (!avatar_icon_data[charIdStr]) {
|
||||
// console.warn(`[name_convert.js] 在 ${AvatarIconDataFile} 中未找到角色 ID ${charIdStr} 的数据 (用于获取 circle icon URL)。`);
|
||||
// } else if (!avatar_icon_data[charIdStr].CircleIcon || typeof avatar_icon_data[charIdStr].CircleIcon !== 'string') {
|
||||
// console.warn(`[name_convert.js] ${AvatarIconDataFile} 中角色 ID ${charIdStr} 缺少有效 CircleIcon 路径。`);
|
||||
// }
|
||||
|
||||
return undefined; // 数据或路径缺失则返回 undefined
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue