练兵场:第二天武将进度清零
This commit is contained in:
@@ -23,25 +23,25 @@ import { getGuildChannelSid } from './chatChannelService';
|
||||
*/
|
||||
export async function refreshTrain(userGuild: UserGuildType, roleId: string, serverId: number) {
|
||||
let { trainCount, trainTime, buyTrainCount, guildCode} = userGuild;
|
||||
let resetResult = await resetTrain(guildCode, serverId);//检查重置练兵场
|
||||
let trainId = await resetTrain(guildCode, serverId);//检查重置练兵场
|
||||
if (trainTime < getZeroPoint()) {//重置挑战次数和购买次数
|
||||
trainCount = ARMY.ARMY_TRAIN_BUYTIMES;
|
||||
|
||||
buyTrainCount = 0;
|
||||
userGuild = await UserGuildModel.updateInfo(roleId, {trainCount, trainTime: nowSeconds(), buyTrainCount}, {});
|
||||
let guildTrains: GuildTrainType[] = [];
|
||||
if(resetResult && resetResult.guildTrains) {
|
||||
guildTrains = resetResult.guildTrains;
|
||||
} else {
|
||||
guildTrains = await GuildTrainModel.getGuildTrainBoxs(guildCode);
|
||||
}
|
||||
for(let guildTrain of guildTrains) {
|
||||
guildTrain.trainInstances.forEach(instance => {
|
||||
instance.progress = 0;
|
||||
instance.endTime = 0;
|
||||
instance.trainBoxs = [];
|
||||
if(trainId) {
|
||||
|
||||
let { trainInstances } = getArmyTrainJuDian(trainId);
|
||||
// 初始化
|
||||
let instances = trainInstances.map(trainInstance => {
|
||||
let t = new TrainInstance();
|
||||
t.hid = trainInstance.hid;
|
||||
t.progress = 0;
|
||||
t.endTime = 0;
|
||||
t.trainBoxs = [];
|
||||
return t;
|
||||
});
|
||||
await GuildTrainModel.updateGuildTrain(guildCode, guildTrain.trainId, { trainInstances: guildTrain.trainInstances });
|
||||
await GuildTrainModel.updateGuildTrain(guildCode, trainId, { trainInstances: instances });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,12 +155,12 @@ export async function resetTrain(code: string, serverId: number) {
|
||||
let res:any = await lockData(serverId, DATA_NAME.GUILD, code);//加锁
|
||||
if (!!res.err)
|
||||
return;
|
||||
let { structure } = await GuildModel.findGuild(code, serverId, 'structure');
|
||||
let { structure, trainId } = await GuildModel.findGuild(code, serverId, 'structure trainId');
|
||||
let { lv } = findWhere(structure, {id: GUILD_STRUCTURE.TRAIN});
|
||||
let guild = await GuildModel.resetGuildTrain(code, serverId, lv);
|
||||
res.releaseCallback();//解锁
|
||||
if (!guild) {//不满足重置条件,结束并解锁
|
||||
return;
|
||||
return trainId;
|
||||
}
|
||||
const userGuildList = await UserGuildModel.getListByGuild(code, 'trainRewards', {});
|
||||
const guildTrains = await GuildTrainModel.getGuildTrainBoxs(code);
|
||||
@@ -197,7 +197,7 @@ export async function resetTrain(code: string, serverId: number) {
|
||||
await GuildTrainModel.resetGuildTrain(code);//将开启的练兵场锁定
|
||||
await unlockTrain(code, 1);//开启练兵场1级
|
||||
await UserGuildModel.resetTrainUserGuild(code);//重置玩家的挑战次数和购买挑战次数
|
||||
return { guildTrains }
|
||||
return trainId
|
||||
}
|
||||
/**
|
||||
* 检查并重置试炼
|
||||
|
||||
Reference in New Issue
Block a user