2023-02-12 21:18:06 +00:00
|
|
|
import { Character } from '../index.js'
|
2022-08-20 23:40:32 +00:00
|
|
|
import lodash from 'lodash'
|
2023-02-08 20:55:54 +00:00
|
|
|
|
2023-02-09 16:57:25 +00:00
|
|
|
import { attrMap, artisIdxMap } from './ProfileMeta.js'
|
2022-08-20 23:40:32 +00:00
|
|
|
|
|
|
|
let MiaoData = {
|
2023-02-08 20:55:54 +00:00
|
|
|
setAvatar (player, ds) {
|
2022-08-20 23:40:32 +00:00
|
|
|
let char = Character.get(ds.id)
|
2023-02-12 21:18:06 +00:00
|
|
|
let avatar = player.getAvatar(ds.id, true)
|
2023-02-08 20:55:54 +00:00
|
|
|
let talentRet = MiaoData.getTalent(char.id, ds.skill)
|
|
|
|
avatar.setAvatar({
|
2022-08-20 23:40:32 +00:00
|
|
|
level: ds.level,
|
|
|
|
cons: ds.constellationNum || 0,
|
2023-02-13 08:31:23 +00:00
|
|
|
promote: ds.promoteLevel,
|
2022-08-20 23:40:32 +00:00
|
|
|
fetter: ds.fetterLevel,
|
2022-08-31 18:26:36 +00:00
|
|
|
costume: char.checkCostume(ds.costumeID) ? ds.costumeID : 0,
|
2023-02-08 20:55:54 +00:00
|
|
|
elem: talentRet.elem,
|
|
|
|
weapon: MiaoData.getWeapon(ds.weapon),
|
|
|
|
talent: talentRet.talent,
|
|
|
|
artis: MiaoData.getArtifact(ds.reliquary)
|
|
|
|
}, 'miao')
|
|
|
|
return avatar
|
2022-08-20 23:40:32 +00:00
|
|
|
},
|
2023-02-09 16:57:25 +00:00
|
|
|
|
2023-02-19 17:08:05 +00:00
|
|
|
setAvatarNew (player, ds) {
|
|
|
|
let char = Character.get(ds.id)
|
|
|
|
let avatar = player.getAvatar(ds.id, true)
|
|
|
|
let talentRet = MiaoData.getTalentNew(char.id, ds.talent)
|
|
|
|
avatar.setAvatar({
|
|
|
|
...ds,
|
2023-02-19 21:24:17 +00:00
|
|
|
elem: talentRet.elem,
|
|
|
|
talent: talentRet.talent
|
2023-02-19 17:08:05 +00:00
|
|
|
}, 'miao')
|
|
|
|
return avatar
|
|
|
|
},
|
|
|
|
|
2022-08-20 23:40:32 +00:00
|
|
|
getWeapon (weapon) {
|
|
|
|
return {
|
|
|
|
name: weapon.name,
|
|
|
|
level: weapon.level,
|
|
|
|
promote: weapon.promoteLevel,
|
|
|
|
affix: (weapon.affixLevel || 0) + 1
|
|
|
|
}
|
|
|
|
},
|
2023-02-09 16:57:25 +00:00
|
|
|
|
2023-02-19 17:08:05 +00:00
|
|
|
getTalentNew (charid, data = {}) {
|
|
|
|
let char = Character.get(charid)
|
2023-02-21 17:26:17 +00:00
|
|
|
let { talentId = {}, talentElem = {} } = char.meta
|
2023-02-19 17:08:05 +00:00
|
|
|
let elem = ''
|
|
|
|
let idx = 0
|
|
|
|
let ret = {}
|
|
|
|
lodash.forEach(data, (level, id) => {
|
|
|
|
let key
|
|
|
|
if (talentId[id]) {
|
2023-02-21 17:26:17 +00:00
|
|
|
key = talentId[id]
|
|
|
|
elem = elem || talentElem[id]
|
2023-02-19 17:08:05 +00:00
|
|
|
ret[key] = level
|
|
|
|
} else {
|
|
|
|
key = ['a', 'e', 'q'][idx]
|
|
|
|
ret[key] = level
|
|
|
|
}
|
|
|
|
idx++
|
|
|
|
})
|
|
|
|
return {
|
|
|
|
talent: ret,
|
|
|
|
elem
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-02-09 16:57:25 +00:00
|
|
|
getTalent (charid, data = {}) {
|
|
|
|
let char = Character.get(charid)
|
2023-02-21 17:26:17 +00:00
|
|
|
let { talentId = {}, talentElem = {} } = char.meta
|
2023-02-09 16:57:25 +00:00
|
|
|
let elem = ''
|
|
|
|
let idx = 0
|
|
|
|
let ret = {}
|
|
|
|
lodash.forEach(data, (ds) => {
|
|
|
|
let key
|
|
|
|
if (talentId[ds.id]) {
|
2023-02-21 17:26:17 +00:00
|
|
|
key = talentId[ds.id]
|
|
|
|
elem = elem || talentElem[ds.id]
|
2023-02-09 16:57:25 +00:00
|
|
|
ret[key] = {
|
|
|
|
level: ds.level
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
key = ['a', 'e', 'q'][idx++]
|
|
|
|
ret[key] = ret[key] || {
|
|
|
|
level: ds.level
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return {
|
|
|
|
talent: ret,
|
|
|
|
elem
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-08-20 23:40:32 +00:00
|
|
|
getArtifact (data) {
|
|
|
|
let ret = {}
|
|
|
|
let get = function (d) {
|
|
|
|
if (!d) {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
let name = d.name
|
|
|
|
name = name.replace('FIGHT_PROP_', '')
|
|
|
|
if (!attrMap[name]) {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
let value = d.value
|
|
|
|
if (value && value < 1) {
|
|
|
|
value = value * 100
|
|
|
|
}
|
2023-02-08 20:55:54 +00:00
|
|
|
return { key: attrMap[name], value }
|
2022-08-20 23:40:32 +00:00
|
|
|
}
|
|
|
|
lodash.forEach(data, (ds) => {
|
|
|
|
let sub = ds.appendAffix || []
|
2023-02-09 16:57:25 +00:00
|
|
|
let idx = artisIdxMap[ds.type]
|
2022-08-20 23:40:32 +00:00
|
|
|
if (!idx) {
|
|
|
|
return
|
|
|
|
}
|
2023-02-08 20:55:54 +00:00
|
|
|
ret[idx] = {
|
2022-08-20 23:40:32 +00:00
|
|
|
name: ds.name,
|
|
|
|
level: ds.level,
|
2023-02-11 19:51:50 +00:00
|
|
|
star: ds.rank,
|
2022-08-20 23:40:32 +00:00
|
|
|
main: get(ds.mainAffix),
|
|
|
|
attrs: [
|
|
|
|
get(sub[0]),
|
|
|
|
get(sub[1]),
|
|
|
|
get(sub[2]),
|
|
|
|
get(sub[3])
|
|
|
|
]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
}
|
2022-08-18 10:13:42 +00:00
|
|
|
export default MiaoData
|