给战力增加默认值防止缺少字段

This commit is contained in:
liangtongchuan
2020-12-01 11:45:19 +08:00
parent dd29d0dd44
commit 0dd3a3c931
3 changed files with 4 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ if(process.env.NODE_ENV == 'local') {
} }
// 创建 mongodb 连接 // 创建 mongodb 连接
mongoose.connect(mongoAddr, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true }, (err) => { mongoose.connect(mongoAddr, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: true }, (err) => {
if (err) { if (err) {
console.log('mongodb connect err', err); console.log('mongodb connect err', err);
} else { } else {

View File

@@ -2,7 +2,7 @@
* @Author: 梁桐川 * @Author: 梁桐川
* @Date: 2020-11-30 15:05:48 * @Date: 2020-11-30 15:05:48
* @Last Modified by: 梁桐川 * @Last Modified by: 梁桐川
* @Last Modified time: 2020-11-30 23:45:32 * @Last Modified time: 2020-12-01 11:17:04
*/ */
import { COM_BATTLE_ASSIST_TIME, COM_BATTLE_ROBOT_ROUND_LMT, COM_BATTLE_ROBOT_HURT_RATIO, COM_BATTLE_ROBOT_HURT_CH_RATIO, COM_TEAM_STATUS } from './../../../consts/consts'; import { COM_BATTLE_ASSIST_TIME, COM_BATTLE_ROBOT_ROUND_LMT, COM_BATTLE_ROBOT_HURT_RATIO, COM_BATTLE_ROBOT_HURT_CH_RATIO, COM_TEAM_STATUS } from './../../../consts/consts';
import { IT_TYPE, GOLD_COST_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_BATTLE_CAP_TIME, COM_BATTLE_TIME_LMT } from './../../../consts/consts'; import { IT_TYPE, GOLD_COST_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_BATTLE_CAP_TIME, COM_BATTLE_TIME_LMT } from './../../../consts/consts';
@@ -91,7 +91,7 @@ export class ComBattleHandler {
if (!goodData || goodData.itid !== IT_TYPE.BLUEPRT) return resResult(STATUS.COM_BATTLE_BLUEPRT_INVALID); if (!goodData || goodData.itid !== IT_TYPE.BLUEPRT) return resResult(STATUS.COM_BATTLE_BLUEPRT_INVALID);
// 检查藏宝图是否足够 // 检查藏宝图是否足够
let { lv, headHid = 19, topFiveCe, sHid = 19 } = await RoleModel.findByRoleId(roleId); let { lv, headHid = 19, topFiveCe = 100, sHid = 19 } = await RoleModel.findByRoleId(roleId);
if (lv < COM_TEAM_ENABLE_LV) return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH); if (lv < COM_TEAM_ENABLE_LV) return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH);
let blueprt = await ItemModel.findbyRoleAndGidAndCount(roleId, blueprtId, 1); let blueprt = await ItemModel.findbyRoleAndGidAndCount(roleId, blueprtId, 1);

View File

@@ -25,7 +25,7 @@ export function getRandComBtlRobots(topFiveCe: number, lv: number, cnt: number)
// 创建并添加机器人 // 创建并添加机器人
let robotStArr = [], robotIdArr = []; let robotStArr = [], robotIdArr = [];
for (let robot of robotHeroes) { for (let robot of robotHeroes) {
const robotCe = getRandValue(topFiveCe, COM_BATTLE_ROBOT_CE_RATIO, 0); const robotCe = getRandValue(topFiveCe || 0, COM_BATTLE_ROBOT_CE_RATIO, 0);
const robotLv = getRandValue(lv, COM_BATTLE_ROBOT_CE_RATIO, 0); const robotLv = getRandValue(lv, COM_BATTLE_ROBOT_CE_RATIO, 0);
const imgHid = robot[Math.floor(Math.random() * robot.length)]; const imgHid = robot[Math.floor(Math.random() * robot.length)];
const { robotRoleId, robotRoleName } = COM_BATTLE_ROBOT_ID_NAME[Math.floor(Math.random() * COM_BATTLE_ROBOT_ID_NAME.length)]; const { robotRoleId, robotRoleName } = COM_BATTLE_ROBOT_ID_NAME[Math.floor(Math.random() * COM_BATTLE_ROBOT_ID_NAME.length)];