miao-plugin/models/player/MiaoData.js

67 lines
1.4 KiB
JavaScript
Raw Normal View History

import { Character } from '../index.js'
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'
let MiaoData = {
2023-02-08 20:55:54 +00:00
setAvatar (player, ds) {
let char = Character.get(ds.id)
let avatar = player.getAvatar(ds.id, true)
if (!char) {
return false
}
if (player.isSr) {
avatar.setAvatar({
...ds,
...MiaoData.getTalentSR(char, ds.talent)
}, 'miao')
} else {
let talentRet = MiaoData.getTalent(char, ds.talent)
avatar.setAvatar({
...ds,
elem: talentRet.elem,
talent: talentRet.talent
}, 'miao')
}
return avatar
},
2023-02-09 16:57:25 +00:00
getTalent (char, data = {}) {
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]) {
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
}
},
getTalentSR (char, data) {
let talent = {}
let trees = []
lodash.forEach(data, (lv, id) => {
let key = char.getTalentKey(id)
if (key || lv > 1) {
talent[key || id] = lv
2023-02-09 16:57:25 +00:00
} else {
trees.push(id)
}
})
return { talent, trees }
}
}
2022-08-18 10:13:42 +00:00
export default MiaoData