2022-07-30 20:20:10 +00:00
|
|
|
import lodash from 'lodash'
|
|
|
|
import Character from '../models/Character.js'
|
2022-06-03 09:13:12 +00:00
|
|
|
|
|
|
|
const artifactMap = {
|
2022-07-30 20:20:10 +00:00
|
|
|
生命值: {
|
|
|
|
title: '小生命'
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
生命值_百分比: {
|
|
|
|
title: '大生命',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
暴击率: {
|
|
|
|
title: '暴击率',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
暴击伤害: {
|
|
|
|
title: '暴击伤害',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
防御力: {
|
|
|
|
title: '小防御'
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
防御力_百分比: {
|
|
|
|
title: '大防御',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
攻击力: {
|
|
|
|
title: '小攻击'
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
攻击力_百分比: {
|
|
|
|
title: '大攻击',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
元素精通: {
|
|
|
|
title: '元素精通'
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
元素充能效率: {
|
|
|
|
title: '充能效率',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
治疗加成: {
|
|
|
|
title: '治疗加成',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let posIdx = {
|
2022-07-30 20:20:10 +00:00
|
|
|
生之花: {
|
2022-06-03 09:13:12 +00:00
|
|
|
idx: 1
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
死之羽: {
|
2022-06-03 09:13:12 +00:00
|
|
|
idx: 2
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
时之沙: {
|
2022-06-03 09:13:12 +00:00
|
|
|
idx: 3
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
空之杯: {
|
2022-06-03 09:13:12 +00:00
|
|
|
idx: 4
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
理之冠: {
|
2022-06-03 09:13:12 +00:00
|
|
|
idx: 5
|
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
|
|
|
|
let Data = {
|
2022-07-30 20:20:10 +00:00
|
|
|
getData (uid, data) {
|
2022-06-03 09:13:12 +00:00
|
|
|
let ret = {
|
|
|
|
uid,
|
|
|
|
chars: {}
|
2022-07-30 20:20:10 +00:00
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
|
|
|
|
lodash.forEach({
|
2022-07-30 20:20:10 +00:00
|
|
|
name: '角色名称',
|
|
|
|
avatar: '头像ID',
|
2022-08-18 23:16:28 +00:00
|
|
|
level: '冒险等阶'
|
2022-06-03 09:13:12 +00:00
|
|
|
}, (title, key) => {
|
2022-07-30 20:20:10 +00:00
|
|
|
ret[key] = data[title] || ''
|
2022-06-03 09:13:12 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
lodash.forEach(data.items, (ds) => {
|
2022-07-30 20:20:10 +00:00
|
|
|
let char = Data.getAvatar(ds)
|
|
|
|
ret.chars[char.id] = char
|
|
|
|
})
|
2022-06-03 09:13:12 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
return ret
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
getAvatar (data) {
|
|
|
|
let char = Character.get(data['英雄Id'])
|
2022-06-03 09:13:12 +00:00
|
|
|
return {
|
2022-07-30 20:20:10 +00:00
|
|
|
id: data['英雄Id'],
|
|
|
|
name: char ? char.name : '',
|
2022-08-18 23:16:28 +00:00
|
|
|
level: data['等级'],
|
2022-06-03 09:13:12 +00:00
|
|
|
attr: Data.getAttr(data),
|
|
|
|
// weapon: Data.getWeapon(data),
|
2022-07-30 20:20:10 +00:00
|
|
|
artis: Data.getArtifact(data)
|
|
|
|
// cons: data["命之座数量"] * 1 || 0,
|
|
|
|
// talent: Data.getTalent(data)
|
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
getAttr (data) {
|
|
|
|
let ret = {}
|
2022-06-03 09:13:12 +00:00
|
|
|
let attrKey = {
|
2022-07-30 20:20:10 +00:00
|
|
|
atk: '攻击力_总',
|
|
|
|
atkBase: '属性攻击力',
|
|
|
|
def: '防御力_总',
|
|
|
|
defBase: '属性防御力',
|
|
|
|
hp: '生命值上限_总',
|
|
|
|
hpBase: '属性生命值上限',
|
|
|
|
mastery: '属性元素精通',
|
2022-06-03 09:13:12 +00:00
|
|
|
cRate: {
|
2022-07-30 20:20:10 +00:00
|
|
|
title: '属性暴击率',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
},
|
|
|
|
cDmg: {
|
2022-07-30 20:20:10 +00:00
|
|
|
title: '属性暴击伤害',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
},
|
|
|
|
hInc: {
|
2022-07-30 20:20:10 +00:00
|
|
|
title: '属性治疗加成',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
},
|
|
|
|
recharge: {
|
2022-07-30 20:20:10 +00:00
|
|
|
title: '属性元素充能效率',
|
2022-06-03 09:13:12 +00:00
|
|
|
pct: true
|
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
lodash.forEach(attrKey, (cfg, key) => {
|
2022-07-30 20:20:10 +00:00
|
|
|
if (typeof (cfg) === 'string') {
|
|
|
|
cfg = { title: cfg }
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
let val = data[cfg.title] || ''
|
2022-06-03 09:13:12 +00:00
|
|
|
if (cfg.pct) {
|
|
|
|
val = (val * 100).toFixed(2)
|
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
ret[key] = val
|
|
|
|
})
|
|
|
|
let maxDmg = 0
|
|
|
|
lodash.forEach('火水草雷风冰岩'.split(''), (key) => {
|
|
|
|
maxDmg = Math.max(data[`属性${key}元素伤害加成`] * 1, maxDmg)
|
|
|
|
})
|
|
|
|
ret.dmgBonus = (maxDmg * 100).toFixed(2)
|
|
|
|
ret.phyBonus = (data['属性物理伤害加成'] * 100).toFixed(2)
|
2022-06-03 09:13:12 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
return ret
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
getWeapon (data) {
|
2022-06-03 09:13:12 +00:00
|
|
|
return {
|
|
|
|
name: data['武器名称'],
|
2022-08-18 23:16:28 +00:00
|
|
|
level: data['武器等级'],
|
2022-07-30 20:20:10 +00:00
|
|
|
refine: data['武器精炼']
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
getArtifact (data) {
|
|
|
|
let ret = {}
|
2022-06-03 09:13:12 +00:00
|
|
|
let get = function (idx, key) {
|
2022-07-30 20:20:10 +00:00
|
|
|
let v = data[`圣遗物${idx}${key}`]
|
|
|
|
let ret = /^([^\d]*)([\d\.\-]*)$/.exec(v)
|
2022-06-03 09:13:12 +00:00
|
|
|
if (ret && ret[1]) {
|
2022-07-30 20:20:10 +00:00
|
|
|
let title = ret[1]; let val = ret[2]
|
2022-06-03 09:13:12 +00:00
|
|
|
if (artifactMap[title]) {
|
|
|
|
if (artifactMap[title].pct) {
|
2022-07-30 20:20:10 +00:00
|
|
|
val = (val * 100).toFixed(2)
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
title = artifactMap[title].title
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
return [title, val]
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
return []
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (let idx = 1; idx <= 5; idx++) {
|
|
|
|
ret[`arti${idx}`] = {
|
|
|
|
name: data[`圣遗物${idx}名称`],
|
|
|
|
type: data[`圣遗物${idx}类型`],
|
2022-07-30 20:20:10 +00:00
|
|
|
main: get(idx, '主词条'),
|
2022-06-03 09:13:12 +00:00
|
|
|
attrs: [
|
2022-07-30 20:20:10 +00:00
|
|
|
get(idx, '副词条1'),
|
|
|
|
get(idx, '副词条2'),
|
|
|
|
get(idx, '副词条3'),
|
|
|
|
get(idx, '副词条4')
|
2022-06-03 09:13:12 +00:00
|
|
|
]
|
2022-07-30 20:20:10 +00:00
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
return ret
|
2022-06-03 09:13:12 +00:00
|
|
|
},
|
2022-07-30 20:20:10 +00:00
|
|
|
getTalent (data) {
|
|
|
|
let ret = {}
|
2022-06-03 09:13:12 +00:00
|
|
|
lodash.forEach({
|
|
|
|
a: 1,
|
|
|
|
e: 2,
|
|
|
|
q: 3
|
|
|
|
}, (idx, key) => {
|
|
|
|
let val = data[`天赋主动名称${idx}`]
|
2022-07-30 20:20:10 +00:00
|
|
|
let regRet = /等级(\d*)$/.exec(val)
|
2022-06-03 09:13:12 +00:00
|
|
|
if (regRet && regRet[1]) {
|
|
|
|
ret[key] = regRet[1] * 1 || 1
|
|
|
|
} else {
|
2022-07-30 20:20:10 +00:00
|
|
|
ret[key] = 1
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
|
|
|
})
|
2022-07-30 20:20:10 +00:00
|
|
|
return ret
|
2022-06-03 09:13:12 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
}
|