红点:添加试炼宝箱
This commit is contained in:
@@ -24,7 +24,7 @@ import { getSchoolList } from './roleService';
|
||||
import { addRoleToGuildChannel } from './chatChannelService';
|
||||
import { getMyGuildInfo, getGuildWithRefActive, getUserGuildWithRefActive, getWishPool } from './guildService';
|
||||
import { getAuction } from './auctionService';
|
||||
import { getGuildTrainInstance } from './guildTrainService';
|
||||
import { getGuildTrainInstance, getTrainBoxRewardsResult } from './guildTrainService';
|
||||
import { BossInstanceModel } from '../db/BossInstance';
|
||||
import { getBossInstanceInfo } from './guildBossService';
|
||||
import { getEvent } from './eventSercive';
|
||||
@@ -109,7 +109,11 @@ export async function pushData(role: RoleType, session: FrontendOrBackendSession
|
||||
case 'auction':
|
||||
return hasGuild? await getAuction(guildCode, session): null;
|
||||
case 'train':
|
||||
return hasGuild? await getGuildTrainInstance(roleId, guild, userGuild): null;
|
||||
if(hasGuild) {
|
||||
let trainInstance = await getGuildTrainInstance(roleId, guild, userGuild);
|
||||
let trainBoxRewards = await getTrainBoxRewardsResult(guildCode);
|
||||
return { trainInstance, trainBoxRewards }
|
||||
}
|
||||
case 'boss':
|
||||
if(hasGuild) {
|
||||
const bossInstance = await BossInstanceModel.findBossInstance(guild.code);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user