红点:添加试炼宝箱

This commit is contained in:
luying
2021-06-19 14:21:25 +08:00
parent 70b5b59912
commit 9f132e5581
3 changed files with 33 additions and 23 deletions

View File

@@ -35,6 +35,31 @@ export async function getUserGuild(roleId: string, serverId: number) {
return userGuild;
}
export async function getTrainBoxRewardsResult(guildCode: string) {
let guildTrains = await GuildTrainModel.findGuildTrain(guildCode);//获得未失效的宝箱奖励
let resTrainBoxs = [];
guildTrains.forEach(({ trainInstances, trainId }) => {
let { trainInstances: instances } = getArmyTrainJuDian(trainId);
let flag = false;
let boxRewards = [];
trainInstances.map(({ hid, progress, endTime, trainBoxs }) => {
let isComplete = false;
let instance = findWhere(instances, { hid });
if (progress >= instance.progress) {
isComplete = true;
if (endTime > nowSeconds())
flag = true;
}
boxRewards.push({ hid, recordBoxs: trainBoxs, trainId, endTime, isComplete });
});
if (flag) {
resTrainBoxs.push({ trainId, boxRewards });
}
})
return resTrainBoxs
}
/**
* 获得未失效的试炼宝箱奖励
* @param guildTrain