军团:bug修复
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from 'pinus';
|
||||
import { resResult, getRandEelm, shouldRefresh, sortArrRandom } from '../../../pubUtils/util';
|
||||
import { STATUS, GUILD_OPERATE, GUILD_AUTH, GUILD_JOB, GUILD_APPLY_TYPE, GUILD_STRUCTURE, GUILD_REC_TYPE, GUILD_STRUCTURE_NAME, MAIL_TYPE, REDIS_KEY, GUILD_SELECT, USER_GUILD_SELECT, TASK_TYPE, DEBUG_MAGIC_WORD } from '../../../consts';
|
||||
import { STATUS, GUILD_OPERATE, GUILD_AUTH, GUILD_JOB, GUILD_APPLY_TYPE, GUILD_STRUCTURE, GUILD_REC_TYPE, GUILD_STRUCTURE_NAME, MAIL_TYPE, REDIS_KEY, GUILD_SELECT, USER_GUILD_SELECT, TASK_TYPE, DEBUG_MAGIC_WORD, CHANNEL_PREFIX, MSG_TYPE, MSG_SOURCE } from '../../../consts';
|
||||
import { UserGuildModel, UserGuildType } from '../../../db/UserGuild';
|
||||
import { checkAuth, joinGuild, getGuildWithRefActive, getUserGuildWithRefActive, addActive, settleGuildWeekly, getMyGuildInfo, refreshUserGuild, setUserGuildSession } from '../../../services/guildService';
|
||||
import { GuildModel, GuildType, GuildUpdateParam } from '../../../db/Guild';
|
||||
@@ -21,12 +21,13 @@ import { openGuildRefine } from '../../../services/guildRefineService';
|
||||
import { unlockTrain } from '../../../services/guildTrainService';
|
||||
import { removeBossRank } from '../../../services/guildBossService';
|
||||
import { removeTrainRank } from '../../../services/guildTrainService';
|
||||
import { pushGuildNoticeUpdateMsg, pushGuildUpStructureMsg, addRoleToGuildChannel, getGuildChannelSid } from '../../../services/chatService';
|
||||
import { pushGuildNoticeUpdateMsg, pushGuildUpStructureMsg, addRoleToGuildChannel, getGuildChannelSid, createGroupMsg, pushGroupMsgToRoom } from '../../../services/chatService';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
import { guildInter } from '../../../pubUtils/interface';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildHandler(app);
|
||||
@@ -796,16 +797,19 @@ export class GuildHandler {
|
||||
async recruit(msg: guildInter & { code: string, info: string }, session: BackendSession) {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
// const roleName = session.get('roleName');
|
||||
const sid = session.get('sid');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
|
||||
const { code, info } = msg;
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId);
|
||||
if (!guild) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
|
||||
|
||||
// 发送世界频道消息
|
||||
this.app.rpc.chat.chatRemote.sendWorldMessage.toServer('chat-server-1', serverId, { info });
|
||||
let channelId = `${serverId}`;
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.WORLD, channelId, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GUILD_RECURIT, JSON.stringify({ guildCode: guild.code, guildName: guild.name, info }), '', '');
|
||||
if (!msgData) return resResult(STATUS.WRONG_PARMS);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { isSuccess: true });
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ export class GuildTrainHandler {
|
||||
const { guildCode: code } = userGuild;
|
||||
if (userGuild.trainCount <= 0)
|
||||
return resResult(STATUS.GUILD_TRAIN_BATTLE_COUNT_NOT_ENOUGH);
|
||||
let { trainId: curTeainId, trainLv } = await GuildModel.findGuild(code, serverId, 'trainId');
|
||||
let { trainId: curTeainId, trainLv } = await GuildModel.findGuild(code, serverId, 'trainId trainLv');
|
||||
if (curTeainId !== trainId)
|
||||
return resResult(STATUS.GUILD_TRAIN_LEVEL_IS_COMPLETE);
|
||||
let guildTrain = await GuildTrainModel.findTrainByTrainIdNotLock(code, trainId, 'trainId isComplete trainInstances');
|
||||
@@ -191,7 +191,7 @@ export class GuildTrainHandler {
|
||||
}
|
||||
let addScore = Math.floor((isSuccess ? trainSoloReward.winScore : trainSoloReward.failScore));//个人获得积分,也是压制进度
|
||||
//个人功勋奖励
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.HONOUR), count: Math.floor((isSuccess ? trainSoloReward.winHonour : trainSoloReward.failHonour) * (soloRewardRatio + 100) / 100) }]);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.HONOUR), count: Math.floor((isSuccess ? trainSoloReward.winHonour : trainSoloReward.failHonour) * soloRewardRatio) }]);
|
||||
let { isComplete, ranks } = guildTrain;
|
||||
let reports = [];
|
||||
// let index = findIndex(ranks, { roleId });
|
||||
@@ -224,6 +224,7 @@ export class GuildTrainHandler {
|
||||
reports.push({ type: 3, time: nowSeconds(), score: addScore, roleName, trainId, hid, difficulty });
|
||||
pushGuildTrainSucMsg(roleId, roleName, code, hid);
|
||||
|
||||
|
||||
if (needLockNext && maxTrainId > trainId) {
|
||||
guildTrain = await unlockTrain(code, trainId + 1);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { WishPoolReportModel } from '../../../db/WishPoolReport';
|
||||
import { resResult, genCode } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { getArmyWishPoolBaseByLv, getGoodById } from '../../../pubUtils/data';
|
||||
import { addItems, checkGoods } from '../../../services/rewardService';
|
||||
import { addItems, checkGoods, checkHeroes } from '../../../services/rewardService';
|
||||
import { IT_TYPE } from '../../../consts/constModules/itemConst';
|
||||
import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
|
||||
import { refreshUserGuild, getWishPool, getUserGuildWithRefActive } from '../../../services/guildService';
|
||||
@@ -14,6 +14,7 @@ import { RoleModel } from '../../../db/Role';
|
||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||
import { ARMY } from '../../../pubUtils/dicParam';
|
||||
import { guildInter } from '../../../pubUtils/interface';
|
||||
import { getSeconds, nowSeconds } from '../../../pubUtils/timeUtil';
|
||||
export default function(app: Application) {
|
||||
return new WishPoolHandler(app);
|
||||
}
|
||||
@@ -50,7 +51,7 @@ export class WishPoolHandler {
|
||||
let result = await checkGoods(roleId, [goodId]);
|
||||
if (!result) {
|
||||
if (goodInfo.itid == IT_TYPE.HERO_PIECE ) {
|
||||
result = await checkGoods(roleId, [goodInfo.hid]);
|
||||
result = await checkHeroes(roleId, [goodInfo.hid]);
|
||||
if (!result)
|
||||
return resResult(STATUS.GUILD_WISH_POOL_NOT_OWN_HERO);
|
||||
} else if (goodInfo.itid == IT_TYPE.EQUIP_PIECE ) {
|
||||
@@ -59,7 +60,8 @@ export class WishPoolHandler {
|
||||
return resResult(STATUS.GUILD_WISH_POOL_NOT_OWN_EQUIP);
|
||||
}
|
||||
}
|
||||
const { guildCode: code, wishGoods } = userGuild;
|
||||
const { guildCode: code, wishGoods, receivedWishPool, createdAt } = userGuild;
|
||||
|
||||
let { structure } = await GuildModel.findGuild(code, serverId, 'structure');
|
||||
let { lv } = findWhere(structure, {id: GUILD_STRUCTURE.WISH_POOL});
|
||||
let { wishGoodsEquips, wishGoodsHeros } = getArmyWishPoolBaseByLv(lv);
|
||||
@@ -68,6 +70,9 @@ export class WishPoolHandler {
|
||||
if (resType == type)
|
||||
len++;
|
||||
});
|
||||
if(receivedWishPool.indexOf(type) != -1 && getSeconds(createdAt) > nowSeconds()) {
|
||||
return resResult(STATUS.HAS_REACH_WISH_COUNT_LIMIT);
|
||||
}
|
||||
if (len >= ARMY.ARMY_WISH_TIMES) //今日已经许愿过
|
||||
return resResult(STATUS.HAS_REACH_WISH_COUNT_LIMIT);
|
||||
if (type == 1) {
|
||||
@@ -135,7 +140,7 @@ export class WishPoolHandler {
|
||||
let userGuild = await refreshUserGuild(myUserGuild, roleId);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { wishGoods } = userGuild;
|
||||
const { wishGoods, receivedWishPool } = userGuild;
|
||||
let index = findIndex(wishGoods, { id });
|
||||
if (index == -1)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
@@ -143,7 +148,9 @@ export class WishPoolHandler {
|
||||
if (drawCnt <= 0)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
wishGoods[index].drawCnt = 0;
|
||||
let result = await UserGuildModel.updateInfo(roleId, { wishGoods }, {});
|
||||
if(receivedWishPool.indexOf(wishGoods[index].type) == -1) receivedWishPool.push(wishGoods[index].type);
|
||||
|
||||
let result = await UserGuildModel.updateInfo(roleId, { wishGoods, receivedWishPool }, {});
|
||||
if (!result)
|
||||
resResult(STATUS.INTERNAL_ERR);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id : goodId, count: drawCnt }]);
|
||||
|
||||
Reference in New Issue
Block a user