试炼调试数据
This commit is contained in:
@@ -4,7 +4,6 @@ import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, GUILD_OPERATE } from '../../../consts';
|
||||
import { GuildRefineModel } from '../../../db/GuildRefine';
|
||||
import { getArmyDevelopConsumeById, getGoodById } from '../../../pubUtils/data';
|
||||
import { EquipModel } from '../../../db/Equip';
|
||||
import { nowSeconds } from '../../../pubUtils/timeUtil';
|
||||
import { handleCost, addItems } from '../../../services/rewardService';
|
||||
import { GuildModel } from '../../../db/Guild';
|
||||
@@ -15,7 +14,6 @@ import { checkAuth } from '../../../services/guildService';
|
||||
import { ARMY } from '../../../pubUtils/dicParam';
|
||||
import { CURRENCY_BY_TYPE, CURRENCY_TYPE } from '../../../consts/constModules/itemConst';
|
||||
import { openGuildRefine } from '../../../services/guildRefineService';
|
||||
import { now } from 'moment';
|
||||
export default function (app: Application) {
|
||||
return new GuildRefineHandler(app);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export class GuildTrainHandler {
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let { trainId } = await GuildModel.findGuild(code, serverId, 'trainId');
|
||||
let { trainId, trainLv } = await GuildModel.findGuild(code, serverId, 'trainId trainLv');
|
||||
let guildTrain = await GuildTrainModel.findTrainByTrainIdNotLock(code, trainId);
|
||||
if (!guildTrain ) {
|
||||
guildTrain = await unlockTrain(code, trainId);
|
||||
@@ -41,6 +41,7 @@ export class GuildTrainHandler {
|
||||
let { trainCount, trainRewards, buyTrainCount } = userGuild;
|
||||
let result:any = getGuildTrainInfo(guildTrain, roleId, trainCount, trainRewards);
|
||||
result.buyTrainCount = buyTrainCount;
|
||||
result.trainLv = trainLv;
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
//获得试炼战报
|
||||
@@ -65,7 +66,7 @@ export class GuildTrainHandler {
|
||||
}
|
||||
reports.push(...resReports);
|
||||
});
|
||||
return resResult(STATUS.SUCCESS, {reports});
|
||||
return resResult(STATUS.SUCCESS, { reports });
|
||||
}
|
||||
|
||||
//获得试炼宝箱
|
||||
@@ -199,7 +200,7 @@ export class GuildTrainHandler {
|
||||
ranks.push({score: addScore, roleId});
|
||||
}
|
||||
let needLockNext = false;
|
||||
let report = {roleName, trainId, hid, score: addScore, time: nowSeconds(), isSuccessed: isSuccess, type: 1};//1表示普通战报, 2表示系统战报即:被成功压制
|
||||
let report = {roleName, trainId, hid, score: addScore, time: nowSeconds(), type: isSuccess?2:1, difficulty: battleRecord.record.difficulty};//1表示普通战报, 2表示系统战报即:被成功压制
|
||||
reports.push(report);
|
||||
if (trainInstance.progress < instance.progress ) {
|
||||
if (trainInstance.progress + addScore >= instance.progress) {
|
||||
@@ -217,7 +218,7 @@ export class GuildTrainHandler {
|
||||
let progress = instance.progress;
|
||||
guildTrain = await GuildTrainModel.updateGuildTrainProgress(code, trainId, hid, progress, ranks, isComplete);
|
||||
if (needLockNext) { //
|
||||
reports.push({ isSuccessed: true, type: 2, time:nowSeconds(), score: addScore, roleName, trainId, hid });
|
||||
reports.push({ type: 3, time:nowSeconds(), score: addScore, roleName, trainId, hid, difficulty: battleRecord.record.difficulty });
|
||||
guildTrain = await unlockTrain(code, trainId + 1);
|
||||
}
|
||||
res.releaseCallback();//解锁
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { GuildModel } from '../../../db/Guild';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { WishPoolReportModel } from '../../../db/WishPoolReport';
|
||||
import { resResult, genCode } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { DonationModel } from '../../../db/Donation';
|
||||
import { nowSeconds } from '../../../pubUtils/timeUtil';
|
||||
import { getArmyDonateBaseByLv, getArmyDonateBoxBaseById } from '../../../pubUtils/data';
|
||||
import { getArmyWishPoolBaseByLv, getGoodById } from '../../../pubUtils/data';
|
||||
import { handleCost, addItems } from '../../../services/rewardService';
|
||||
import { CHAT_SERVER } from '../../../consts';
|
||||
import { getDonation } from '../../../services/donateService';
|
||||
import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
|
||||
import { getUserGuildWithRefActive } from '../../../services/guildService';
|
||||
import { ARMY } from '../../../pubUtils/dicParam';
|
||||
import { findIndex, findWhere } from 'underscore';
|
||||
export default function(app: Application) {
|
||||
return new WishPoolHandler(app);
|
||||
}
|
||||
@@ -29,23 +30,92 @@ export class WishPoolHandler {
|
||||
let userGuilds = await UserGuildModel.getWishPoolGoods(code, ' wishDntCnt wishGoods');
|
||||
let list = [];
|
||||
userGuilds.map(({ wishGoods })=>{
|
||||
// wishGoods.map(({ type, goodId, count, receiveCnt, drawCnt, _id })=>{
|
||||
// list.push({ type, goodId, count, receiveCnt, drawCnt, id: _id })
|
||||
// });
|
||||
wishGoods.map(({ type, goodId, count, receiveCnt, drawCnt, id })=>{
|
||||
list.push({ type, goodId, count, receiveCnt, drawCnt, id })
|
||||
});
|
||||
});
|
||||
return resResult(STATUS.SUCCESS, { list, wishDntCnt, wishGoods });
|
||||
}
|
||||
|
||||
async wishGoods(msg: {roleId: string, id: number}, session: BackendSession) {
|
||||
// 许愿
|
||||
async wishGoods(msg: {goodId: number, type: number}, session: BackendSession) {
|
||||
const { goodId, type } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, 'donateCnt receiveBoxs guildCode');
|
||||
let count;
|
||||
let goodInfo = getGoodById(goodId)
|
||||
if (!goodInfo)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, ' wishDntCnt wishGoods guildCode wishGoods');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code, wishDntCnt, wishGoods } = userGuild;
|
||||
const { wishPoolLv } = await GuildModel.findGuild(code, serverId);
|
||||
let { structure } = await GuildModel.findGuild(code, serverId, 'structure');
|
||||
let { lv } = findWhere(structure, {id: GUILD_STRUCTURE.DONATE});
|
||||
let { wishGoodsEquips, wishGoodsHeros } = getArmyWishPoolBaseByLv(lv);
|
||||
let len = wishGoods.length;
|
||||
if (len >= 1) //今日已经许愿过
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (type == 1) {
|
||||
let wishGoodsEquip = findWhere(wishGoodsEquips, { quality: goodInfo.quality});
|
||||
count = wishGoodsEquip.count;
|
||||
} else {
|
||||
let wishGoodsHero = findWhere(wishGoodsHeros, { quality: goodInfo.quality});
|
||||
count = wishGoodsHero.count;
|
||||
}
|
||||
const id = genCode(6);
|
||||
let { wishGoods : resWishGoods } = await UserGuildModel.pushAndUpdate(roleId, { wishGoods }, { wishGoods: { type, goodId, count, receiveCnt: 0, drawCnt: 0, id} }, 'wishGoods');
|
||||
return resResult(STATUS.SUCCESS, { wishDntCnt, wishGoods: resWishGoods });
|
||||
}
|
||||
|
||||
// 捐赠
|
||||
async donateGoods(msg: {wishRoleId: string, id: string}, session: BackendSession) {
|
||||
let { wishRoleId, id } = msg;
|
||||
const dntRoleId: string = session.get('roleId');
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
const dntRoleName: string = session.get('roleName');
|
||||
|
||||
let wishUserGuild = await getUserGuildWithRefActive(wishRoleId, ' wishDntCnt wishGoods guildCode wishGoods');
|
||||
if (!wishUserGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code, wishGoods } = wishUserGuild;
|
||||
const { } = await GuildModel.findGuild(code, serverId);
|
||||
let wishGood = findWhere(wishGoods, { id });
|
||||
if (wishGood) {
|
||||
|
||||
}
|
||||
// WishPoolReportModel.addReport(code, roleId: wishRoleId, roleName: , dntRoleId, dntRoleName, goodId, 1);
|
||||
}
|
||||
|
||||
async receiveGoods(msg: { id: string }, session: BackendSession) {
|
||||
let { id } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const roleName: string = session.get('roleName');
|
||||
const sid: string = session.get('sid');
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, 'donateCnt receiveBoxs guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code, wishGoods } = userGuild;
|
||||
let index = findIndex(wishGoods, { id });
|
||||
if (index == -1)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let { drawCnt, goodId } = wishGoods[index];
|
||||
if (drawCnt <= 0)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id : goodId, count: drawCnt }]);
|
||||
wishGoods[index].drawCnt = 0;
|
||||
await UserGuildModel.updateInfo(code, { wishGoods }, {});
|
||||
return resResult(STATUS.SUCCESS, { goods, wishGoods });
|
||||
}
|
||||
|
||||
async getReports(msg: {}, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, ' guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
const reports = await WishPoolReportModel.getReportsByTime(code, 1);
|
||||
return resResult(STATUS.SUCCESS, { reports });
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user