#深渊组队使用新版胡桃API进行组队信息获取

This commit is contained in:
yoimiya-kokomi 2022-10-23 03:45:28 +08:00
parent 9dbaad5e6a
commit 92419e1d73
9 changed files with 85 additions and 28 deletions

View File

@ -2,6 +2,7 @@
* 增加妮露的伤害计算及圣遗物权重设置
* `#面板`会展示角色名命座信息
* `#深渊组队`使用新版胡桃API进行组队信息获取
* 一些已知问题修复及优化
# 2.0.1~2.0.3

View File

@ -262,7 +262,7 @@ async function abyssTeam (e) {
}
lodash.forEach(abyssData, (ds) => {
let floor = ds.level.floor
let floor = ds.floor
if (!data[floor]) {
data[floor] = {
up: {},
@ -270,9 +270,9 @@ async function abyssTeam (e) {
teams: []
}
}
lodash.forEach(ds.teams, (ds) => {
lodash.forEach(['up', 'down'], (halfKey) => {
let teamCfg = getTeamCfg(ds.id[`${halfKey}Half`])
lodash.forEach(['up', 'down'], (halfKey) => {
lodash.forEach(ds[halfKey], (ds) => {
let teamCfg = getTeamCfg(ds.item)
if (teamCfg) {
if (!data[floor][halfKey][teamCfg.key]) {
data[floor][halfKey][teamCfg.key] = {
@ -281,8 +281,8 @@ async function abyssTeam (e) {
hasTeam: teamCfg.mark > 1
}
}
data[floor][halfKey][teamCfg.key].count += ds.value
data[floor][halfKey][teamCfg.key].mark += ds.value * teamCfg.mark
data[floor][halfKey][teamCfg.key].count += ds.rate
data[floor][halfKey][teamCfg.key].mark += ds.rate * teamCfg.mark
}
})
})

View File

@ -46,13 +46,17 @@ let HutaoApi = {
},
async getAbyssTeam () {
return await HutaoApi.req('/Statistics/TeamCombination')
return await HutaoApi.req('/Statistics/Team/Combination')
},
async getOverview () {
return await HutaoApi.req('/Statistics/Overview')
},
async getUsage () {
return await HutaoApi.req('/Statistics/Avatar/AvatarCollocation')
},
async getWeaponUsage () {
return await HutaoApi.req('/Statistics/AvatarWeaponUsage')
},
@ -61,22 +65,12 @@ let HutaoApi = {
return await HutaoApi.req('/Statistics/AvatarReliquaryUsage')
},
async upload (data) {
let body = JSON.stringify(data)
return await HutaoApi.req('/Record/Upload', {
method: 'POST',
headers: {
'Content-Type': 'text/json; charset=utf-8'
},
body
})
},
async uploadData (data = {}) {
let body = JSON.stringify(data)
return await HutaoApi.req('/Record/UploadData', {
method: 'POST',
headers: {
'User-Agent': 'Yunzai-Bot/Miao-Plugin',
'Content-Type': 'text/json; charset=utf-8'
},
body

View File

@ -107,18 +107,18 @@ async function renderWiki ({ e, char }) {
lodash.extend(data, char.getData('weaponType,elemName'))
// 命座持有
let holding = await CharWiki.getHolding(char.id)
let weapons = await CharWiki.getWeapons(char.id)
let artis = await CharWiki.getArtis(char.id)
// let usage = await CharWiki.getUsage(char.id)
let usage = {
weapons: await CharWiki.getWeapons(char.id),
artis: await CharWiki.getArtis(char.id)
}
return await Common.render('wiki/character-wiki', {
// saveId: `info-${char.id}`,
data,
attr: char.getAttrList(),
detail: char.getDetail(),
imgs: char.getImgs(),
weapons,
holding,
artis,
usage,
materials: char.getMaterials(),
elem: char.elem
}, { e, scale: 1.4 })

View File

@ -66,6 +66,65 @@ let CharWiki = {
})
})
}
artis = lodash.sortBy(artis, 'value')
artis = artis.reverse()
artis.forEach((ds) => {
ds.value = Format.percent(ds.value)
})
return artis
},
async getUsage (id) {
let ud = (await HutaoApi.getUsage()).data || {}
if (!ud[id]) {
return {}
}
ud = ud[id]
return {
weapons: CharWiki.getWeaponsData(ud.weapons),
artis: CharWiki.getArtisData(ud.artis)
}
},
getWeaponsData (data = []) {
let weapons = []
lodash.forEach(data, (ds) => {
let weapon = Weapon.get(ds.item) || {}
weapons.push({
...weapon.getData('name,abbr,img,star'),
value: ds.rate
})
})
weapons = lodash.sortBy(weapons, 'value')
weapons = weapons.reverse()
lodash.forEach(weapons, (ds) => {
ds.value = Format.percent(ds.value, 1)
})
return weapons
},
getArtisData (data = []) {
let artis = []
lodash.forEach(data, (ds) => {
let imgs = []
let abbrs = []
let ss = ds.item.split(',')
lodash.forEach(ss, (t) => {
t = t.split(':')
let artiSet = ArtifactSet.get(t[0])
if (artiSet) {
imgs.push(artiSet.img)
abbrs.push(artiSet.abbr + (ss.length === 1 ? t[1] : ''))
}
})
artis.push({
imgs,
title: abbrs.join('+'),
value: ds.rate
})
})
artis = lodash.sortBy(artis, 'value')
artis = artis.reverse()
artis.forEach((ds) => {

View File

@ -125,6 +125,7 @@ export default class Avatar extends Base {
let id = char.id
let talent = {}
let talentRes = await mys.getDetail(id)
// { data: null, message: '请先登录', retcode: -100, api: 'detail' }
let avatar = this.meta
if (!char || !avatar) {
return false

View File

@ -17,7 +17,7 @@ body,
padding: 10px;
}
.char-item {
margin: 5px;
margin: 5px 0;
}
.char-item .name {
margin-top: 5px;
@ -51,6 +51,7 @@ body,
border: 2px solid #fff;
box-shadow: 1px 1px 3px 0 #000;
overflow: visible;
margin: 0 5px 0 6px;
}
.char-icon .img {
background-size: auto 100%;

View File

@ -21,7 +21,7 @@ body, .container {
}
.char-item {
margin: 5px;
margin: 5px 0;
.name {
margin-top: 5px;
@ -61,6 +61,7 @@ body, .container {
border: 2px solid #fff;
box-shadow: 1px 1px 3px 0 #000;
overflow: visible;
margin: 0 5px 0 6px;
.img {
background-size: auto 100%;

View File

@ -83,7 +83,7 @@
{{/if}}
<div class="talent-notice">输入<strong>#{{data.abbr}}天赋、#{{data.abbr}}命座</strong>可查看详细天赋/命座信息</div>
{{set weapons = usage.weapons || [] }}
{{if weapons.length >0}}
<div class="cont">
<div class="cont-title border-less">常用武器</div>
@ -100,7 +100,7 @@
</div>
</div>
{{/if}}
{{set artis = usage.artis || [] }}
{{if artis.length >0}}
<div class="cont">
<div class="cont-title border-less">常用圣遗物<span>持有率、武器、圣遗物统计来自胡桃API未经允许请勿使用此数据</span></div>