军团: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 }]);
|
||||
|
||||
@@ -224,7 +224,7 @@ export async function getUserGuildWithRefActive(roleId: string, select?: string,
|
||||
|
||||
export async function refreshUserGuild(userGuild: UserGuildType, roleId: string, notPush?: boolean) {
|
||||
if(!userGuild) return false;
|
||||
let { receivedActive, refTimeDaily, activeDaily, activeRecord, wishGoods } = userGuild;
|
||||
let { receivedActive, refTimeDaily, activeDaily, activeRecord, wishGoods, receivedWishPool } = userGuild;
|
||||
|
||||
const now = new Date();
|
||||
let isRefDaily = shouldRefresh(refTimeDaily, now);
|
||||
@@ -243,9 +243,9 @@ export async function refreshUserGuild(userGuild: UserGuildType, roleId: string,
|
||||
}
|
||||
});
|
||||
|
||||
receivedActive = []; refTimeDaily = now; activeDaily = 0; activeRecord = []; wishGoods = [];
|
||||
receivedActive = []; refTimeDaily = now; activeDaily = 0; activeRecord = []; wishGoods = []; receivedWishPool = [];
|
||||
let receiveBoxs = [], wishDntCnt = 0, donateCnt = 0;
|
||||
userGuild = await UserGuildModel.updateInfo(roleId, { receivedActive, refTimeDaily, activeDaily, activeRecord, wishGoods, receiveBoxs, wishDntCnt, donateCnt }, {});
|
||||
userGuild = await UserGuildModel.updateInfo(roleId, { receivedActive, refTimeDaily, activeDaily, activeRecord, wishGoods, receiveBoxs, wishDntCnt, donateCnt, receivedWishPool }, {});
|
||||
if (!userGuild) return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -390,17 +390,9 @@ export async function checkGoods(roleId: string, goodIds: Array<number>) {
|
||||
} else if (table == ITEM_TABLE.ITEM) {
|
||||
itemIds.push(goodId);
|
||||
}
|
||||
} else {
|
||||
hids.push(goodId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!!hids.length) {
|
||||
let heros = await HeroModel.findByHidRange(hids, roleId);
|
||||
if (heros.length < hids.length)
|
||||
return false;
|
||||
}
|
||||
|
||||
//检查装备是否存在
|
||||
if (!!equipIds.length) {
|
||||
let resEquips = await EquipModel.getEquipsByIds(roleId, equipIds);
|
||||
@@ -419,6 +411,14 @@ export async function checkGoods(roleId: string, goodIds: Array<number>) {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function checkHeroes(roleId: string, hids: number[]) {
|
||||
if (!!hids.length) {
|
||||
let heros = await HeroModel.findByHidRange(hids, roleId);
|
||||
if (heros.length < hids.length)
|
||||
return false;
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
export async function unlockFigure(sid: string, roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }[], role?: RoleType) {
|
||||
let figureInfo = await pubUnlockFigure(roleId, conditions, role);
|
||||
|
||||
@@ -54,7 +54,8 @@ export const MSG_SOURCE = {
|
||||
EQUIP_REFRESH_BEST: 20,
|
||||
ACQUIRE_RARE_GOODS: 21,
|
||||
GROUP_SEND_GIFT: 22,
|
||||
SEND_MARQUEE: 23
|
||||
SEND_MARQUEE: 23,
|
||||
GUILD_RECURIT: 24,
|
||||
}
|
||||
|
||||
export const ON_PRIVATE_MSG_ROUTE = 'onPrivateMessage';
|
||||
|
||||
@@ -88,6 +88,9 @@ export default class UserGuild extends BaseModel {
|
||||
@prop({ required: true, default: [], type: WishGood, _id: false })
|
||||
wishGoods: Array<WishGood>;
|
||||
|
||||
@prop({ required: true, default: [], type: Number })
|
||||
receivedWishPool: number[];
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
wishDntCnt: number;//今天许愿池捐献次数
|
||||
|
||||
@@ -127,12 +130,12 @@ export default class UserGuild extends BaseModel {
|
||||
|
||||
public static async createUserGuild(guildCode: string, role: RoleType, isLeader: boolean) {
|
||||
const lastGuild = await UserGuildModel.findMyLastGuild(role.roleId);
|
||||
let { receiveBoxs = [], donateCnt = 0, receivedActive = [], encourageCnt = 0, bossChallengeCnt = 0 } = lastGuild||{};
|
||||
let { receiveBoxs = [], donateCnt = 0, receivedActive = [], encourageCnt = 0, bossChallengeCnt = 0, receivedWishPool = [] } = lastGuild||{};
|
||||
|
||||
const doc = new UserGuildModel();
|
||||
let job = isLeader? GUILD_JOB.DAJIANGJUN: GUILD_JOB.SHIBING;
|
||||
let auth = isLeader? GUILD_AUTH.LEADER: GUILD_AUTH.MEMBER;
|
||||
const update = Object.assign(doc.toJSON(), { guildCode, roleId: role.roleId, role: role._id, job, auth, receiveBoxs, donateCnt, receivedActive, encourageCnt, bossChallengeCnt });
|
||||
const update = Object.assign(doc.toJSON(), { guildCode, roleId: role.roleId, role: role._id, job, auth, receiveBoxs, donateCnt, receivedActive, encourageCnt, bossChallengeCnt, receivedWishPool });
|
||||
delete update._id;
|
||||
const result: UserGuildType = await UserGuildModel.findOneAndUpdate({ roleId: role.roleId, guildCode, status: USER_GUILD_STATUS.ON }, update, { upsert: true, new: true })
|
||||
.select('activeDaily activeRecord activeWeekly activeUpdateTime job auth receivedActive guildCode')
|
||||
|
||||
@@ -7,7 +7,6 @@ export interface DicTrainSoloReward {
|
||||
|
||||
readonly id: number;
|
||||
// 目标品质
|
||||
readonly ratio: number;
|
||||
readonly winScore: number;
|
||||
readonly failScore: number;
|
||||
readonly winHonour: number;
|
||||
@@ -17,7 +16,6 @@ export interface DicTrainSoloReward {
|
||||
|
||||
const DicTrainSoloRewardKeys: KeysEnum<DicTrainSoloReward> = {
|
||||
id: true,
|
||||
ratio: true,
|
||||
winScore: true,
|
||||
failScore: true,
|
||||
winHonour: true,
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
"name": "TEAM_INVITE",
|
||||
"mean": "组队一键邀请",
|
||||
"type": "2&3",
|
||||
"template": "<color=#c08834>%d</color><color=#a49a48>发起组队邀请,诚邀各路侠士加入</color><color=#a49a48>%d</color><color=#a49a48>寻宝队伍,</color><color=#2f9b00><on click=%d>[加入]</on></color>",
|
||||
"template": "<color=#c08834>%d</color><color=#a49a48>发起组队邀请,诚邀各路侠士加入</color><color=#a49a48> %d</color><color=#a49a48>寻宝队伍,</color><color=#2f9b00><on click=%d>[加入]</on></color>",
|
||||
"comments": "1:%d(发出组队邀请的玩家名);2:%d(藏宝图对应的关卡名); 3:%d(跳转链接)"
|
||||
},
|
||||
{
|
||||
@@ -190,5 +190,13 @@
|
||||
"type": "1&",
|
||||
"template": "%d",
|
||||
"comments": "&"
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
"name": "GUILD_RECURIT",
|
||||
"mean": "军团招募",
|
||||
"type": "2&",
|
||||
"template": "<color=#c08834>%d</color><color=#a49a48>正在招兵买马,诚邀各路侠士加入!<color=#2f9b00><on click=%d>[前往]</on></color>",
|
||||
"comments": "1:%d(军团名)"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user