✨ feat(battle): 保存战场校验异常的数据
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { BattleSweepRecordModel } from '../../../db/BattleSweepRecord';
|
||||
import { BattleCheatRecModel } from '../../../db/BattleCheatRec';
|
||||
import { genCode, getReasonByWarType, getWarTypeName } from '../../../pubUtils/util';
|
||||
import { WAR_TYPE, EVENT_STATUS, REDIS_KEY, KING_EXP_RATIO_TYPE, TA_EVENT, ITEM_CHANGE_REASON } from '../../../consts';
|
||||
import { checkDaily, checkDailyAndIncrease } from '../../../services/dailyBattleService';
|
||||
@@ -528,4 +529,17 @@ export class NormalBattleHandler {
|
||||
receivedWarIds: warIds, goods: combineItems(goods)
|
||||
});
|
||||
}
|
||||
|
||||
// 记录战场校验异常数据
|
||||
async recordBattleCheat(msg: { dataId: number, type: number, iKey: number, value: number, secV: number }, session: BackendSession) {
|
||||
const { dataId, type, iKey, value, secV } = msg;
|
||||
let roleId = session.get('roleId');
|
||||
let roleName = session.get('roleName');
|
||||
|
||||
const rec = await BattleCheatRecModel.createRecord(dataId, type, iKey, value, secV, roleId, roleName);
|
||||
if (!rec) {
|
||||
return resResult(STATUS.BATTLE_CHECK_REC_SAVE_ERR);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ export const STATUS = {
|
||||
BATTLE_NOT_FOUND: { code: 20011, simStr: '未找到对应关卡'},
|
||||
BATTLE_RPL_UPDATE_ERR: { code: 20012, simStr: '录像状态更新失败'},
|
||||
BATTLE_RPL_NOT_SUPPORT: { code: 20013, simStr: '暂不支持保存此类战斗的录像'},
|
||||
BATTLE_CHECK_REC_SAVE_ERR: { code: 20014, simStr: '战斗检测记录保存错误'},
|
||||
|
||||
// 主线 20100 - 20199
|
||||
BATTLE_INFO_VALIDATE_ERR: { code: 20101, simStr: '关卡信息不同' },
|
||||
|
||||
56
shared/db/BattleCheatRec.ts
Normal file
56
shared/db/BattleCheatRec.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
|
||||
/**
|
||||
* 战场作弊信息记录
|
||||
**/
|
||||
@index({ roleId: 1, dataId: 1 })
|
||||
export default class BattleCheatRec extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
dataId: number; // 武将 ID
|
||||
|
||||
@prop({ required: true })
|
||||
type: number; // 数据类型
|
||||
|
||||
@prop({ required: true })
|
||||
iKey: number; // iKey,异或密钥
|
||||
|
||||
@prop({ required: true })
|
||||
value: number; // value,原始值备份
|
||||
|
||||
@prop({ required: true })
|
||||
secV: number; // secV,异或后的值
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 角色ID
|
||||
|
||||
@prop({ required: true })
|
||||
roleName: string; // 角色名
|
||||
|
||||
@prop({ required: true })
|
||||
code: string; // 唯一标识
|
||||
|
||||
// 创建记录
|
||||
public static async createRecord(dataId: number, type: number, iKey: number, value: number, secV: number, roleId: string, roleName: string) {
|
||||
const code = genCode(6);
|
||||
const rec: BattleCheatRecType = await BattleCheatRecModel.insertMany({ code, dataId, type, iKey, value, secV, roleId, roleName });
|
||||
return rec;
|
||||
}
|
||||
|
||||
// 获取某个玩家某个武将的记录
|
||||
public static async getRecord(roleId: string, dataId: number) {
|
||||
const query = { roleId };
|
||||
if (dataId) {
|
||||
query['dataId'] = dataId;
|
||||
}
|
||||
const recs: BattleCheatRecType[] = await BattleCheatRecModel.find(query).limit(100).lean();
|
||||
return recs;
|
||||
}
|
||||
}
|
||||
|
||||
export const BattleCheatRecModel = getModelForClass(BattleCheatRec);
|
||||
|
||||
export interface BattleCheatRecType extends Pick<DocumentType<BattleCheatRec>, keyof BattleCheatRec> { };
|
||||
export type BattleCheatRecParam = Partial<BattleCheatRecType>;
|
||||
Reference in New Issue
Block a user