mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
#上传深渊数据
命令会返回最强一击及承受伤害的排名
This commit is contained in:
parent
fc318ce954
commit
3c6e7f264a
@ -1,3 +1,9 @@
|
||||
# 1.8.6
|
||||
|
||||
* `#上传深渊数据`命令会返回最强一击及承受伤害的排名
|
||||
* 需要有当期深渊挑战记录才会展示排名信息
|
||||
* 当前为文字展示,后期会改为图像模式
|
||||
|
||||
# 1.8.5
|
||||
|
||||
* 支持戳一戳返回喵喵版角色卡片
|
||||
|
@ -143,33 +143,6 @@ async function getTalent(e, avatars) {
|
||||
}
|
||||
|
||||
|
||||
let _pokeCharacter = false;
|
||||
|
||||
async function initPoke() {
|
||||
if (!_pokeCharacter) {
|
||||
_pokeCharacter = YunzaiApps.mysInfo.pokeCharacter;
|
||||
}
|
||||
YunzaiApps.mysInfo.pokeCharacter = async function (e, components) {
|
||||
if (Cfg.isDisable('char.poke', true)) {
|
||||
return await _pokeCharacter(e, components);
|
||||
}
|
||||
return await pokeCharacter(e, components);
|
||||
}
|
||||
}
|
||||
|
||||
async function pokeCharacter(e, { render }) {
|
||||
let MysApi = await e.getMysApi({
|
||||
auth: "all",
|
||||
targetType: Cfg.get("char.queryOther", true) ? "all" : "self",
|
||||
cookieType: "all",
|
||||
actionName: "查询信息"
|
||||
});
|
||||
let avatarList = await getAvatarList(e, false, MysApi);
|
||||
let avatar = lodash.sample(avatarList);
|
||||
return renderAvatar(e, avatar, render, 'card');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取角色数据
|
||||
* */
|
||||
|
69
apps/stat.js
69
apps/stat.js
@ -397,56 +397,41 @@ export async function uploadData(e) {
|
||||
try {
|
||||
let resDetail = await MysApi.getCharacter();
|
||||
let resAbyss = await MysApi.getSpiralAbyss(1);
|
||||
//Data.writeJson('/test-data', 'abyss.json', resAbyss);
|
||||
if (!resDetail || !resAbyss || !resDetail.avatars || resDetail.avatars.length <= 3) {
|
||||
e.reply("角色信息获取失败");
|
||||
return true;
|
||||
}
|
||||
let playerAvatars = [];
|
||||
lodash.forEach(resDetail.avatars || [], (avatar) => {
|
||||
let tmp = Data.getData(avatar, "id,level,activedConstellationNum:actived_constellation_num")
|
||||
tmp.weapon = Data.getData(avatar.weapon, "id,level,affixLevel:affix_level");
|
||||
let setMap = {};
|
||||
lodash.forEach(avatar.reliquaries, (ds) => {
|
||||
setMap[ds.set.id] = setMap[ds.set.id] || 0;
|
||||
setMap[ds.set.id]++;
|
||||
})
|
||||
let reliquarySets = [];
|
||||
lodash.forEach(setMap, (count, id) => {
|
||||
reliquarySets.push({ id: id * 1, count })
|
||||
});
|
||||
tmp.reliquarySets = reliquarySets;
|
||||
playerAvatars.push(tmp);
|
||||
})
|
||||
let playerSpiralAbyssesLevels = [];
|
||||
let getBattleData = function (ds) {
|
||||
let avatars = [];
|
||||
lodash.forEach(ds.avatars, (a) => {
|
||||
avatars.push(a.id);
|
||||
})
|
||||
return {
|
||||
battleIndex: ds.index - 1 || 0,
|
||||
avatarIds: avatars
|
||||
}
|
||||
}
|
||||
lodash.forEach(resAbyss.floors || [], (floor) => {
|
||||
lodash.forEach(floor.levels || [], (level) => {
|
||||
playerSpiralAbyssesLevels.push({
|
||||
floorIndex: floor.index,
|
||||
levelIndex: level.index,
|
||||
star: level.star,
|
||||
battles: [getBattleData(level.battles[0] || {}), getBattleData(level.battles[1] || {})]
|
||||
})
|
||||
})
|
||||
});
|
||||
ret = await HutaoApi.upload({
|
||||
uid: uid.toString(),
|
||||
playerAvatars,
|
||||
playerSpiralAbyssesLevels
|
||||
delete resDetail._res;
|
||||
delete resAbyss._res;
|
||||
ret = await HutaoApi.uploadData({
|
||||
uid,
|
||||
resDetail,
|
||||
resAbyss
|
||||
});
|
||||
} catch (err) {
|
||||
// console.log(err);
|
||||
}
|
||||
if (ret && ret.retcode === 0) {
|
||||
e.reply(`uid:${uid}本次深渊记录上传成功\n多谢支持,喵~`);
|
||||
let msg = [`uid:${uid}本次深渊记录上传成功,多谢支持,喵~`];
|
||||
if (ret.data) {
|
||||
let addMsg = function (title, ds) {
|
||||
if (!ds && !ds.avatarId && !ds.percent) {
|
||||
return;
|
||||
}
|
||||
let char = Character.get(ds.avatarId);
|
||||
title = `${title}:${char.name} ${(ds.value / 10000).toFixed(1)}W,`;
|
||||
if (ds.percent < 0.2) {
|
||||
msg.push(`${title}少于${(100 - ds.percent * 100).toFixed(1)}%的用户`)
|
||||
} else {
|
||||
msg.push(`${title}超过${(ds.percent * 100).toFixed(1)}%的用户`)
|
||||
}
|
||||
}
|
||||
msg.push("本次深渊排行:");
|
||||
addMsg("最强一击", ret.data.damage || {});
|
||||
addMsg("承受伤害", ret.data.takeDamage || {});
|
||||
}
|
||||
e.reply(msg.join("\n"))
|
||||
} else {
|
||||
e.reply(`${ret.message || "上传失败"},请稍后重试...`);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ let Data = {
|
||||
}
|
||||
|
||||
// 检查并创建目录
|
||||
Data.createDir(_path, path, true);
|
||||
Data.createDir(_path, path, false);
|
||||
console.log(data);
|
||||
delete data._res;
|
||||
return fs.writeFileSync(`${_path}/${path}/${file}`, JSON.stringify(data, null, space));
|
||||
|
@ -57,6 +57,17 @@ let HutaoApi = {
|
||||
},
|
||||
body
|
||||
});
|
||||
},
|
||||
|
||||
async uploadData(data = {}) {
|
||||
let body = JSON.stringify(data);
|
||||
return await HutaoApi.req("/Record/UploadData", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'text/json; charset=utf-8',
|
||||
},
|
||||
body
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user