Merge branch 'statusCode' of gitlab.trgame.cn:zyztech/zyz_server
Conflicts: game-server/app/servers/battle/handler/eventBattleHandler.ts
This commit is contained in:
@@ -4,20 +4,63 @@ export const STATUS = {
|
||||
WRONG_PARMS: { code: 1, simStr: '参数错误' },
|
||||
TOKEN_ERR: { code: 2, simStr: 'token失效' },
|
||||
INTERNAL_ERR: { code: 3, simStr: '内部错误' },
|
||||
CONNECTOR_ERR: { code: 4, simStr: '连接服配置错误'},
|
||||
// 账号相关状态 10000 - 19999
|
||||
SMS_IN_60S: { code: 10001, simStr: '60秒内只能发送一次' },
|
||||
SMS_CNT_LIMIT: { code: 10002, simStr: '今日短信条数已达上限' },
|
||||
SMS_INVALID: { code: 10003, simStr: '验证码无效' },
|
||||
SERVER_NOT_FOUND: { code: 10004, simStr: '未找到服务器列表' },
|
||||
ROLE_NOT_FOUND: { code: 10005, simStr: '未找到角色' },
|
||||
DUP_LOGIN: { code: 10006, simStr: '重复登录' },
|
||||
// 战斗相关状态 20000 - 29999
|
||||
// 战斗通用 20000 - 20099
|
||||
BATTLE_MISS_INFO: { code: 20001, simStr: '缺少关卡信息' },
|
||||
BATTLE_ACTION_POINT_LACK: { code: 20002, simStr: '体力不足' },
|
||||
BATTLE_NEED_PREVIOUS_GK: { code: 20003, simStr: '需要完成上一关才可以挑战' },
|
||||
BATTLE_ID_NOT_MATCH: { code: 20004, simStr: '战斗数据错误' },
|
||||
BATTLE_STATUS_WRONG: { code: 20005, simStr: '关卡状态错误' },
|
||||
|
||||
// 主线 20100 - 20199
|
||||
BATTLE_INFO_VALIDATE_ERR: { code: 20101, simStr: '关卡信息不同' },
|
||||
BATTLE_SWEEP_CONDITION_STAR: { code: 20102, simStr: '需要3星通过关卡才可以扫荡' },
|
||||
// 每日 20200 - 20299
|
||||
DAILY_WAR_NOT_FOUND: { code: 20201, simStr: '未找到该关卡' },
|
||||
DAILY_TYPE_NOT_FOUND: { code: 20202, simStr: '未找到该类型' },
|
||||
DAILY_TIMES_LACK: { code: 20203, simStr: '次数不足' },
|
||||
// 奇遇 20300 - 20399
|
||||
EVENT_RECORD_NOT_FOUND: { code: 20301, simStr: '未找到记录' },
|
||||
EVENT_STATUS_ERROR: { code: 20302, simStr: '状态错误' },
|
||||
EVENT_WRONG_ID: { code: 20303, simStr: '事件id错误' },
|
||||
EVENT_INFO_NOT_FOUND: { code: 20304, simStr: '未找到该事件' },
|
||||
// 远征 20400 - 20499
|
||||
EXPEDITION_MATCH_NO_PLAYER: { code: 20401, simStr: '无法匹配对手' },
|
||||
EXPEDITION_MISS_WAR_RECORD: { code: 20402, simStr: '未找到该远征记录' },
|
||||
EXPEDITION_DUPLICATE_CHALLENGE: { code: 20403, simStr: '已挑战过这一关' },
|
||||
EXPEDITION_WRONG_STATUS_WHEN_RECEIVE: { code: 20404, simStr: '需要战斗胜利后才可以领取' },
|
||||
EXPEDITION_WRONG_RECEIVE_STATUS: { code: 20405, simStr: '已经领取过了' },
|
||||
EXPEDITION_MISS_INFO: { code: 20406, simStr: '未找到该配置' },
|
||||
EXPEDITION_MISS_POINT_INFO: { code: 20407, simStr: '该点数不能领取奖励' },
|
||||
EXPEDITION_POINT_NOT_ENOUGH: { code: 20408, simStr: '点数不足' },
|
||||
EXPEDITION_POINT_RECORD_NOT_FOUND: { code: 20409, simStr: '点数宝箱已刷新' },
|
||||
EXPEDITION_POINT_NEED_ALL_RECEIVED: { code: 20410, simStr: '宝箱需要领取完才可以刷新' },
|
||||
// 天梯 20500 - 20599
|
||||
TOWER_RESET_ERR: { code: 20501, simStr: '只能重置当前层' }
|
||||
TOWER_RESET_ERR: { code: 20501, simStr: '只能重置当前层' },
|
||||
TOWER_INFO_NOT_FOUND: { code: 20502, simStr: '天梯层数异常' },
|
||||
TOWER_WRONG_BATTLE_ID: { code: 20503, simStr: '战斗 Id 异常' },
|
||||
TOWER_DUPLICATE_HERO: { code: 20504, simStr: '使用了重复的武将' },
|
||||
TOWER_DUPLICATE_CHALLENGE: { code: 20505, simStr: '天梯关卡不能重复挑战' },
|
||||
TOWER_NOT_FOUND: { code: 20506, simStr: '没有找到合适的天梯记录' },
|
||||
TOWER_HANG_UP_NOT_VALID: { code: 20507, simStr: '尚未到可收取时间' },
|
||||
TOWER_NOT_ENOUGH_HANG_UP_TIME: { code: 20508, simStr: '今日加速次数不足' },
|
||||
TOWER_HANG_UP_FAILED: { code: 20509, simStr: '不满足加速条件' },
|
||||
TOWER_TASK_NOT_FOUND: { code: 20510, simStr: '没有可用派遣任务' },
|
||||
TOWER_TASK_MAX_HERO: { code: 20511, simStr: '超过派遣武将最大人数' },
|
||||
TOWER_TASK_HERO_HAS_USED: { code: 20512, simStr: '武将已经派遣到其他任务' },
|
||||
TOWER_TASK_CODE_NOT_FOUND: { code: 20513, simStr: '未找到此任务编号' },
|
||||
TOWER_TASK_SEND_ERR: { code: 20514, simStr: '任务派遣失败,请检查任务编号' },
|
||||
TOWER_TASK_BATCH_NOT_FOUND: { code: 20515, simStr: '派遣编码错误' },
|
||||
// 共斗 20600 - 20699
|
||||
COM_BATTLE_DUP_ENTER: { code: 20601, simStr: '不能重复加入' },
|
||||
// 养成相关状态 30000 - 39999
|
||||
// 社交相关状态 40000 - 49999
|
||||
// 运营模块相关状态 50000 - 59999
|
||||
|
||||
@@ -3,6 +3,9 @@ import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
|
||||
class ServerInfo {
|
||||
@prop({ required: true })
|
||||
id: number;
|
||||
|
||||
@prop({ required: true })
|
||||
name: string;
|
||||
|
||||
@@ -55,7 +58,7 @@ export default class Game extends BaseModel {
|
||||
public static async getServerListByType(serverType: string) {
|
||||
let game = await GameModel.findOne().lean();
|
||||
if (!game) {
|
||||
const serverInfo: ServerInfo = { name: '常山少年', host: 'pinus_test.trgame.cn', port: 3014, status: 1, createTime: new Date(), serverType: 'official' };
|
||||
const serverInfo: ServerInfo = { id: 1, name: '常山少年', host: 'pinus_test.trgame.cn', port: 3014, status: 1, createTime: new Date(), serverType: 'official' };
|
||||
const iconUrl = `https://download.tgamebox.cn/avatar/${APP_ID}/1.png`;
|
||||
game = await GameModel.findOneAndUpdate(
|
||||
{},
|
||||
|
||||
@@ -48,14 +48,15 @@ export default class Sms extends BaseModel {
|
||||
}
|
||||
|
||||
public async cntLimit(cnt: number) {
|
||||
console.log('hasSendToday:', this.hasSendToday());
|
||||
if (await this.hasSendToday() && this.countToday >= cnt) {
|
||||
console.log('hasSendToday:', this.hasSendToday(), this.countToday, cnt);
|
||||
if (this.hasSendToday() && this.countToday >= cnt) {
|
||||
return true;
|
||||
}
|
||||
this.countToday = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public async hasSendToday() {
|
||||
public hasSendToday() {
|
||||
console.log(moment(this.updateTime).format('YYYY-MM-DD'), moment(Date.now()).format('YYYY-MM-DD'));
|
||||
return moment(this.updateTime).format('YYYY-MM-DD') === moment(Date.now()).format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { COUNTER } from './../consts/consts';
|
||||
import { CounterModel } from './Counter';
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
|
||||
/**
|
||||
* 用户字段接口
|
||||
@@ -16,6 +17,9 @@ export default class User extends BaseModel {
|
||||
@prop({ required: true })
|
||||
username: string;
|
||||
|
||||
@prop({ required: true })
|
||||
userCode: string; // 用户唯一字符串标识
|
||||
|
||||
@prop({ required: true })
|
||||
token: string;
|
||||
|
||||
@@ -65,8 +69,9 @@ export default class User extends BaseModel {
|
||||
let update = {};
|
||||
if (!user) {
|
||||
const uid = await CounterModel.getNewCounter(COUNTER.UID);
|
||||
const userCode = genCode(8);
|
||||
const doc = new UserModel();
|
||||
update = Object.assign(update, { platform, pkgName, serverType, createTime: curTime, uid, username: `用户${uid}` }, doc.toJSON());
|
||||
update = Object.assign(update, { platform, pkgName, serverType, createTime: curTime, uid, userCode, username: `用户${uid}` }, doc.toJSON());
|
||||
}
|
||||
update = Object.assign(update, { token, lastLoginTime: curTime });
|
||||
user = await UserModel.findOneAndUpdate({ tel }, update, { upsert: true, new: true }).lean(lean);
|
||||
|
||||
@@ -33,37 +33,37 @@ const moment = require('moment');
|
||||
switch (type) {
|
||||
case 'fixReward': {
|
||||
let [gid, count] = arr;
|
||||
if(isNaN(gid) || isNaN(count)) throw new Error('格式错误');
|
||||
if(isNaN(gid) || isNaN(count)) throw new Error('data table format wrong');
|
||||
result = { gid: parseInt(gid), count: parseInt(count)};
|
||||
break;
|
||||
}
|
||||
case 'conditionReward': {
|
||||
let [gid, count, condition] = arr;
|
||||
if(isNaN(gid) || isNaN(count)) throw new Error('格式错误');
|
||||
if(isNaN(gid) || isNaN(count)) throw new Error('data table format wrong');
|
||||
result = { gid: parseInt(gid), count: parseInt(count), condition: parseInt(condition) };
|
||||
break;
|
||||
}
|
||||
case 'randomReward': {
|
||||
let [gid, count, frequency] = arr;
|
||||
if(isNaN(gid) || isNaN(count)) throw new Error('格式错误');
|
||||
if(isNaN(gid) || isNaN(count)) throw new Error('data table format wrong');
|
||||
result = { gid: parseInt(gid), count: parseInt(count), frequency: parseInt(frequency) };
|
||||
break;
|
||||
}
|
||||
case 'eventSuitLevel': {
|
||||
let [min, max] = arr;
|
||||
if(isNaN(min) || isNaN(max)) throw new Error('格式错误');
|
||||
if(isNaN(min) || isNaN(max)) throw new Error('data table format wrong');
|
||||
result = { min: parseInt(min), max: parseInt(max) };
|
||||
break;
|
||||
}
|
||||
case 'attribute': {
|
||||
let [id, value] = arr;
|
||||
if(isNaN(id) || isNaN(value)) throw new Error('格式错误');
|
||||
if(isNaN(id) || isNaN(value)) throw new Error('data table format wrong');
|
||||
result = { id: parseInt(id), value: parseInt(value) };
|
||||
break;
|
||||
}
|
||||
case 'position': {
|
||||
let [x, y] = arr;
|
||||
if(isNaN(x) || isNaN(y)) throw new Error('格式错误');
|
||||
if(isNaN(x) || isNaN(y)) throw new Error('data table format wrong');
|
||||
result = { x: parseInt(x), y: parseInt(y) };
|
||||
break;
|
||||
}
|
||||
@@ -184,5 +184,8 @@ export function getRandEelm(source: Array<any> = [], cnt = 1): Array<any> {
|
||||
|
||||
export function resResult(status: {code: number, simStr: string}, data = null, customMsg = '') {
|
||||
const { code, simStr } = status;
|
||||
if (code !== STATUS.SUCCESS.code) {
|
||||
console.log(`normal err, code: ${code}, des: ${customMsg || simStr}`);
|
||||
}
|
||||
return {code, msg: customMsg || simStr, data};
|
||||
}
|
||||
Reference in New Issue
Block a user