炼器堂
This commit is contained in:
@@ -4,7 +4,7 @@ import { STATUS, GUILD_OPERATE, GUILD_AUTH, GUILD_JOB } from '../../../consts';
|
||||
import { GuildTrainModel } from '../../../db/GuildTrain';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { nowSeconds, getHourPoint, getCurHourPoint } from '../../../pubUtils/timeUtil';
|
||||
import { getUserGuild, getGuildTrainInfo, lockTrain, resetTrain, getGuildTrainRewards} from '../../../services/guildTrainService';
|
||||
import { getUserGuild, getGuildTrainInfo, unlockTrain, resetTrain, getGuildTrainRewards} from '../../../services/guildTrainService';
|
||||
import { findIndex, findWhere, indexBy } from 'underscore'
|
||||
import { lockData } from '../../../services/redLockService';
|
||||
import { GUILD_DATA_NAME, REFRESH_HOUR } from '../../../consts/constModules/guildConst';
|
||||
@@ -14,6 +14,7 @@ import { getArmyTrainJuDian, getTrainSoloReward, getTrainBaseByLv } from '../../
|
||||
import { CURRENCY_BY_TYPE, CURRENCY_TYPE } from '../../../consts/constModules/itemConst';
|
||||
import { handleCost, addItems } from '../../../services/rewardService';
|
||||
import { ARMY } from '../../../pubUtils/dicParam';
|
||||
import { addActive } from '../../../services/guildService';
|
||||
export default function (app: Application) {
|
||||
return new GuildTrainHandler(app);
|
||||
}
|
||||
@@ -38,7 +39,7 @@ export class GuildTrainHandler {
|
||||
}
|
||||
let guildTrains = await GuildTrainModel.findGuildTrainByTrainIds(code, trainIds);
|
||||
if (!guildTrains || !findWhere(guildTrains, {trainId})) {
|
||||
let guildTrain = await lockTrain(code, trainId);
|
||||
let guildTrain = await unlockTrain(code, trainId);
|
||||
if (!guildTrains) {
|
||||
guildTrains.push(guildTrain);
|
||||
}
|
||||
@@ -98,13 +99,14 @@ export class GuildTrainHandler {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
const battleRecord = await BattleRecordModel.getBattleRecordByCode(battleCode, true);
|
||||
// if(!battleRecord || battleRecord.status != 0 || roleId != battleRecord.roleId || battleRecord.record.guildCode != code) {
|
||||
// if (!battleRecord || battleRecord.status != 0 || roleId != battleRecord.roleId || battleRecord.record.guildCode != code) {
|
||||
// return resResult(STATUS.WRONG_PARMS);
|
||||
// }
|
||||
let time = Math.floor(battleRecord.createdAt.getTime()/1000);
|
||||
// if (userGuild.trainCount - 1 < 0) {
|
||||
// return resResult(STATUS.WRONG_PARMS);
|
||||
// }
|
||||
|
||||
if (time < getCurHourPoint(REFRESH_HOUR) && nowSeconds() > getCurHourPoint(REFRESH_HOUR)) {
|
||||
return resResult(STATUS.GUILD_TRAIN_IS_RESETED);//关卡已经重置
|
||||
}
|
||||
@@ -168,14 +170,14 @@ export class GuildTrainHandler {
|
||||
let progress = instance.progress;
|
||||
resGuildTrain = await GuildTrainModel.updateGuildTrainProgress(code, trainId, hid, progress, ranks, reports, isComplete);
|
||||
if (needLockNext) { //
|
||||
let nextResGuildTrain = await lockTrain(code, trainId + 1);
|
||||
let nextResGuildTrain = await unlockTrain(code, trainId + 1);
|
||||
trainIds.push(nextResGuildTrain.trainId);
|
||||
guildTrains.push(nextResGuildTrain);
|
||||
}
|
||||
res.releaseCallback();//解锁
|
||||
} else {
|
||||
let progress = trainInstance.progress + addScore;
|
||||
resGuildTrain = await GuildTrainModel.updateGuildTrainProgress(code, trainId, hid, progress, ranks, reports, isComplete);
|
||||
resGuildTrain = await GuildTrainModel.updateGuildTrainProgress(code, trainId, hid, progress, ranks, reports, isComplete);
|
||||
res.releaseCallback();//解锁
|
||||
}
|
||||
} else {
|
||||
@@ -194,6 +196,7 @@ export class GuildTrainHandler {
|
||||
let { trainCount, trainRewards } = userGuild;
|
||||
let result:any = getGuildTrainInfo(guildTrains, roleId, trainCount, trainRewards, trainIds);
|
||||
result.battleGoods = goods;
|
||||
await addActive(roleId, serverId, 2, 1);
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user