✨ feat(battle): 保存战场校验异常的数据
This commit is contained in:
@@ -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: '关卡信息不同' },
|
||||
|
||||
@@ -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