热更新:handler监听热更新
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { DividendModel } from './../../../db/Dividend';
|
||||
import { Application, BackendSession, ChannelService } from "pinus";
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from "pinus";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS } from "../../../consts";
|
||||
import { LotModel } from "../../../db/Lot";
|
||||
import { ItemReward } from "../../../domain/dbGeneral";
|
||||
@@ -17,6 +17,7 @@ import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { UserGuildApplyModel } from '../../../db/UserGuildApply';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new AuctionHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
||||
@@ -14,6 +14,7 @@ import { ARMY } from '../../../pubUtils/dicParam';
|
||||
import { addActive } from '../../../services/guildService'
|
||||
import { checkActivityTask, checkTask } from '../../../services/taskService';
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new DonationHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { EventRecordModel } from '../../../db/EventRecord';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { EVENT_STATUS, EVENT_RECORD_STATUS, EVENT_ANSWER_STATUS, TASK_TYPE } from '../../../consts';
|
||||
@@ -10,6 +10,7 @@ import { checkActivityTask, checkTask } from '../../../services/taskService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new EventBattleHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { ExpeditionRecordModel } from '../../../db/ExpeditionRecord';
|
||||
import { ExpeditionWarRecordModel } from '../../../db/ExpeditionWarRecord';
|
||||
@@ -17,6 +17,7 @@ import { checkActivityTask, checkTask, checkTaskInBattleEnd } from '../../../ser
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ExpeditionBattleHandler(app);
|
||||
}
|
||||
|
||||
@@ -33,7 +34,7 @@ export class ExpeditionBattleHandler {
|
||||
let roleName = session.get('roleName');
|
||||
|
||||
let res = await getExpeditionStatus(roleId, roleName);
|
||||
if(!res) return resResult(STATUS.ROLE_IS_NOT_INIT);
|
||||
if (!res) return resResult(STATUS.ROLE_IS_NOT_INIT);
|
||||
|
||||
return resResult(STATUS.SUCCESS, res);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { BossInstanceModel } from '../../../db/BossInstance';
|
||||
@@ -18,6 +18,7 @@ import { pushGuildBossSucMsg, getGuildChannelSid } from '../../../services/chatS
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildHandler(app);
|
||||
}
|
||||
|
||||
@@ -28,18 +29,18 @@ export class GuildHandler {
|
||||
async debugAddBattleTimes(msg: {}, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let { ranks } = await BossInstanceModel.findBossInstance(code);
|
||||
for (let i = 0;i < ranks.length; i++) {
|
||||
for (let i = 0; i < ranks.length; i++) {
|
||||
let rank = ranks[i];
|
||||
if (rank.roleId == roleId) {
|
||||
rank.time = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let { ranks : resRanks } = await BossInstanceModel.updateBossInstance(code, {ranks});
|
||||
let { ranks: resRanks } = await BossInstanceModel.updateBossInstance(code, { ranks });
|
||||
return resResult(STATUS.SUCCESS, { ranks: resRanks });
|
||||
}
|
||||
|
||||
@@ -47,17 +48,17 @@ export class GuildHandler {
|
||||
async getBossInstance(msg: {}, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let bossInstance = await BossInstanceModel.findBossInstance(code);
|
||||
if (!bossInstance) {
|
||||
return resResult(STATUS.SUCCESS, {status: GUILD_BOSS_STATUS.WAIT_OPEN});//等待团长开启
|
||||
return resResult(STATUS.SUCCESS, { status: GUILD_BOSS_STATUS.WAIT_OPEN });//等待团长开启
|
||||
}
|
||||
let result = await getBossInstanceInfo(bossInstance, roleId);
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
|
||||
//开启演武场
|
||||
async openBossInstance(msg: {}, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
@@ -65,27 +66,27 @@ export class GuildHandler {
|
||||
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'auth guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
const checkMyResult = await checkAuth(GUILD_OPERATE.OPEN_BOSS, roleId, null, userGuild);
|
||||
if(!checkMyResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
let res:any = await lockData(serverId, DATA_NAME.BOSS_SCRIPT, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
if (!checkMyResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
let res: any = await lockData(serverId, DATA_NAME.BOSS_SCRIPT, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
let bossInstance = await BossInstanceModel.findBossInstance(code);
|
||||
if (!!bossInstance && ( bossInstance.bossHp > 0 || bossInstance.startTime >= getZeroPoint() )) {
|
||||
if (!!bossInstance && (bossInstance.bossHp > 0 || bossInstance.startTime >= getZeroPoint())) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_SCRIPT_IS_OPENED_TODAY);
|
||||
}
|
||||
const guild = await GuildModel.findByCode(code, serverId, 'lv structure');
|
||||
if(!guild) {
|
||||
if (!guild) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
}
|
||||
const { structure } = guild;
|
||||
const curStructure = structure.find(cur => cur.id == GUILD_STRUCTURE.BOSS);
|
||||
if(!curStructure) {
|
||||
if (!curStructure) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
||||
}
|
||||
@@ -98,7 +99,7 @@ export class GuildHandler {
|
||||
}
|
||||
await BossInstanceModel.openBossInstance(code, bossHp, warId, bossBase.bossLevel);
|
||||
res.releaseCallback();
|
||||
let result = {warId, ranks: [], myRank: {}, bossHp, status: 3, bossLv: bossBase.bossLevel, isBattled: false};
|
||||
let result = { warId, ranks: [], myRank: {}, bossHp, status: 3, bossLv: bossBase.bossLevel, isBattled: false };
|
||||
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
pinus.app.rpc.chat.guildRemote.pushBossOpen.toServer(chatSid, code, warId, bossHp, result.status);
|
||||
@@ -110,16 +111,16 @@ export class GuildHandler {
|
||||
const roleId: string = session.get('roleId');
|
||||
const roleName: string = session.get('roleName');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode job');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let bossInstance = await BossInstanceModel.findBossInstance(code);
|
||||
if (!bossInstance)
|
||||
if (!bossInstance)
|
||||
return resResult(STATUS.GUILD_SCRIPT_NOT_OPENED);
|
||||
if (bossInstance.bossHp <= 0)
|
||||
if (bossInstance.bossHp <= 0)
|
||||
return resResult(STATUS.GUILD_SCRIPT_IS_COMPLETE);
|
||||
let myRank = findWhere(bossInstance.ranks, {roleId});
|
||||
if (!!myRank && myRank.time > getZeroPoint())
|
||||
let myRank = findWhere(bossInstance.ranks, { roleId });
|
||||
if (!!myRank && myRank.time > getZeroPoint())
|
||||
return resResult(STATUS.GUILD_SCRIPT_IS_BATTLED);
|
||||
let { warId, ranks } = bossInstance;
|
||||
const battleCode = genCode(8); // 关卡唯一值
|
||||
@@ -127,35 +128,35 @@ export class GuildHandler {
|
||||
$set: {
|
||||
roleId, roleName, battleId: warId,
|
||||
status: 0,
|
||||
record: { heroes:[],recordNum: bossInstance.num, bossHp: bossInstance.bossHp},
|
||||
record: { heroes: [], recordNum: bossInstance.num, bossHp: bossInstance.bossHp },
|
||||
}
|
||||
}, true);
|
||||
const serverId:number = parseInt(session.get('serverId'));
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
await addBossInstance(code, serverId, roleId);
|
||||
if (!findWhere(ranks, {roleId})) {
|
||||
await BossInstanceModel.pushRanks(code, {roleId, score: 0, time: nowSeconds(), job: userGuild.job});
|
||||
if (!findWhere(ranks, { roleId })) {
|
||||
await BossInstanceModel.pushRanks(code, { roleId, score: 0, time: nowSeconds(), job: userGuild.job });
|
||||
} else {
|
||||
await BossInstanceModel.updateRank(code, roleId);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { battleCode });
|
||||
}
|
||||
|
||||
async action (msg: { damage: number, battleCode: string }, session: BackendSession ) {
|
||||
async action(msg: { damage: number, battleCode: string }, session: BackendSession) {
|
||||
const { battleCode, damage } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const roleName: string = session.get('roleName');
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let flag = await checkBossBattleMemberExists(code, serverId, roleId, battleCode);
|
||||
if (!flag) {
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
}
|
||||
//记录伤害
|
||||
let bossInstance = await BossInstanceModel.updateBossHp(code, damage, roleId);
|
||||
if (!bossInstance|| bossInstance.bossHp == 0) {//进入结算
|
||||
if (!bossInstance || bossInstance.bossHp == 0) {//进入结算
|
||||
let flag = await bossResult(code, serverId, DATA_NAME.BOSS_SCRIPT, roleId, damage);
|
||||
if (!flag) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
@@ -175,13 +176,13 @@ export class GuildHandler {
|
||||
const funcs: number[] = session.get('funcs');
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
const battleRecord = await BattleRecordModel.getBattleRecordByCode(battleCode, true);
|
||||
if (!battleRecord || battleRecord.status != 0 || roleId != battleRecord.roleId) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
}
|
||||
await BattleRecordModel.updateBattleRecordByCode(battleCode, {
|
||||
$set: { status: 1 }//战斗结束统一设置成1
|
||||
}, true);
|
||||
@@ -192,5 +193,5 @@ export class GuildHandler {
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_BOSS, 1, true, {});
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, ChannelService } from 'pinus';
|
||||
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 } from '../../../consts';
|
||||
import { UserGuildModel, UserGuildType } from '../../../db/UserGuild';
|
||||
@@ -25,6 +25,7 @@ import { pushGuildNoticeUpdateMsg, pushGuildUpStructureMsg, addRoleToGuildChanne
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||
import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, GUILD_OPERATE, TASK_TYPE } from '../../../consts';
|
||||
@@ -17,6 +17,7 @@ import { DATA_NAME } from '../../../consts/dataName';
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildRefineHandler(app);
|
||||
}
|
||||
|
||||
@@ -32,21 +33,21 @@ export class GuildRefineHandler {
|
||||
async getRefine(msg: {}, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let guildRefine = await GuildRefineModel.getRefine(code);
|
||||
if (!guildRefine) {
|
||||
guildRefine = await openGuildRefine(code);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees: guildRefine.scienceTrees });
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees: guildRefine.scienceTrees });
|
||||
}
|
||||
/**
|
||||
* 炼器
|
||||
* @param msg
|
||||
* @param session
|
||||
*/
|
||||
async refineEquip(msg: {pid: number}, session: BackendSession) {
|
||||
async refineEquip(msg: { pid: number }, session: BackendSession) {
|
||||
let { pid } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const sid: string = session.get('sid');
|
||||
@@ -54,10 +55,10 @@ export class GuildRefineHandler {
|
||||
const funcs: number[] = session.get('funcs');
|
||||
let pieceInfo = getGoodById(pid);
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let { guildCode: code } = userGuild;
|
||||
|
||||
|
||||
let { scienceTrees } = await GuildRefineModel.getRefine(code);
|
||||
let findDevelopConsume;
|
||||
//判断是否可以炼该兵器
|
||||
@@ -70,38 +71,38 @@ export class GuildRefineHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!findDevelopConsume)
|
||||
if (!findDevelopConsume)
|
||||
return resResult(STATUS.GUILD_NOT_REFINE_THE_EQUIP);
|
||||
let result = await handleCost(roleId, sid, findDevelopConsume.honourConsume);
|
||||
if(!result)
|
||||
if (!result)
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let goods = await addItems(roleId, roleName, sid, [{id: pid, count: 1}]);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id: pid, count: 1 }]);
|
||||
|
||||
// 任务
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_REFINE, 1, true, { quality: pieceInfo.lvLimited });
|
||||
return resResult(STATUS.SUCCESS, { goods });
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { goods });
|
||||
}
|
||||
/**
|
||||
* 点亮科技树
|
||||
* @param msg
|
||||
* @param session
|
||||
*/
|
||||
async lightUpTree(msg: {id: number}, session: BackendSession) {
|
||||
async lightUpTree(msg: { id: number }, session: BackendSession) {
|
||||
let { id } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const serverId: number = session.get('serverId');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'auth guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const checkMyResult = await checkAuth(GUILD_OPERATE.EQUIP_PRODUCE, roleId, null, userGuild);
|
||||
if(!checkMyResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkMyResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
const { guildCode: code } = userGuild;
|
||||
let developConsume = getArmyDevelopConsumeById(id);
|
||||
if (!developConsume)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let res:any = await lockData(serverId, DATA_NAME.GUILD_REFINE, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let res: any = await lockData(serverId, DATA_NAME.GUILD_REFINE, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
let guildRefine = await GuildRefineModel.getRefine(code);
|
||||
let nowTime = nowSeconds();
|
||||
for (let scienceTree of guildRefine.scienceTrees) {
|
||||
@@ -109,51 +110,51 @@ export class GuildRefineHandler {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_LIGHT_UP_THE_SCIENCETREE);
|
||||
}
|
||||
|
||||
|
||||
if (scienceTree.endTime > nowTime) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_SCIENCETREE_IS_RUNNING);//检查是否有在进行的科技研发,若在研发,不允许研发其他科技树
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (let prePosition of developConsume.prePositions) {
|
||||
let scienceTree = findWhere(guildRefine.scienceTrees, {id: prePosition});
|
||||
if (!scienceTree||scienceTree.endTime > nowTime) {
|
||||
let scienceTree = findWhere(guildRefine.scienceTrees, { id: prePosition });
|
||||
if (!scienceTree || scienceTree.endTime > nowTime) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_PERSITION_TREE_NOT_LIGHT);//前置科技树未点亮
|
||||
}
|
||||
}
|
||||
//点亮消耗
|
||||
const costResult = await GuildModel.costFund(code, developConsume.fundConsume);
|
||||
if(!costResult) {
|
||||
if (!costResult) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_FUND_NOT_ENOUGH);
|
||||
}
|
||||
let scienceTree = { id, endTime: nowTime + developConsume.timeConsume, assistRoleIds: []}
|
||||
let scienceTree = { id, endTime: nowTime + developConsume.timeConsume, assistRoleIds: [] }
|
||||
let { scienceTrees } = await GuildRefineModel.pushRefine(code, scienceTree);
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees });
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees });
|
||||
}
|
||||
/**
|
||||
* 协助点亮科技树
|
||||
* @param msg
|
||||
* @param session
|
||||
*/
|
||||
async assistRefine(msg: {id: number}, session: BackendSession) {
|
||||
async assistRefine(msg: { id: number }, session: BackendSession) {
|
||||
let { id } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const serverId: number = session.get('serverId');
|
||||
const sid: string = session.get('sid');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let res:any = await lockData(serverId, DATA_NAME.GUILD_ASSIST_REFINE, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
let res: any = await lockData(serverId, DATA_NAME.GUILD_ASSIST_REFINE, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
let guildRefine = await GuildRefineModel.getRefine(code);
|
||||
|
||||
|
||||
let index = findIndex(guildRefine.scienceTrees, { id });
|
||||
if (index == -1) {
|
||||
res.releaseCallback();
|
||||
@@ -168,10 +169,10 @@ export class GuildRefineHandler {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_REACH_MAX_ASSIST_COUNT); //协助的人数已经达到最大
|
||||
}
|
||||
let result = await handleCost(roleId, sid, [{id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: ARMY.ARMY_DEVELOPMENT_SPEEDCOST}]);
|
||||
let result = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: ARMY.ARMY_DEVELOPMENT_SPEEDCOST }]);
|
||||
if (!result) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
}
|
||||
scienceTree.assistRoleIds.push(roleId);
|
||||
scienceTree.endTime = scienceTree.endTime - ARMY.ARMY_DEVELOPMENT_SPEED * 60;
|
||||
@@ -181,6 +182,6 @@ export class GuildRefineHandler {
|
||||
// 任务
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_ASSIST_REFINE, 1, true, {});
|
||||
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees });
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees });
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { GuildTrainModel } from '../../../db/GuildTrain';
|
||||
@@ -22,6 +22,7 @@ import { checkActivityTask, checkTask } from '../../../services/taskService';
|
||||
import { sendPopUpActivityData } from '../../../services/guildActivityService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildTrainHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { BattleSweepRecordModel } from '../../../db/BattleSweepRecord';
|
||||
import { genCode } from '../../../pubUtils/util';
|
||||
@@ -26,6 +26,7 @@ import { challengeDailyGK } from '../../../services/activity/dailyGKService';
|
||||
import { challengeNewHeroGK } from '../../../services/activity/newHeroGKService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new NormalBattleHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||
import { uniq, findWhere, findIndex } from 'underscore';
|
||||
import { gameData, getPvpBoxs, getPLvByScore } from '../../../pubUtils/data';
|
||||
import { refreshEnemies, getEnemies, getLvByScore, defaultHeroes, comsumeChallengeCnt, refresh, findPvpDefByRoleId, checkRoleIsRobot, getRefOppCnt, findPvpDefAllByRoleId, generPVPOppRecInfo, generMyRecInfo, robotIdComBack } from '../../../services/pvpService';
|
||||
@@ -26,6 +26,7 @@ import { Rank } from '../../../services/rankService';
|
||||
import { checkActivityTask, checkTask, checkTaskInPvpEnd } from '../../../services/taskService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new PvpHandler(app);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user