校验:添加接口校验
This commit is contained in:
@@ -132,8 +132,6 @@ export class ActivityMonopolyHandler {
|
|||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
const sid: string = session.get('sid');
|
const sid: string = session.get('sid');
|
||||||
|
|
||||||
|
|
||||||
if (addCount > 0) {
|
|
||||||
let playerData = await getPlayerMonopolyData(activityId, serverId, roleId)
|
let playerData = await getPlayerMonopolyData(activityId, serverId, roleId)
|
||||||
let curPosition = playerData.curPosition;
|
let curPosition = playerData.curPosition;
|
||||||
if (curPosition == 0) {
|
if (curPosition == 0) {
|
||||||
@@ -169,9 +167,6 @@ export class ActivityMonopolyHandler {
|
|||||||
let recordResult = await ActivityMonopolyLandModel.addRecord(serverId, activityId, roleId, curPosition, BANK_TYPE.IN, resrouseStr);
|
let recordResult = await ActivityMonopolyLandModel.addRecord(serverId, activityId, roleId, curPosition, BANK_TYPE.IN, resrouseStr);
|
||||||
landData.record = recordResult.record;
|
landData.record = recordResult.record;
|
||||||
return resResult(STATUS.SUCCESS, { landData });
|
return resResult(STATUS.SUCCESS, { landData });
|
||||||
}
|
|
||||||
|
|
||||||
return resResult(STATUS.MONOPOLY_BANK_COUNT_ERROR);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ export class DailyCoinHandler {
|
|||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
if(count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
let playerData = await getPlayerDailyCoinData(activityId, serverId, roleId)
|
let playerData = await getPlayerDailyCoinData(activityId, serverId, roleId)
|
||||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ export class GachaHandler {
|
|||||||
*/
|
*/
|
||||||
async pull(msg: { gachaId: number, activityId: number, count: number }, session: BackendSession) {
|
async pull(msg: { gachaId: number, activityId: number, count: number }, session: BackendSession) {
|
||||||
const { gachaId, activityId, count } = msg;
|
const { gachaId, activityId, count } = msg;
|
||||||
if (gachaId == undefined || activityId == undefined || count == undefined || count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
const roleId: string = session.get('roleId');
|
const roleId: string = session.get('roleId');
|
||||||
const roleName: string = session.get('roleName');
|
const roleName: string = session.get('roleName');
|
||||||
const sid: string = session.get('sid');
|
const sid: string = session.get('sid');
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ export class LuckyTurntableHandler {
|
|||||||
*/
|
*/
|
||||||
async pull(msg: { activityId: number, count: number }, session: BackendSession) {
|
async pull(msg: { activityId: number, count: number }, session: BackendSession) {
|
||||||
const { activityId, count } = msg;
|
const { activityId, count } = msg;
|
||||||
if(count < 0) {
|
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
|
||||||
}
|
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ export class TaskPassHandler {
|
|||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
if(count <= 0 || !isNumber(count)) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
let playerData = await getTaskPassData(activityId, serverId, roleId)
|
let playerData = await getTaskPassData(activityId, serverId, roleId)
|
||||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ export class DungeonBattleHandler {
|
|||||||
// 购买每日次数
|
// 购买每日次数
|
||||||
async buyNum(msg: { count: number }, session: BackendSession) {
|
async buyNum(msg: { count: number }, session: BackendSession) {
|
||||||
let { count } = msg;
|
let { count } = msg;
|
||||||
if( !count || count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export class ExpeditionBattleHandler {
|
|||||||
* 进入战斗
|
* 进入战斗
|
||||||
* 记录我军数据,生成战斗唯一表示,记录状态
|
* 记录我军数据,生成战斗唯一表示,记录状态
|
||||||
*/
|
*/
|
||||||
async checkBattle(msg: { expeditionCode: string, expeditionId: number, battleId: number, heroes: Array<number> }, session: BackendSession) {
|
async checkBattle(msg: { expeditionCode: string, expeditionId: number, battleId: number, heroes: number[] }, session: BackendSession) {
|
||||||
const { expeditionCode, expeditionId, battleId, heroes: seqIds = [] } = msg;
|
const { expeditionCode, expeditionId, battleId, heroes: seqIds = [] } = msg;
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let roleName = session.get('roleName');
|
let roleName = session.get('roleName');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Application, BackendSession, HandlerService, } from 'pinus';
|
|||||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||||
import { BattleSweepRecordModel } from '../../../db/BattleSweepRecord';
|
import { BattleSweepRecordModel } from '../../../db/BattleSweepRecord';
|
||||||
import { genCode, getReasonByWarType, getWarTypeName } from '../../../pubUtils/util';
|
import { genCode, getReasonByWarType, getWarTypeName } from '../../../pubUtils/util';
|
||||||
import { WAR_TYPE, EVENT_STATUS, FUNC_OPT_TYPE, MSG_SOURCE, REDIS_KEY, TASK_TYPE, KING_EXP_RATIO_TYPE, TA_EVENT, ITEM_CHANGE_REASON } from '../../../consts';
|
import { WAR_TYPE, EVENT_STATUS, REDIS_KEY, KING_EXP_RATIO_TYPE, TA_EVENT, ITEM_CHANGE_REASON } from '../../../consts';
|
||||||
import { checkDaily, checkDailyAndIncrease } from '../../../services/dailyBattleService';
|
import { checkDaily, checkDailyAndIncrease } from '../../../services/dailyBattleService';
|
||||||
import { checkTowerWar, towerBattleEnd } from '../../../services/battleService';
|
import { checkTowerWar, towerBattleEnd } from '../../../services/battleService';
|
||||||
import { WarReward } from '../../../services/warRewardService';
|
import { WarReward } from '../../../services/warRewardService';
|
||||||
@@ -12,7 +12,7 @@ import { STATUS } from '../../../consts/statusCode';
|
|||||||
import { resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
import { RScriptRecordModel } from '../../../db/RScriptRecord';
|
import { RScriptRecordModel } from '../../../db/RScriptRecord';
|
||||||
import { checkBattleHeroes, roleLevelup, getBattleList, calculateWarStar, getBattleListOfTypes, getMainChapter, getStarOfChapter, checkWarCountAndInc } from '../../../services/normalBattleService';
|
import { checkBattleHeroes, roleLevelup, calculateWarStar, getBattleListOfTypes, getMainChapter, getStarOfChapter, checkWarCountAndInc } from '../../../services/normalBattleService';
|
||||||
import { checkDungeonNum, checkDungeonAndIncrease, saveDungeonFirst } from '../../../services/dungeonService';
|
import { checkDungeonNum, checkDungeonAndIncrease, saveDungeonFirst } from '../../../services/dungeonService';
|
||||||
// import { switchOnFunc } from '../../../services/funcSwitchService';
|
// import { switchOnFunc } from '../../../services/funcSwitchService';
|
||||||
import { gameData } from '../../../pubUtils/data';
|
import { gameData } from '../../../pubUtils/data';
|
||||||
@@ -131,8 +131,6 @@ export class NormalBattleHandler {
|
|||||||
// 关卡列表
|
// 关卡列表
|
||||||
async getBattleList(msg: { types: number[] }, session: BackendSession) {
|
async getBattleList(msg: { types: number[] }, session: BackendSession) {
|
||||||
const { types } = msg;
|
const { types } = msg;
|
||||||
if(!isArray(types)) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
|
|
||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
@@ -143,7 +141,7 @@ export class NormalBattleHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 关卡结算,记录使用的武将,获得奖励
|
// 关卡结算,记录使用的武将,获得奖励
|
||||||
async battleEnd(msg: { battleCode: string, battleId: number, isSuccess: boolean, stars: number[], heroes: Array<any>, activityId: number, pageIndex: number }, session: BackendSession) {
|
async battleEnd(msg: { battleCode: string, battleId: number, isSuccess: boolean, stars: number[], heroes: number[], activityId: number, pageIndex: number }, session: BackendSession) {
|
||||||
const { battleCode, battleId, isSuccess, heroes = [], stars = [], activityId, pageIndex } = msg;
|
const { battleCode, battleId, isSuccess, heroes = [], stars = [], activityId, pageIndex } = msg;
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let roleName = session.get('roleName');
|
let roleName = session.get('roleName');
|
||||||
@@ -318,9 +316,7 @@ export class NormalBattleHandler {
|
|||||||
let sid = session.get('sid');
|
let sid = session.get('sid');
|
||||||
let serverId = session.get('serverId');
|
let serverId = session.get('serverId');
|
||||||
let ip = session.get('ip');
|
let ip = session.get('ip');
|
||||||
|
|
||||||
if(count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
let warInfo = gameData.war.get(battleId);
|
let warInfo = gameData.war.get(battleId);
|
||||||
if (!warInfo) {
|
if (!warInfo) {
|
||||||
return resResult(STATUS.BATTLE_MISS_INFO);
|
return resResult(STATUS.BATTLE_MISS_INFO);
|
||||||
@@ -443,9 +439,6 @@ export class NormalBattleHandler {
|
|||||||
const { warId, battleCode, count } = msg;
|
const { warId, battleCode, count } = msg;
|
||||||
let roleId: string = session.get('roleId');
|
let roleId: string = session.get('roleId');
|
||||||
let vipStartTime: number = session.get('vipStartTime');
|
let vipStartTime: number = session.get('vipStartTime');
|
||||||
if(!isNumber(count) || count <= 0) {
|
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
let battleRecord = await BattleRecordModel.getBattleRecordByCode(battleCode);
|
let battleRecord = await BattleRecordModel.getBattleRecordByCode(battleCode);
|
||||||
if(!battleRecord || battleRecord.roleId != roleId || battleRecord.battleId != warId) {
|
if(!battleRecord || battleRecord.roleId != roleId || battleRecord.battleId != warId) {
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
|
|
||||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||||
import { uniq, findWhere, findIndex } from 'underscore';
|
import { findIndex } from 'underscore';
|
||||||
import { gameData, getPvpBoxBySeasonNumAndIndex } from '../../../pubUtils/data';
|
import { gameData, getPvpBoxBySeasonNumAndIndex } from '../../../pubUtils/data';
|
||||||
import { refreshEnemies, getEnemies, getLvByScore, comsumeChallengeCnt, refChallengeCnt, generPVPOppRecInfo, generMyRecInfo, sendLastSeasonRewardIfNotSent, refreshRefOppCnt, generPvpLineupCe } from '../../../services/pvpService';
|
import { refreshEnemies, getEnemies, refChallengeCnt, generPVPOppRecInfo, generMyRecInfo, sendLastSeasonRewardIfNotSent, refreshRefOppCnt, generPvpLineupCe } from '../../../services/pvpService';
|
||||||
import { RoleModel, RoleType } from '../../../db/Role';
|
import { RoleModel, RoleType } from '../../../db/Role';
|
||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
import { resResult, genCode, checkRoleIsRobot, robotIdComBack } from '../../../pubUtils/util';
|
import { resResult, genCode, checkRoleIsRobot, robotIdComBack } from '../../../pubUtils/util';
|
||||||
import { PvpDefenseModel, pvpUpdateInter } from '../../../db/PvpDefense';
|
import { PvpDefenseModel, pvpUpdateInter } from '../../../db/PvpDefense';
|
||||||
import { PvpSeasonResultModel } from '../../../db/PvpSeasonResult';
|
import { PvpSeasonResultModel } from '../../../db/PvpSeasonResult';
|
||||||
import { PVPConfigModel } from '../../../db/SystemConfig';
|
|
||||||
import { Rank } from '../../../services/rankService';
|
import { Rank } from '../../../services/rankService';
|
||||||
import { checkTask, checkTaskInPvpEnd } from '../../../services/task/taskService';
|
import { checkTask, checkTaskInPvpEnd } from '../../../services/task/taskService';
|
||||||
import { Attack, AttackHero, Defense, DefenseHero, PvpDataReturn } from '../../../domain/battleField/pvp';
|
import { Attack, Defense, DefenseHero, PvpDataReturn } from '../../../domain/battleField/pvp';
|
||||||
import { DEBUG_MAGIC_WORD, FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, LINEUP_NUM, REDIS_KEY, TASK_TYPE } from '../../../consts';
|
import { DEBUG_MAGIC_WORD, FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, LINEUP_NUM, REDIS_KEY, TASK_TYPE } from '../../../consts';
|
||||||
import { PVP } from '../../../pubUtils/dicParam';
|
import { PVP } from '../../../pubUtils/dicParam';
|
||||||
import { addItems, getGoldObject, handleCost, unlockFigure } from '../../../services/role/rewardService';
|
import { addItems, getGoldObject, handleCost, unlockFigure } from '../../../services/role/rewardService';
|
||||||
import { pick } from "underscore";
|
import { pick } from "underscore";
|
||||||
import { HeroModel } from '../../../db/Hero';
|
import { HeroModel } from '../../../db/Hero';
|
||||||
import PvpHistoryOpp, { PvpHistoryOppModel } from '../../../db/PvpHistoryOpp';
|
import PvpHistoryOpp, { PvpHistoryOppModel } from '../../../db/PvpHistoryOpp';
|
||||||
import { checkBattleHeroesByHid } from '../../../services/normalBattleService';
|
|
||||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||||
import { PvpRecordModel } from '../../../db/PvpRecord';
|
import { PvpRecordModel } from '../../../db/PvpRecord';
|
||||||
import { pvpEndParamInter } from '../../../pubUtils/interface';
|
import { pvpEndParamInter } from '../../../pubUtils/interface';
|
||||||
@@ -293,7 +291,6 @@ export class PvpHandler {
|
|||||||
let { count } = msg;
|
let { count } = msg;
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let sid = session.get('sid');
|
let sid = session.get('sid');
|
||||||
if(count <= 0 || count == undefined) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
let pvpDefense = await PvpDefenseModel.findByRoleId(roleId);
|
let pvpDefense = await PvpDefenseModel.findByRoleId(roleId);
|
||||||
if(!pvpDefense) return resResult(STATUS.PVP_NOT_OPEN);
|
if(!pvpDefense) return resResult(STATUS.PVP_NOT_OPEN);
|
||||||
@@ -338,12 +335,7 @@ export class PvpHandler {
|
|||||||
async saveAttack(msg: { heroes: { actorId: number, order: number }[] }, session: BackendSession) {
|
async saveAttack(msg: { heroes: { actorId: number, order: number }[] }, session: BackendSession) {
|
||||||
let { heroes } = msg;
|
let { heroes } = msg;
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let sid = session.get('sid');
|
|
||||||
|
|
||||||
if (heroes.length > LINEUP_NUM || heroes.length <= 0) {
|
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
|
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
|
||||||
if(!pvpDefense) return resResult(STATUS.PVP_NOT_OPEN);
|
if(!pvpDefense) return resResult(STATUS.PVP_NOT_OPEN);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { STATUS } from './../../../consts/statusCode';
|
import { STATUS } from './../../../consts/statusCode';
|
||||||
import { HANG_UP_CONSTS, ITEM_CHANGE_REASON, MSG_SOURCE, REDIS_KEY, TASK_TYPE } from './../../../consts';
|
import { HANG_UP_CONSTS, ITEM_CHANGE_REASON, MSG_SOURCE, REDIS_KEY } from './../../../consts';
|
||||||
import { TaskHero, TowerTaskRecModel, TowerTaskRecType } from './../../../db/TowerTaskRec';
|
import { TaskHero, TowerTaskRecModel, TowerTaskRecType } from './../../../db/TowerTaskRec';
|
||||||
import { HangUpSpdUpRecModel } from './../../../db/HangUpSpdUpRec';
|
import { HangUpSpdUpRecModel } from './../../../db/HangUpSpdUpRec';
|
||||||
import { HangUpRecordModel } from './../../../db/HangUpRecord';
|
import { HangUpRecordModel } from './../../../db/HangUpRecord';
|
||||||
@@ -7,19 +7,18 @@ import { RoleModel } from './../../../db/Role';
|
|||||||
import { TowerRecordModel } from './../../../db/TowerRecord';
|
import { TowerRecordModel } from './../../../db/TowerRecord';
|
||||||
import { Application, BackendSession } from 'pinus';
|
import { Application, BackendSession } from 'pinus';
|
||||||
import { resResult, genCode, shouldRefresh } from '../../../pubUtils/util';
|
import { resResult, genCode, shouldRefresh } from '../../../pubUtils/util';
|
||||||
import { calcuHangUpReward, refreshTasks, treatTask, getRemainTime, getTowerStatus, getHungupRewards, getTasks, checkTaskRewards, getTowerTaskCostGold, getHangSpdUpCostGold, getManyHangSpdUpCostGold, getTaskStatus, checkForbiddenChar, checkAndStartHungUp, createNewTowerRecord, getTowerRecByLv } from '../../../services/battleService';
|
import { calcuHangUpReward, refreshTasks, treatTask, getRemainTime, getTowerStatus, getHungupRewards, getTasks, checkTaskRewards, getTowerTaskCostGold, getManyHangSpdUpCostGold, getTaskStatus, checkForbiddenChar, checkAndStartHungUp, createNewTowerRecord, getTowerRecByLv } from '../../../services/battleService';
|
||||||
import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService';
|
import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService';
|
||||||
import { checkBattleHeroes } from '../../../services/normalBattleService';
|
import { checkBattleHeroes } from '../../../services/normalBattleService';
|
||||||
import { gameData } from '../../../pubUtils/data';
|
import { gameData } from '../../../pubUtils/data';
|
||||||
import * as dicParam from '../../../pubUtils/dicParam';
|
import * as dicParam from '../../../pubUtils/dicParam';
|
||||||
import { isNumber } from 'underscore';
|
|
||||||
import { HeroModel } from '../../../db/Hero';
|
import { HeroModel } from '../../../db/Hero';
|
||||||
import { vipCanSkipTower } from '../../../services/activity/monthlyTicketService';
|
import { vipCanSkipTower } from '../../../services/activity/monthlyTicketService';
|
||||||
import { pushTowerMsg } from '../../../services/sysChatService';
|
import { pushTowerMsg } from '../../../services/sysChatService';
|
||||||
import { WarStar } from '../../../domain/dbGeneral';
|
import { WarStar } from '../../../domain/dbGeneral';
|
||||||
import { RewardInter } from '../../../pubUtils/interface';
|
import { RewardInter } from '../../../pubUtils/interface';
|
||||||
import { combineItems } from '../../../services/role/util';
|
import { combineItems } from '../../../services/role/util';
|
||||||
import { checkTask, checkTaskInSkipTower } from '../../../services/task/taskService';
|
import { checkTaskInSkipTower } from '../../../services/task/taskService';
|
||||||
import { Rank } from '../../../services/rankService';
|
import { Rank } from '../../../services/rankService';
|
||||||
|
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
@@ -122,10 +121,7 @@ export class TowerBattleHandler {
|
|||||||
let roleName = session.get('roleName');
|
let roleName = session.get('roleName');
|
||||||
let sid = session.get('sid');
|
let sid = session.get('sid');
|
||||||
let { speedUpCnt } = msg;
|
let { speedUpCnt } = msg;
|
||||||
|
|
||||||
if (!isNumber(speedUpCnt) || speedUpCnt <= 0) {
|
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
|
||||||
}
|
|
||||||
const curTime = new Date();
|
const curTime = new Date();
|
||||||
|
|
||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ export class ChatHandler {
|
|||||||
async getPrivateMessage(msg: { targetRoleId: string, fromSeqId: number, count: number }, session: BackendSession) {
|
async getPrivateMessage(msg: { targetRoleId: string, fromSeqId: number, count: number }, session: BackendSession) {
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const { targetRoleId, fromSeqId = Infinity, count = DEFAULT_MSG_PER_PAGE } = msg;
|
const { targetRoleId, fromSeqId = Infinity, count = DEFAULT_MSG_PER_PAGE } = msg;
|
||||||
if( count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
const msgs = await getPrivateMessages(roleId, targetRoleId, fromSeqId, count);
|
const msgs = await getPrivateMessages(roleId, targetRoleId, fromSeqId, count);
|
||||||
const targetRoleInfo = await getSimpleRoleInfo(targetRoleId);
|
const targetRoleInfo = await getSimpleRoleInfo(targetRoleId);
|
||||||
return resResult(STATUS.SUCCESS, { targetRoleId, msgs, targetRoleInfo });
|
return resResult(STATUS.SUCCESS, { targetRoleId, msgs, targetRoleInfo });
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import { isCheckWord } from "../../../pubUtils/sdkUtil";
|
|||||||
import { isDevelopEnv } from "../../../services/utilService";
|
import { isDevelopEnv } from "../../../services/utilService";
|
||||||
import { isNumber } from "underscore";
|
import { isNumber } from "underscore";
|
||||||
import { redisClient } from "../../../services/redisService";
|
import { redisClient } from "../../../services/redisService";
|
||||||
|
import { checkRouteParam } from "../../../services/checkParam";
|
||||||
|
|
||||||
export function globalFilter(app: Application) {
|
export function globalFilter(app: Application) {
|
||||||
return new Filter(app);
|
return new Filter(app);
|
||||||
}
|
}
|
||||||
@@ -52,6 +54,10 @@ class Filter {
|
|||||||
return next(new Error('globalFilter'), resResult(STATUS.FUNCTION_CLOSE));
|
return next(new Error('globalFilter'), resResult(STATUS.FUNCTION_CLOSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!checkRouteParam(routeRecord.route, msg)) {
|
||||||
|
return next(new Error('globalFilter'), resResult(STATUS.WRONG_PARMS));
|
||||||
|
}
|
||||||
|
|
||||||
// 玩家屏蔽
|
// 玩家屏蔽
|
||||||
if(blockType == BLOCK_TYPE.BLOCK) return next(new Error('globalFilter'), resResult(STATUS.BLOCKED));
|
if(blockType == BLOCK_TYPE.BLOCK) return next(new Error('globalFilter'), resResult(STATUS.BLOCKED));
|
||||||
if(blockType == BLOCK_TYPE.BAN && this.checkBanRoute(routeRecord.route)) {
|
if(blockType == BLOCK_TYPE.BAN && this.checkBanRoute(routeRecord.route)) {
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ export class EntryHandler {
|
|||||||
* @param {Object} msg request message
|
* @param {Object} msg request message
|
||||||
* @param {Object} session current session object
|
* @param {Object} session current session object
|
||||||
*/
|
*/
|
||||||
async gmEnter(msg: { token: string, serverId: number }, session: FrontendSession) {
|
async gmEnter(msg: { token: string }, session: FrontendSession) {
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
|
|||||||
@@ -190,7 +190,6 @@ export class AuctionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async offerRecs(msg: { count: number }, session: BackendSession) {
|
async offerRecs(msg: { count: number }, session: BackendSession) {
|
||||||
if( msg.count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
const lotsData = await LotModel.recentBidLots(serverId, roleId, msg.count);
|
const lotsData = await LotModel.recentBidLots(serverId, roleId, msg.count);
|
||||||
@@ -203,7 +202,6 @@ export class AuctionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async guildLotRecs(msg: { count: number }, session: BackendSession) {
|
async guildLotRecs(msg: { count: number }, session: BackendSession) {
|
||||||
if( msg.count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
const guildCode = session.get('guildCode');
|
const guildCode = session.get('guildCode');
|
||||||
const dividends = await DividendModel.findDividendsByGuild(guildCode, msg.count);
|
const dividends = await DividendModel.findDividendsByGuild(guildCode, msg.count);
|
||||||
let lotsData = [];
|
let lotsData = [];
|
||||||
|
|||||||
@@ -146,7 +146,6 @@ export class CityActivityHandler {
|
|||||||
// 开始挑战
|
// 开始挑战
|
||||||
async checkBattle(msg: guildInter & { cityId: number, heroes: number[] }, session: BackendSession) {
|
async checkBattle(msg: guildInter & { cityId: number, heroes: number[] }, session: BackendSession) {
|
||||||
let { cityId, heroes, myUserGuild: userGuild } = msg;
|
let { cityId, heroes, myUserGuild: userGuild } = msg;
|
||||||
if (!heroes || heroes.length <= 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
@@ -256,8 +255,6 @@ export class CityActivityHandler {
|
|||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
|
|
||||||
let { cityId, code, damage, hid, round } = msg;
|
let { cityId, code, damage, hid, round } = msg;
|
||||||
if (damage == undefined || damage < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
let obj = getCityActivityObj();
|
let obj = getCityActivityObj();
|
||||||
let { gateHp, maxHp } = await obj.getGateHpAndInc(serverId, cityId);
|
let { gateHp, maxHp } = await obj.getGateHpAndInc(serverId, cityId);
|
||||||
if (gateHp <= 0) return resResult(STATUS.GATE_HP_IS_ZERO);
|
if (gateHp <= 0) return resResult(STATUS.GATE_HP_IS_ZERO);
|
||||||
@@ -320,7 +317,6 @@ export class CityActivityHandler {
|
|||||||
let guildCode = session.get('guildCode');
|
let guildCode = session.get('guildCode');
|
||||||
let serverId = session.get('serverId');
|
let serverId = session.get('serverId');
|
||||||
|
|
||||||
|
|
||||||
let { cityId, code, isSuccess } = msg;
|
let { cityId, code, isSuccess } = msg;
|
||||||
let obj = getCityActivityObj();
|
let obj = getCityActivityObj();
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ export class GateActivityHandler {
|
|||||||
// 开启挑战
|
// 开启挑战
|
||||||
async checkBattle(msg: guildInter & { heroes: number[] }, session: BackendSession) {
|
async checkBattle(msg: guildInter & { heroes: number[] }, session: BackendSession) {
|
||||||
let { heroes, myUserGuild: userGuild } = msg;
|
let { heroes, myUserGuild: userGuild } = msg;
|
||||||
if (!heroes || heroes.length <= 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
@@ -163,7 +161,6 @@ export class GateActivityHandler {
|
|||||||
let sid = session.get('sid');
|
let sid = session.get('sid');
|
||||||
let guildCode = session.get('guildCode');
|
let guildCode = session.get('guildCode');
|
||||||
let serverId = session.get('serverId');
|
let serverId = session.get('serverId');
|
||||||
|
|
||||||
|
|
||||||
let { code, isSuccess, gateHp } = msg;
|
let { code, isSuccess, gateHp } = msg;
|
||||||
|
|
||||||
|
|||||||
@@ -159,9 +159,6 @@ export class GuildHandler {
|
|||||||
if (!flag) {
|
if (!flag) {
|
||||||
return resResult(STATUS.REDLOCK_ERR);
|
return resResult(STATUS.REDLOCK_ERR);
|
||||||
}
|
}
|
||||||
if(damage < 0) {
|
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
//记录伤害
|
//记录伤害
|
||||||
let bossInstance = await BossInstanceModel.updateBossHp(bossCode, zoomInDamage(damage), roleId);
|
let bossInstance = await BossInstanceModel.updateBossHp(bossCode, zoomInDamage(damage), roleId);
|
||||||
@@ -211,8 +208,6 @@ export class GuildHandler {
|
|||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
|
|
||||||
const serverId: number = parseInt(session.get('serverId'));
|
|
||||||
|
|
||||||
let bossInstance = await BossInstanceModel.findByCode(bossCode);
|
let bossInstance = await BossInstanceModel.findByCode(bossCode);
|
||||||
if(!bossInstance) return resResult(STATUS.WRONG_PARMS);
|
if(!bossInstance) return resResult(STATUS.WRONG_PARMS);
|
||||||
@@ -240,7 +235,6 @@ export class GuildHandler {
|
|||||||
const { count, myUserGuild: userGuild } = msg;
|
const { count, myUserGuild: userGuild } = msg;
|
||||||
const roleId: string = session.get('roleId');
|
const roleId: string = session.get('roleId');
|
||||||
const sid: string = session.get('sid');
|
const sid: string = session.get('sid');
|
||||||
if(!count || count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
let bossInstance = await BossInstanceModel.findBossInstance(userGuild.guildCode);
|
let bossInstance = await BossInstanceModel.findBossInstance(userGuild.guildCode);
|
||||||
if(!bossInstance) return resResult(STATUS.GUILD_SCRIPT_NOT_OPENED);
|
if(!bossInstance) return resResult(STATUS.GUILD_SCRIPT_NOT_OPENED);
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ export class GuildRefineHandler {
|
|||||||
*/
|
*/
|
||||||
async refine(msg: guildInter & { id: number, count: number }, session: BackendSession) {
|
async refine(msg: guildInter & { id: number, count: number }, session: BackendSession) {
|
||||||
let { id, count, myUserGuild: userGuild } = msg;
|
let { id, count, myUserGuild: userGuild } = msg;
|
||||||
if( count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
const roleId: string = session.get('roleId');
|
const roleId: string = session.get('roleId');
|
||||||
const sid: string = session.get('sid');
|
const sid: string = session.get('sid');
|
||||||
const roleName: string = session.get('roleName');
|
const roleName: string = session.get('roleName');
|
||||||
|
|||||||
@@ -352,7 +352,6 @@ export class GuildTrainHandler {
|
|||||||
//购买挑战次数
|
//购买挑战次数
|
||||||
async purchaseTrainCount(msg: guildInter & { count: number }, session: BackendSession) {
|
async purchaseTrainCount(msg: guildInter & { count: number }, session: BackendSession) {
|
||||||
let { count, myUserGuild } = msg;
|
let { count, myUserGuild } = msg;
|
||||||
if( count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
const roleId: string = session.get('roleId');
|
const roleId: string = session.get('roleId');
|
||||||
const serverId: number = parseInt(session.get('serverId'));
|
const serverId: number = parseInt(session.get('serverId'));
|
||||||
const sid: string = session.get('sid');
|
const sid: string = session.get('sid');
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ export class RaceActivityHandler {
|
|||||||
let index = getGAIndexInPinus(this.aid);
|
let index = getGAIndexInPinus(this.aid);
|
||||||
|
|
||||||
let { id, count, toGuild } = msg;
|
let { id, count, toGuild } = msg;
|
||||||
if (!count || count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
let obj = getRaceActivityObj();
|
let obj = getRaceActivityObj();
|
||||||
let woodenHorse = obj.getWoodenHorse(toGuild, serverId);
|
let woodenHorse = obj.getWoodenHorse(toGuild, serverId);
|
||||||
if (!woodenHorse) return resResult(STATUS.WRONG_PARMS);
|
if (!woodenHorse) return resResult(STATUS.WRONG_PARMS);
|
||||||
|
|||||||
@@ -716,7 +716,6 @@ export class EquipHandler {
|
|||||||
//宝石合成
|
//宝石合成
|
||||||
public async composeStone(msg: { id: number, count: number }, session: BackendSession) {
|
public async composeStone(msg: { id: number, count: number }, session: BackendSession) {
|
||||||
let { id, count } = msg;
|
let { id, count } = msg;
|
||||||
if(count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
let roleId: string = session.get('roleId');
|
let roleId: string = session.get('roleId');
|
||||||
let roleName: string = session.get('roleName');
|
let roleName: string = session.get('roleName');
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ export class ItemHandler {
|
|||||||
const roleName = session.get('roleName');
|
const roleName = session.get('roleName');
|
||||||
const guildCode = session.get('guildCode');
|
const guildCode = session.get('guildCode');
|
||||||
|
|
||||||
|
|
||||||
if (count > 0) {
|
|
||||||
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }], ITEM_CHANGE_REASON.USE_GIFT_PACKAGE);
|
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }], ITEM_CHANGE_REASON.USE_GIFT_PACKAGE);
|
||||||
if (!consumeResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH);
|
if (!consumeResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH);
|
||||||
|
|
||||||
@@ -55,9 +53,6 @@ export class ItemHandler {
|
|||||||
}
|
}
|
||||||
let result = await useGiftPackage(roleId, roleName, sid, serverId, guildCode, giftID, selected, count);
|
let result = await useGiftPackage(roleId, roleName, sid, serverId, guildCode, giftID, selected, count);
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +64,6 @@ export class ItemHandler {
|
|||||||
const ip = session.get('ip');
|
const ip = session.get('ip');
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
|
|
||||||
if (count > 0) {
|
|
||||||
let dicGoods = gameData.goods.get(id);
|
let dicGoods = gameData.goods.get(id);
|
||||||
if (!dicGoods) {
|
if (!dicGoods) {
|
||||||
return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
@@ -96,10 +90,6 @@ export class ItemHandler {
|
|||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
apJson
|
apJson
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 购买体力道具
|
// 购买体力道具
|
||||||
@@ -188,23 +178,6 @@ export class ItemHandler {
|
|||||||
return resResult(STATUS.SUCCESS, { goods });
|
return resResult(STATUS.SUCCESS, { goods });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async debugIncAp(msg: { magicWord: string, ap: number }, session: BackendSession) {
|
|
||||||
const { magicWord } = msg;
|
|
||||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
|
||||||
return resResult(STATUS.TOKEN_ERR);
|
|
||||||
}
|
|
||||||
|
|
||||||
const roleId = session.get('roleId');
|
|
||||||
const sid = session.get('sid');
|
|
||||||
const ip = session.get('ip');
|
|
||||||
const serverId = session.get('serverId');
|
|
||||||
|
|
||||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
|
||||||
let apJson = await setAp(serverId, roleId, ip, role.lv, msg.ap, sid, ITEM_CHANGE_REASON.DEBUG);
|
|
||||||
if (!apJson) return resResult(STATUS.BATTLE_ACTION_POINT_LACK)
|
|
||||||
return resResult(STATUS.SUCCESS, { apJson });
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getAp(msg: {}, session: BackendSession) {
|
public async getAp(msg: {}, session: BackendSession) {
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let ip = session.get('ip');
|
let ip = session.get('ip');
|
||||||
@@ -233,6 +206,24 @@ export class ItemHandler {
|
|||||||
return resResult(STATUS.SUCCESS, { ap, apBefore });
|
return resResult(STATUS.SUCCESS, { ap, apBefore });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async debugIncAp(msg: { magicWord: string, ap: number }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
const roleId = session.get('roleId');
|
||||||
|
const sid = session.get('sid');
|
||||||
|
const ip = session.get('ip');
|
||||||
|
const serverId = session.get('serverId');
|
||||||
|
|
||||||
|
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||||
|
let apJson = await setAp(serverId, roleId, ip, role.lv, msg.ap, sid, ITEM_CHANGE_REASON.DEBUG);
|
||||||
|
if (!apJson) return resResult(STATUS.BATTLE_ACTION_POINT_LACK)
|
||||||
|
return resResult(STATUS.SUCCESS, { apJson });
|
||||||
|
}
|
||||||
|
|
||||||
public async debugResetBuyTimes(msg: { magicWord: string }, session: BackendSession) {
|
public async debugResetBuyTimes(msg: { magicWord: string }, session: BackendSession) {
|
||||||
const { magicWord } = msg;
|
const { magicWord } = msg;
|
||||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
|||||||
@@ -154,13 +154,4 @@ export class RoleHandler {
|
|||||||
goods
|
goods
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async test(msg: {}, session: BackendSession) {
|
|
||||||
let roles = await RoleModel.find({}).lean();
|
|
||||||
for (let role of roles) {
|
|
||||||
let heroes = await HeroModel.find({ roleId: role.roleId }).lean();
|
|
||||||
await RoleModel.updateRoleInfo(role.roleId, { heroNum: heroes.length, heroNumUpdatedAt: nowSeconds() });
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,6 @@ export class RoleHandler {
|
|||||||
//神像强化
|
//神像强化
|
||||||
async roleTeraphStrengthen(msg: { id: number, count: number }, session: BackendSession) {
|
async roleTeraphStrengthen(msg: { id: number, count: number }, session: BackendSession) {
|
||||||
let { id, count } = msg;
|
let { id, count } = msg;
|
||||||
if( count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
let serverId: number = session.get('serverId');
|
let serverId: number = session.get('serverId');
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ export class ShopHandler {
|
|||||||
let serverId = session.get('serverId');
|
let serverId = session.get('serverId');
|
||||||
|
|
||||||
let { activityId = 0, shopItemId, count } = msg;
|
let { activityId = 0, shopItemId, count } = msg;
|
||||||
if( count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
let dicShopItem = await getShopDicById(activityId, shopItemId, roleId, serverId);
|
let dicShopItem = await getShopDicById(activityId, shopItemId, roleId, serverId);
|
||||||
if(!dicShopItem) return STATUS.DIC_DATA_NOT_FOUND;
|
if(!dicShopItem) return STATUS.DIC_DATA_NOT_FOUND;
|
||||||
@@ -95,7 +94,6 @@ export class ShopHandler {
|
|||||||
let roleName = session.get('roleName');
|
let roleName = session.get('roleName');
|
||||||
let sid = session.get('sid');
|
let sid = session.get('sid');
|
||||||
let { goodsId, count } = msg;
|
let { goodsId, count } = msg;
|
||||||
if(!count || count < 0) return resResult(STATUS.WRONG_PARMS);
|
|
||||||
|
|
||||||
let dicGoods = gameData.goods.get(goodsId);
|
let dicGoods = gameData.goods.get(goodsId);
|
||||||
if(!dicGoods) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
if(!dicGoods) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
|
|||||||
1649
game-server/app/services/checkParam.ts
Normal file
1649
game-server/app/services/checkParam.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -137,7 +137,7 @@ export function sendMessgeToChannelByBatch(channel: Channel, route: string, data
|
|||||||
|
|
||||||
// 抽下下来pushMessage收束
|
// 抽下下来pushMessage收束
|
||||||
export function sendMessageToChannel(channel: Channel, route: string, data: any) {
|
export function sendMessageToChannel(channel: Channel, route: string, data: any) {
|
||||||
channel.pushMessage(route, data);
|
channel.pushMessage(route, encryptMsg(route, data));
|
||||||
infologger.debug(`pushMessage route: ${route} data: ${JSON.stringify(data)} members: ${channel.getMembers().join()}`);
|
infologger.debug(`pushMessage route: ${route} data: ${JSON.stringify(data)} members: ${channel.getMembers().join()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { PinusWSClient } from 'pinus-robot-plugin';
|
|||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { Client } from './Client';
|
import { Client } from './Client';
|
||||||
import { checkSuccessResponse } from './CheckPatten';
|
import { checkSuccessResponse } from './CheckPatten';
|
||||||
import { ACTIVITY_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, STATUS } from '../app/consts';
|
import { ACTIVITY_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, DEBUG_MAGIC_WORD, STATUS } from '../app/consts';
|
||||||
describe('活动测试', function () {
|
describe('活动测试', function () {
|
||||||
let pinusClient: PinusWSClient;
|
let pinusClient: PinusWSClient;
|
||||||
let playerGroupArray: [] = [];
|
let playerGroupArray: [] = [];
|
||||||
@@ -188,7 +188,7 @@ describe('活动测试', function () {
|
|||||||
|
|
||||||
function checkActivityData(pinusClient, url, type, done) {
|
function checkActivityData(pinusClient, url, type, done) {
|
||||||
try {
|
try {
|
||||||
requestActivity(pinusClient, 'activity.activityHandler.debugActivityMemory', { type })
|
requestActivity(pinusClient, 'activity.activityHandler.debugActivityMemory', { magicWord: DEBUG_MAGIC_WORD })
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
if (data.data) {
|
if (data.data) {
|
||||||
checkSuccessResponse(data);
|
checkSuccessResponse(data);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { PinusWSClient } from 'pinus-robot-plugin';
|
|||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { addItemsIfNotEnough, checkBattleGoods, checkDisplayItems, checkSuccessResponse, checkTimeStamp, checkWarJson } from './CheckPatten';
|
import { addItemsIfNotEnough, checkBattleGoods, checkDisplayItems, checkSuccessResponse, checkTimeStamp, checkWarJson } from './CheckPatten';
|
||||||
import * as dic7001 from '../app/resource/warJsons/7001.json';
|
import * as dic7001 from '../app/resource/warJsons/7001.json';
|
||||||
|
import { DEBUG_MAGIC_WORD } from '../app/consts';
|
||||||
|
|
||||||
describe('蛮夷入侵测试', function () {
|
describe('蛮夷入侵测试', function () {
|
||||||
let pinusClient: PinusWSClient;
|
let pinusClient: PinusWSClient;
|
||||||
@@ -358,7 +359,7 @@ describe('粮草先行测试', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('结束比赛', function (done) {
|
it('结束比赛', function (done) {
|
||||||
pinusClient.request('guild.raceActivityHandler.settleReward', { serverId: roleInfo.serverId }, res => {
|
pinusClient.request('guild.raceActivityHandler.settleReward', { magicWord: DEBUG_MAGIC_WORD, serverId: roleInfo.serverId }, res => {
|
||||||
pinusClient.request('guild.raceActivityHandler.battleEnd', { code, isSuccess: true }, res => {
|
pinusClient.request('guild.raceActivityHandler.battleEnd', { code, isSuccess: true }, res => {
|
||||||
checkSuccessResponse(res);
|
checkSuccessResponse(res);
|
||||||
expect(res.data.hasShow).to.equal(false);
|
expect(res.data.hasShow).to.equal(false);
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ export function deltaDays(preTime: Date, proTime: Date): number {
|
|||||||
* @param deltaDay 间隔几天刷新,默认每天刷新(deltaDay = 1)
|
* @param deltaDay 间隔几天刷新,默认每天刷新(deltaDay = 1)
|
||||||
*/
|
*/
|
||||||
export function shouldRefresh(preTime: Date, now: Date, hour: number = REFRESH_TIME, deltaDay = 1): boolean {
|
export function shouldRefresh(preTime: Date, now: Date, hour: number = REFRESH_TIME, deltaDay = 1): boolean {
|
||||||
|
console.log('##### shouldRefresh preTime', preTime, 'now', now, 'hour', hour, 'deltaDay', deltaDay)
|
||||||
if (!preTime) return true;
|
if (!preTime) return true;
|
||||||
let curTime = new Date(now.getTime());
|
let curTime = new Date(now.getTime());
|
||||||
let refreshTime = getZeroPointD(SHOP_REFRESH_TYPE.DAILY, hour);
|
let refreshTime = getZeroPointD(SHOP_REFRESH_TYPE.DAILY, hour);
|
||||||
|
|||||||
Reference in New Issue
Block a user