From cfb0c407652ae8a1ae989ad1aad3336d9758202b Mon Sep 17 00:00:00 2001 From: xyz <15380362192@163.com> Date: Fri, 4 Apr 2025 02:11:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E5=87=8F=E9=83=A8=E5=88=86=E5=86=97?= =?UTF-8?q?=E4=BD=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ekapi/enka_to_mys.js | 46 +++++++++++----------------------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/lib/ekapi/enka_to_mys.js b/lib/ekapi/enka_to_mys.js index c7d2d8d..04f3633 100644 --- a/lib/ekapi/enka_to_mys.js +++ b/lib/ekapi/enka_to_mys.js @@ -1,7 +1,4 @@ -// enka_to_mys.js -// Purpose: Converts Enka Network ZZZ showcase data to MyS API format based on provided samples. -// --- Imports --- import { equip_data, weapon_data, @@ -11,20 +8,18 @@ import { } from './name_convert.js'; import _ from 'lodash'; -// --- Simple Logger (Using console directly) --- -const logger = console; -// --- End Simple Logger --- -// --- Data Import Confirmation --- + + if (typeof partner_data === 'undefined' || Object.keys(partner_data || {}).length === 0) { logger.error("[enka_to_mys.js] CRITICAL ERROR: partner_data is undefined or empty!"); } if (typeof PartnerId2SkillParam === 'undefined') { PartnerId2SkillParam = {}; logger.warn("[enka_to_mys.js] WARNING: PartnerId2SkillParam is undefined."); } if (typeof equip_data === 'undefined') { equip_data = {}; logger.warn("[enka_to_mys.js] WARNING: equip_data is undefined."); } if (typeof weapon_data === 'undefined') { weapon_data = {}; logger.warn("[enka_to_mys.js] WARNING: weapon_data is undefined."); } -// --- End Data Import Confirmation --- -// --- Constants and Mappings --- + + const ID_TO_PROP_NAME = { '11101': '生命值', '11103': '生命值', '11102': '生命值百分比', '12101': '攻击力', '12103': '攻击力', '12102': '攻击力百分比', '13101': '防御力', '13103': '防御力', '13102': '防御力百分比', '12203': '冲击力', '20103': '暴击率', '21103': '暴击伤害', @@ -32,25 +27,25 @@ const ID_TO_PROP_NAME = { '30503': '能量自动回复', '30502': '能量自动回复', '31503': '物理伤害加成', '31603': '火属性伤害加成', '31703': '冰属性伤害加成', '31803': '雷属性伤害加成', '31903': '以太属性伤害加成', '12202': '冲击力', // Correcting ID 12202 based on sample equip[5] main stat }; -const MYSAPI_PROP_ID = { // Final Panel Property IDs +const MYSAPI_PROP_ID = { '生命值': 1, '攻击力': 2, '防御力': 3, '冲击力': 4, '暴击率': 5, '暴击伤害': 6, '异常掌控': 7, '异常精通': 8, '穿透率': 9, '能量自动回复': 11, // MyS uses 11 for SpRecover '穿透值': 232, '物理伤害加成': 315, '火属性伤害加成': 316, '冰属性伤害加成': 317, '雷属性伤害加成': 318, '以太属性伤害加成': 319, '生命值百分比': 0, '攻击力百分比': 0, '防御力百分比': 0, // Keep 0 for filtering in panel }; -const ID_TO_EN = { // Internal calculation keys +const ID_TO_EN = { '11101': 'HpMax', '11103': 'HpBase', '11102': 'HpAdd', '12101': 'Attack', '12103': 'AttackBase', '12102': 'AttackAdd', '13101': 'Defence', '13103': 'DefenceBase', '13102': 'DefenceAdd', '12203': 'BreakStun', // Flat Impact from Enka? MyS panel uses ID 4 '20103': 'Crit', '21103': 'CritDmg', '31402': 'ElementAbnormalPower', '31403': 'ElementAbnormalPower', '31202': 'ElementMystery', '31203': 'ElementMystery', '23103': 'PenRate', '23203': 'PenDelta', '30503': 'SpRecover', '30502': 'SpRecover', '31503': 'PhysDmgBonus', '31603': 'FireDmgBonus', '31703': 'IceDmgBonus', '31803': 'ThunderDmgBonus', '31903': 'EtherDmgBonus', - '12202': 'BreakStunPercent', // Assign a unique EN key for the % Impact (ID 12202) found on equip + '12202': 'BreakStunPercent', }; const EN_TO_ZH = {}; for (const id in ID_TO_EN) { if (ID_TO_PROP_NAME[id]) { EN_TO_ZH[ID_TO_EN[id]] = ID_TO_PROP_NAME[id]; } } EN_TO_ZH['HpAdd'] = '生命值百分比'; EN_TO_ZH['AttackAdd'] = '攻击力百分比'; EN_TO_ZH['DefenceAdd'] = '防御力百分比'; -EN_TO_ZH['BreakStunPercent'] = '冲击力'; // Map the new EN key back to ZH +EN_TO_ZH['BreakStunPercent'] = '冲击力'; const MAIN_PROP_BASE_INCREASE = { /* ... Keep values ... */ '11101': 330, '11103': 330, '11102': 47.4, '12101': 47.4, '12103': 47.4, '12102': 450, '13101': 27.6, '13103': 27.6, @@ -63,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' }; -// --- End Constants and Mappings --- +/ function formatEquipWeaponPropValue(value, prop_id) { const idStr = String(prop_id); const isPercentProp = PERCENT_ID_LIST.includes(idStr); @@ -74,23 +69,6 @@ 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'; } } -/** - * Formats a raw stat value for the final character panel ('final' format). -// */ -// function formatFinalPanelPropValue(value, prop_id) { -// const idStr = String(prop_id); -// const isPercentProp = PERCENT_ID_LIST.includes(idStr); -// const numericValue = Number(value); -// if (value === undefined || value === null || isNaN(numericValue)) { return isPercentProp ? '0.0%' : '0'; } -// try { -// if (isPercentProp) { return (numericValue / 100).toFixed(1) + '%'; } -// else if (idStr === '30503' || idStr === '30502') { return (numericValue / 100).toFixed(2); } // ER specific -// else { return String(Math.floor(numericValue)); } -// } catch (e) { logger.error(`Error formatting Final prop value ${value} for ${prop_id}:`, e); return '0'; } -// } - -// ****** INSERT MISSING FUNCTIONS HERE ****** - /** * Calculates final weapon base and random stat values (raw, 1/10000 unit). * @param {object} weapon_meta Metadata for the weapon. @@ -503,13 +481,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 the list of converted data + return result_list; }