2022-07-27 18:36:49 +00:00
|
|
|
import lodash from 'lodash'
|
|
|
|
import Character from '../models/Character.js'
|
|
|
|
import meta from './enka-meta.js'
|
|
|
|
import cmeta from './enka-char.js'
|
|
|
|
import _Data from '../Data.js'
|
|
|
|
import moment from 'moment'
|
2022-06-04 21:29:24 +00:00
|
|
|
|
2022-07-27 18:36:49 +00:00
|
|
|
moment.locale('zh-cn')
|
|
|
|
let _path = process.cwd()
|
|
|
|
let relis = _Data.readJSON(`${_path}/plugins/miao-plugin/resources/meta/reliquaries/`, 'data.json') || {}
|
2022-06-03 09:13:12 +00:00
|
|
|
|
|
|
|
let relisMap = {}
|
|
|
|
|
|
|
|
lodash.forEach(relis, (ds) => {
|
2022-07-27 18:36:49 +00:00
|
|
|
relisMap[ds.name] = ds
|
2022-06-03 09:13:12 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const artiIdx = {
|
|
|
|
EQUIP_BRACER: 1,
|
|
|
|
EQUIP_NECKLACE: 2,
|
|
|
|
EQUIP_SHOES: 3,
|
|
|
|
EQUIP_RING: 4,
|
|
|
|
EQUIP_DRESS: 5
|
2022-07-27 18:36:49 +00:00
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
|
|
|
|
const attrMap = {
|
2022-07-27 18:36:49 +00:00
|
|
|
HP: '小生命',
|
|
|
|
HP_PERCENT: '大生命',
|
|
|
|
ATTACK: '小攻击',
|
|
|
|
ATTACK_PERCENT: '大攻击',
|
|
|
|
DEFENSE: '小防御',
|
|
|
|
DEFENSE_PERCENT: '大防御',
|
|
|
|
FIRE_ADD_HURT: '火元素伤害加成',
|
|
|
|
ICE_ADD_HURT: '冰元素伤害加成',
|
|
|
|
ROCK_ADD_HURT: '岩元素伤害加成',
|
|
|
|
ELEC_ADD_HURT: '雷元素伤害加成',
|
|
|
|
WIND_ADD_HURT: '风元素伤害加成',
|
|
|
|
WATER_ADD_HURT: '水元素伤害加成',
|
|
|
|
PHYSICAL_ADD_HURT: '物理伤害加成',
|
|
|
|
HEAL_ADD: '治疗加成',
|
|
|
|
ELEMENT_MASTERY: '元素精通',
|
|
|
|
CRITICAL: '暴击率',
|
|
|
|
CRITICAL_HURT: '暴击伤害',
|
|
|
|
CHARGE_EFFICIENCY: '充能效率'
|
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
|
|
|
|
let Data = {
|
2022-07-27 18:36:49 +00:00
|
|
|
getData (uid, data) {
|
2022-06-03 09:13:12 +00:00
|
|
|
let ret = {
|
|
|
|
uid,
|
|
|
|
chars: {}
|
|
|
|
}
|
|
|
|
|
|
|
|
lodash.forEach({
|
2022-07-27 18:36:49 +00:00
|
|
|
name: 'nickname',
|
|
|
|
avatar: 'profilePicture.avatarId',
|
|
|
|
lv: 'level'
|
2022-06-03 09:13:12 +00:00
|
|
|
}, (src, key) => {
|
2022-07-27 18:36:49 +00:00
|
|
|
ret[key] = lodash.get(data.playerInfo, src, '')
|
2022-06-03 09:13:12 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
lodash.forEach(data.avatarInfoList, (ds) => {
|
2022-07-27 18:36:49 +00:00
|
|
|
let char = Data.getAvatar(ds)
|
|
|
|
ret.chars[char.id] = char
|
2022-06-03 09:13:12 +00:00
|
|
|
})
|
|
|
|
|
2022-07-27 18:36:49 +00:00
|
|
|
return ret
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-27 18:36:49 +00:00
|
|
|
getAvatar (data) {
|
|
|
|
let char = Character.get(data.avatarId)
|
|
|
|
let now = moment()
|
2022-06-03 09:13:12 +00:00
|
|
|
let ret = {
|
2022-07-27 18:36:49 +00:00
|
|
|
id: data.avatarId,
|
|
|
|
name: char ? char.name : '',
|
|
|
|
dataSource: 'enka',
|
|
|
|
updateTime: now.format('YYYY-MM-DD HH:mm:ss'),
|
2022-06-03 09:13:12 +00:00
|
|
|
lv: data.propMap['4001'].val * 1,
|
|
|
|
fetter: data.fetterInfo.expLevel,
|
|
|
|
attr: Data.getAttr(data.fightPropMap),
|
|
|
|
weapon: Data.getWeapon(data.equipList),
|
|
|
|
artis: Data.getArtifact(data.equipList),
|
|
|
|
cons: data.talentIdList ? data.talentIdList.length : 0,
|
|
|
|
talent: Data.getTalent(char.id, data.skillLevelMap, data.proudSkillExtraLevelMap || {})
|
2022-07-27 18:36:49 +00:00
|
|
|
}
|
|
|
|
return Data.dataFix(ret)
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-27 18:36:49 +00:00
|
|
|
getAttr (data) {
|
|
|
|
let ret = {}
|
2022-06-03 09:13:12 +00:00
|
|
|
let attrKey = {
|
|
|
|
// atk: 2001,
|
|
|
|
atkBase: 4,
|
|
|
|
def: 2002,
|
|
|
|
defBase: 7,
|
|
|
|
hp: 2000,
|
|
|
|
hpBase: 1,
|
|
|
|
mastery: 28,
|
|
|
|
cRate: {
|
|
|
|
src: 20,
|
|
|
|
pct: true
|
|
|
|
},
|
|
|
|
cDmg: {
|
|
|
|
src: 22,
|
|
|
|
pct: true
|
|
|
|
},
|
|
|
|
hInc: {
|
|
|
|
src: 26,
|
|
|
|
pct: true
|
|
|
|
},
|
|
|
|
recharge: {
|
|
|
|
src: 23,
|
|
|
|
pct: true
|
|
|
|
}
|
2022-07-27 18:36:49 +00:00
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
lodash.forEach(attrKey, (cfg, key) => {
|
|
|
|
if (!lodash.isObject(cfg)) {
|
2022-07-27 18:36:49 +00:00
|
|
|
cfg = { src: cfg }
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-27 18:36:49 +00:00
|
|
|
let val = data[cfg.src] || 0
|
2022-06-03 09:13:12 +00:00
|
|
|
if (cfg.pct) {
|
|
|
|
val = val * 100
|
|
|
|
}
|
2022-07-27 18:36:49 +00:00
|
|
|
ret[key] = val
|
|
|
|
})
|
|
|
|
ret.atk = data['4'] * (1 + (data['6'] || 0)) + (data['5'] || 0)
|
|
|
|
let maxDmg = 0
|
2022-06-03 09:13:12 +00:00
|
|
|
// 火40 水42 风44 岩45 冰46 雷46
|
|
|
|
// 41 雷
|
2022-07-27 18:36:49 +00:00
|
|
|
lodash.forEach('40,41,42,43,44,45,45,46'.split(','), (key) => {
|
|
|
|
maxDmg = Math.max(data[key] * 1, maxDmg)
|
|
|
|
})
|
2022-06-03 09:13:12 +00:00
|
|
|
// phy 30
|
2022-07-27 18:36:49 +00:00
|
|
|
ret.dmgBonus = maxDmg * 100
|
|
|
|
ret.phyBonus = data['30'] * 100
|
2022-06-03 09:13:12 +00:00
|
|
|
|
2022-07-27 18:36:49 +00:00
|
|
|
return ret
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
|
|
|
|
2022-07-27 18:36:49 +00:00
|
|
|
getArtifact (data) {
|
|
|
|
let ret = {}
|
2022-06-03 09:13:12 +00:00
|
|
|
|
|
|
|
let get = function (d) {
|
|
|
|
if (!d) {
|
2022-07-27 18:36:49 +00:00
|
|
|
return []
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-27 18:36:49 +00:00
|
|
|
let id = d.appendPropId || d.mainPropId || ''
|
|
|
|
id = id.replace('FIGHT_PROP_', '')
|
2022-06-03 09:13:12 +00:00
|
|
|
if (!attrMap[id]) {
|
2022-07-27 18:36:49 +00:00
|
|
|
return []
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-27 18:36:49 +00:00
|
|
|
return [attrMap[id], d.statValue]
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
|
|
|
lodash.forEach(data, (ds) => {
|
2022-07-27 18:36:49 +00:00
|
|
|
let flat = ds.flat || {}; let sub = flat.reliquarySubstats || []
|
|
|
|
let idx = artiIdx[flat.equipType]
|
2022-06-03 09:13:12 +00:00
|
|
|
if (!idx) {
|
2022-07-27 18:36:49 +00:00
|
|
|
return
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
|
|
|
|
2022-07-27 18:36:49 +00:00
|
|
|
let setName = meta[flat.setNameTextMapHash] || ''
|
|
|
|
let setCfg = relisMap[setName] || { name: '', sets: {} }
|
|
|
|
let artiCfg = setCfg.sets[`arti${idx}`] || { name: '' }
|
2022-06-03 09:13:12 +00:00
|
|
|
|
|
|
|
ret[`arti${idx}`] = {
|
|
|
|
name: artiCfg.name,
|
|
|
|
set: setCfg.name,
|
|
|
|
level: Math.min(20, ((ds.reliquary && ds.reliquary.level) || 1) - 1),
|
|
|
|
main: get(flat.reliquaryMainstat),
|
|
|
|
attrs: [
|
|
|
|
get(sub[0]),
|
|
|
|
get(sub[1]),
|
|
|
|
get(sub[2]),
|
|
|
|
get(sub[3])
|
|
|
|
]
|
|
|
|
}
|
|
|
|
})
|
2022-07-27 18:36:49 +00:00
|
|
|
return ret
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-27 18:36:49 +00:00
|
|
|
getWeapon (data) {
|
2022-06-03 09:13:12 +00:00
|
|
|
let ds = {}
|
|
|
|
lodash.forEach(data, (temp) => {
|
2022-07-27 18:36:49 +00:00
|
|
|
if (temp.flat && temp.flat.itemType === 'ITEM_WEAPON') {
|
|
|
|
ds = temp
|
|
|
|
return false
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
|
|
|
})
|
2022-07-27 18:36:49 +00:00
|
|
|
let { weapon, flat } = ds
|
2022-06-03 09:13:12 +00:00
|
|
|
return {
|
|
|
|
name: meta[flat.nameTextMapHash],
|
|
|
|
star: flat.rankLevel,
|
2022-06-04 21:29:24 +00:00
|
|
|
level: weapon.level,
|
2022-06-03 09:13:12 +00:00
|
|
|
promote: weapon.promoteLevel,
|
2022-06-03 09:20:23 +00:00
|
|
|
affix: (lodash.values(weapon.affixMap)[0] || 0) + 1
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
|
|
|
},
|
2022-07-27 18:36:49 +00:00
|
|
|
getTalent (charid, ds = {}, ext = {}) {
|
|
|
|
let cm = cmeta[charid] || {}
|
|
|
|
let cn = cm.Skills || {}; let ce = cm.ProudMap
|
|
|
|
let idx = 1
|
|
|
|
let idxMap = { 1: 'a', 2: 'e', 3: 'q', a: 'a', s: 'e', e: 'q' }
|
2022-06-03 09:13:12 +00:00
|
|
|
lodash.forEach(cn, (n, id) => {
|
2022-07-27 18:36:49 +00:00
|
|
|
let nRet = /skill_(\w)/.exec(n.toLowerCase())
|
|
|
|
idxMap[id] = nRet && nRet[1] ? idxMap[nRet[1]] : idxMap[idx]
|
|
|
|
idx++
|
|
|
|
})
|
2022-06-03 09:13:12 +00:00
|
|
|
lodash.forEach(ce, (n, id) => {
|
2022-07-27 18:36:49 +00:00
|
|
|
idxMap[n] = idxMap[id]
|
2022-06-03 09:13:12 +00:00
|
|
|
})
|
2022-07-27 18:36:49 +00:00
|
|
|
let ret = {}
|
2022-06-03 09:13:12 +00:00
|
|
|
lodash.forEach(ds, (lv, id) => {
|
2022-07-27 18:36:49 +00:00
|
|
|
let key = idxMap[id]
|
2022-06-03 09:13:12 +00:00
|
|
|
ret[key] = {
|
|
|
|
level_original: lv,
|
|
|
|
level_current: lv
|
|
|
|
}
|
|
|
|
})
|
|
|
|
lodash.forEach(ext, (lv, id) => {
|
2022-07-27 18:36:49 +00:00
|
|
|
let key = idxMap[id]
|
2022-06-03 09:13:12 +00:00
|
|
|
if (ret[key]) {
|
2022-07-27 18:36:49 +00:00
|
|
|
ret[key].level_current = ret[key].level_current + lv
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-07-27 18:36:49 +00:00
|
|
|
return ret
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-27 18:36:49 +00:00
|
|
|
dataFix (ret) {
|
2022-06-04 21:29:24 +00:00
|
|
|
if (ret._fix) {
|
2022-07-27 18:36:49 +00:00
|
|
|
return ret
|
2022-06-04 21:29:24 +00:00
|
|
|
}
|
2022-08-03 18:32:10 +00:00
|
|
|
let { attr, talent, id } = ret
|
2022-07-27 18:36:49 +00:00
|
|
|
id = id * 1
|
2022-06-03 09:13:12 +00:00
|
|
|
switch (id) {
|
|
|
|
case 10000052:
|
|
|
|
// 雷神被动加成fix
|
2022-06-05 07:53:13 +00:00
|
|
|
attr.dmgBonus = Math.max(0, attr.dmgBonus - (attr.recharge - 100) * 0.4)
|
2022-07-27 18:36:49 +00:00
|
|
|
break
|
2022-06-03 09:13:12 +00:00
|
|
|
case 10000041:
|
|
|
|
// 莫娜被动fix
|
2022-06-05 07:53:13 +00:00
|
|
|
attr.dmgBonus = Math.max(0, attr.dmgBonus - attr.recharge * 0.2)
|
2022-07-27 18:36:49 +00:00
|
|
|
break
|
2022-08-03 18:32:10 +00:00
|
|
|
}
|
|
|
|
if (id !== 10000033) {
|
|
|
|
let a = talent.a || {}
|
|
|
|
if (a.level_current > 10) {
|
|
|
|
a.level_current = 10
|
|
|
|
a.level_original = 10
|
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-27 18:36:49 +00:00
|
|
|
ret._fix = true
|
|
|
|
return ret
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-27 18:36:49 +00:00
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
|
2022-07-27 18:36:49 +00:00
|
|
|
export default Data
|