2023-05-14 20:19:33 +00:00
|
|
|
import lodash from 'lodash'
|
|
|
|
import { Data } from '#miao'
|
|
|
|
import { Character } from '#miao.models'
|
|
|
|
|
|
|
|
export default {
|
2023-05-19 18:50:39 +00:00
|
|
|
id: 'homo',
|
|
|
|
name: 'Mihomo',
|
|
|
|
cfgKey: 'homoApi',
|
2023-05-14 20:19:33 +00:00
|
|
|
// 处理请求参数
|
|
|
|
async request (api) {
|
|
|
|
let params = {
|
|
|
|
headers: { 'User-Agent': this.getCfg('userAgent') }
|
|
|
|
}
|
|
|
|
return { api, params }
|
|
|
|
},
|
|
|
|
|
|
|
|
// 处理服务返回
|
|
|
|
async response (data, req) {
|
2023-06-08 08:45:07 +00:00
|
|
|
if (!data.detailInfo) {
|
2023-05-14 20:19:33 +00:00
|
|
|
return req.err('error', 60)
|
|
|
|
}
|
2023-06-08 08:45:07 +00:00
|
|
|
let ds = data.detailInfo
|
2023-05-14 20:19:33 +00:00
|
|
|
let avatars = {}
|
2024-02-07 03:26:33 +00:00
|
|
|
lodash.forEach(ds.assistAvatarList, (ds) => {
|
|
|
|
avatars[ds.avatarId] = ds
|
|
|
|
})
|
2023-06-08 08:45:07 +00:00
|
|
|
lodash.forEach(ds.avatarDetailList, (ds) => {
|
|
|
|
avatars[ds.avatarId] = ds
|
2023-05-14 20:19:33 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
if (lodash.isEmpty(avatars)) {
|
|
|
|
return req.err('empty', 5 * 60)
|
|
|
|
}
|
2023-08-22 17:45:06 +00:00
|
|
|
ds.avatars = avatars
|
|
|
|
return ds
|
2023-05-14 20:19:33 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
updatePlayer (player, data) {
|
2023-05-16 05:04:43 +00:00
|
|
|
try {
|
2023-08-22 17:45:06 +00:00
|
|
|
player.setBasicData(Data.getData(data, 'name:nickname,face:headIcon,level:level,word:level,sign:signature'))
|
2023-05-16 05:04:43 +00:00
|
|
|
lodash.forEach(data.avatars, (ds, id) => {
|
2023-05-19 18:50:39 +00:00
|
|
|
let ret = HomoData.setAvatar(player, ds)
|
2023-05-16 05:04:43 +00:00
|
|
|
if (ret) {
|
2023-06-08 08:59:49 +00:00
|
|
|
player._update.push(ds.avatarId)
|
2023-05-16 05:04:43 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e)
|
|
|
|
}
|
2023-05-14 20:19:33 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// 获取冷却时间
|
|
|
|
cdTime (data) {
|
|
|
|
return data.ttl || 60
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-19 18:50:39 +00:00
|
|
|
const HomoData = {
|
2023-05-14 20:19:33 +00:00
|
|
|
setAvatar (player, data) {
|
2023-06-08 08:45:07 +00:00
|
|
|
let char = Character.get(data.avatarId)
|
2023-05-14 20:19:33 +00:00
|
|
|
if (!char) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
let avatar = player.getAvatar(char.id, true)
|
|
|
|
let setData = {
|
2023-06-10 02:15:14 +00:00
|
|
|
level: data.level,
|
2023-06-08 08:45:07 +00:00
|
|
|
promote: data.promotion,
|
|
|
|
cons: data.rank || 0,
|
|
|
|
weapon: Data.getData(data.equipment, 'id:tid,promote:promotion,level,affix:rank'),
|
|
|
|
...HomoData.getTalent(data.skillTreeList, char),
|
|
|
|
artis: HomoData.getArtis(data.relicList)
|
2023-05-14 20:19:33 +00:00
|
|
|
}
|
2023-05-19 18:50:39 +00:00
|
|
|
avatar.setAvatar(setData, 'homo')
|
2023-05-14 20:19:33 +00:00
|
|
|
return avatar
|
|
|
|
},
|
2023-05-16 05:04:43 +00:00
|
|
|
getTalent (ds, char) {
|
2023-05-14 20:19:33 +00:00
|
|
|
let talent = {}
|
2023-05-16 05:04:43 +00:00
|
|
|
let trees = []
|
2023-05-14 20:19:33 +00:00
|
|
|
lodash.forEach(ds, (d) => {
|
2023-06-08 08:45:07 +00:00
|
|
|
let key = char.getTalentKey(d.pointId)
|
2023-05-14 20:19:33 +00:00
|
|
|
if (key || d.Level > 1) {
|
2023-06-08 08:45:07 +00:00
|
|
|
talent[key || d.pointId] = d.level
|
2023-05-14 20:19:33 +00:00
|
|
|
} else {
|
2023-06-08 08:45:07 +00:00
|
|
|
trees.push(d.pointId)
|
2023-05-14 20:19:33 +00:00
|
|
|
}
|
|
|
|
})
|
2023-05-16 05:04:43 +00:00
|
|
|
return { talent, trees }
|
2023-05-14 20:19:33 +00:00
|
|
|
},
|
|
|
|
getArtis (artis) {
|
|
|
|
let ret = {}
|
|
|
|
lodash.forEach(artis, (ds) => {
|
2023-05-16 05:04:43 +00:00
|
|
|
let tmp = {
|
2023-06-08 08:45:07 +00:00
|
|
|
id: ds.tid,
|
|
|
|
level: ds.level || 1,
|
|
|
|
mainId: ds.mainAffixId,
|
2023-05-26 21:37:06 +00:00
|
|
|
attrIds: []
|
2023-05-16 05:04:43 +00:00
|
|
|
}
|
2023-06-08 08:45:07 +00:00
|
|
|
lodash.forEach(ds.subAffixList, (s) => {
|
|
|
|
if (!s.affixId) {
|
2023-05-16 05:04:43 +00:00
|
|
|
return true
|
|
|
|
}
|
2023-06-08 08:45:07 +00:00
|
|
|
tmp.attrIds.push([s.affixId, s.cnt, s.step || 0].join(','))
|
2023-05-14 20:19:33 +00:00
|
|
|
})
|
2023-06-10 01:25:44 +00:00
|
|
|
ret[ds.type] = tmp
|
2023-05-14 20:19:33 +00:00
|
|
|
})
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
}
|