2023-10-19 09:48:52 +00:00
|
|
|
import { Character } from '#miao.models'
|
2022-08-20 23:40:32 +00:00
|
|
|
import lodash from 'lodash'
|
2023-02-08 20:55:54 +00:00
|
|
|
|
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-05-20 13:51:44 +00:00
|
|
|
if (!char) {
|
|
|
|
return false
|
|
|
|
}
|
2023-05-19 18:50:39 +00:00
|
|
|
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')
|
2022-08-20 23:40:32 +00:00
|
|
|
}
|
2023-05-19 18:50:39 +00:00
|
|
|
return avatar
|
2022-08-20 23:40:32 +00:00
|
|
|
},
|
2023-02-09 16:57:25 +00:00
|
|
|
|
2023-05-19 18:50:39 +00:00
|
|
|
getTalent (char, data = {}) {
|
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-05-19 18:50:39 +00:00
|
|
|
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 {
|
2023-05-19 18:50:39 +00:00
|
|
|
trees.push(id)
|
2022-08-20 23:40:32 +00:00
|
|
|
}
|
|
|
|
})
|
2023-05-19 18:50:39 +00:00
|
|
|
return { talent, trees }
|
2022-08-20 23:40:32 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-18 10:13:42 +00:00
|
|
|
export default MiaoData
|