主线,每日,奇遇,远征修改错误码
This commit is contained in:
@@ -11,6 +11,8 @@ import { EXPEDITION_INCREASE_POINT } from '../../../consts/consts';
|
||||
import { WarReward } from '../../../services/warRewardService';
|
||||
import { handleFixedReward } from '../../../services/rewardService';
|
||||
import { getAp, setAp } from '../../../services/actionPointService';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new ExpeditionBattleHandler(app);
|
||||
@@ -50,16 +52,13 @@ export class ExpeditionBattleHandler {
|
||||
// 点数,和宝箱领取状态
|
||||
let pointRewards = await getPointRewardStatus(roleId);
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
expeditionCode,
|
||||
curLv,
|
||||
expeditionWarRecord,
|
||||
pointRewards,
|
||||
heroes
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +93,7 @@ export class ExpeditionBattleHandler {
|
||||
flag = await matchRobots(scale, myCe, curDicExpedition.ce, curDicExpedition.json, lv, enemyObj);
|
||||
}
|
||||
if(!flag) {
|
||||
return {code: 202, data:'无法匹配对手'};
|
||||
return resResult(STATUS.EXPEDITION_MATCH_NO_PLAYER);
|
||||
}
|
||||
// 保存
|
||||
let {warId} = curDicExpedition;
|
||||
@@ -104,15 +103,12 @@ export class ExpeditionBattleHandler {
|
||||
}
|
||||
|
||||
let { battleId, enemyFrom, enemies, battleStatus } = expeditionWarRecord;
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
expeditionCode, expeditionId, battleId,
|
||||
battleStatus,
|
||||
enemyFrom,
|
||||
enemies
|
||||
}
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
expeditionCode, expeditionId, battleId,
|
||||
battleStatus,
|
||||
enemyFrom,
|
||||
enemies
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,28 +121,28 @@ export class ExpeditionBattleHandler {
|
||||
let roleName = session.get('roleName');
|
||||
let warInfo = getWarById(battleId);
|
||||
if(!warInfo) {
|
||||
return { code: 202, data: "缺少关卡信息" }
|
||||
return resResult(STATUS.BATTLE_MISS_INFO);
|
||||
}
|
||||
|
||||
let apJson = await getAp(Date.now(), roleId);
|
||||
let {ap} = apJson;
|
||||
if(ap < warInfo.cost) {
|
||||
return { code: 202, data: "体力不足" }
|
||||
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
|
||||
}
|
||||
|
||||
// 前置关卡是否挑战过
|
||||
let previousGk = warInfo.previousGk;
|
||||
if(previousGk) {
|
||||
let preBattle = await BattleRecordModel.getBattleRecordByIdAndStatus(roleId, previousGk, 1);
|
||||
if(!preBattle) return {code: 202, data: '需要完成上一关才可以挑战'};
|
||||
if(!preBattle) return resResult(STATUS.BATTLE_NEED_PREVIOUS_GK);
|
||||
}
|
||||
|
||||
let expeditionWarRecord = await ExpeditionWarRecordModel.getRecordByCodeAndId(expeditionCode, expeditionId);
|
||||
if(!expeditionWarRecord ) {
|
||||
return {code: 202, data: '需要先匹配好对手'}
|
||||
return resResult(STATUS.EXPEDITION_MISS_WAR_RECORD);
|
||||
}
|
||||
if(expeditionWarRecord.battleStatus == 1) {
|
||||
return {code: 202, data: '已挑战过这一关'}
|
||||
return resResult(STATUS.EXPEDITION_DUPLICATE_CHALLENGE);
|
||||
}
|
||||
|
||||
const battleCode = genCode(8);
|
||||
@@ -162,17 +158,14 @@ export class ExpeditionBattleHandler {
|
||||
|
||||
let result = await ExpeditionWarRecordModel.updateStatus(expeditionCode, expeditionId, 0, battleCode);
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
expeditionCode,
|
||||
expeditionId,
|
||||
battleId,
|
||||
battleCode,
|
||||
battleStatus: result.battleStatus,
|
||||
apJson
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +180,7 @@ export class ExpeditionBattleHandler {
|
||||
|
||||
let warInfo = getWarById(battleId);
|
||||
if(!warInfo) {
|
||||
return { code: 202, data: "缺少关卡信息" }
|
||||
return resResult(STATUS.BATTLE_MISS_INFO);
|
||||
}
|
||||
if(!warInfo.hasOwnProperty('cost')) {
|
||||
warInfo['cost'] = 0;
|
||||
@@ -195,7 +188,7 @@ export class ExpeditionBattleHandler {
|
||||
|
||||
const BattleRecord = await BattleRecordModel.getBattleRecordByCode(battleCode);
|
||||
if(!BattleRecord || BattleRecord.status != 0) {
|
||||
return { code: 202, data: '关卡状态错误' }
|
||||
return resResult(STATUS.BATTLE_STATUS_WRONG);
|
||||
}
|
||||
|
||||
let flag = 1; // 对比hero信息
|
||||
@@ -204,20 +197,20 @@ export class ExpeditionBattleHandler {
|
||||
if(dbHeroes.indexOf(actorId) == -1) flag = 0;
|
||||
}
|
||||
if(!flag) {
|
||||
return { code: 202, data: '关卡信息不同' }
|
||||
return resResult(STATUS.BATTLE_INFO_VALIDATE_ERR);
|
||||
}
|
||||
|
||||
const now = Date.now(); // 当前时间戳
|
||||
let apJson = await setAp(now, roleId, -1 * warInfo.cost); // 扣除体力
|
||||
if(!apJson) {
|
||||
return { code: 202, data: '体力不足' }
|
||||
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
|
||||
}
|
||||
|
||||
// 检查record
|
||||
let expeditionRecord = await ExpeditionRecordModel.getExpeditionRecordByCode(expeditionCode);
|
||||
let expeditionWarRecord = await ExpeditionWarRecordModel.getRecordByCodeAndId(expeditionCode, expeditionId);
|
||||
if(!expeditionRecord|| !expeditionWarRecord) {
|
||||
return { code: 202, data:'未找到该记录' }
|
||||
return resResult(STATUS.EXPEDITION_MISS_WAR_RECORD);
|
||||
}
|
||||
// 更新我方剩余血量
|
||||
await ExpeditionRecordModel.updateHeroStatus(expeditionCode, expeditionRecord.heroes, heroes);
|
||||
@@ -235,17 +228,14 @@ export class ExpeditionBattleHandler {
|
||||
let warReward = new WarReward(roleId, roleName, battleId, isSuccess);
|
||||
let reward = await warReward.saveReward(1);
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
expeditionCode, expeditionId,
|
||||
battleCode, battleId,
|
||||
battleStatus: expeditionWarRecord.battleStatus,
|
||||
goods: reward,
|
||||
apJson,
|
||||
expeditionPoint
|
||||
}
|
||||
}
|
||||
expeditionPoint
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,19 +250,19 @@ export class ExpeditionBattleHandler {
|
||||
// 检查expeditionWarRecord的battleStatus
|
||||
let expeditionWarRecord = await ExpeditionWarRecordModel.getRecordByCodeAndId(expeditionCode, expeditionId);
|
||||
if(!expeditionWarRecord) {
|
||||
return {code: 202, data: '未找到该关卡'}
|
||||
return resResult(STATUS.EXPEDITION_MISS_WAR_RECORD);
|
||||
}
|
||||
if(expeditionWarRecord.battleStatus != 1) {
|
||||
return {code: 202, data: '需要战斗胜利后才可以领取'}
|
||||
return resResult(STATUS.EXPEDITION_WRONG_STATUS_WHEN_RECEIVE);
|
||||
}
|
||||
if(expeditionWarRecord.received) {
|
||||
return {code: 202, data: '已经领取过了'}
|
||||
return resResult(STATUS.EXPEDITION_WRONG_RECEIVE_STATUS);
|
||||
}
|
||||
// 设置expeditionWarRecord的received和rewards
|
||||
let dicExpedition = getGamedata('dic_expedition');
|
||||
let curDicExpedition = dicExpedition.find(cur => cur.id == expeditionId);
|
||||
if(!curDicExpedition) {
|
||||
return {code: 202, data: '未找到该配置'}
|
||||
return resResult(STATUS.EXPEDITION_MISS_INFO);
|
||||
}
|
||||
|
||||
let result = await ExpeditionWarRecordModel.updateBoxStatus(expeditionCode, expeditionId, true, curDicExpedition.reward);
|
||||
@@ -280,14 +270,11 @@ export class ExpeditionBattleHandler {
|
||||
// 获取东西
|
||||
let goods = await handleFixedReward(roleId, roleName, curDicExpedition.reward, 1);
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
expeditionCode, expeditionId,
|
||||
battleId, battleCode, battleStatus, received,
|
||||
goods
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -306,18 +293,18 @@ export class ExpeditionBattleHandler {
|
||||
let dicExpeditionPoint = getGamedata('dic_expedition_point');
|
||||
let curDicExpeditionPoint = dicExpeditionPoint.find(cur => cur.point == point);
|
||||
if(!curDicExpeditionPoint) {
|
||||
return {code: 202, data: '该点数不能领取奖励'}
|
||||
return resResult(STATUS.EXPEDITION_MISS_POINT_INFO);
|
||||
}
|
||||
|
||||
if(point > expeditionPoint) {
|
||||
return {code: 202, data: '点数不足'};
|
||||
return resResult(STATUS.EXPEDITION_POINT_NOT_ENOUGH);
|
||||
}
|
||||
let pointStatusInDatabase = await ExpeditionPointModel.getExpeditionPoint(roleId);
|
||||
if(pointStatusInDatabase) {
|
||||
let {rewards} = pointStatusInDatabase;
|
||||
let curReward = rewards.find(cur => cur.point == point);
|
||||
if(curReward && curReward.received) {
|
||||
return {code: 202, data: '已领取过'}
|
||||
return resResult(STATUS.EXPEDITION_WRONG_RECEIVE_STATUS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,13 +313,10 @@ export class ExpeditionBattleHandler {
|
||||
let pointRewards = await getPointRewardStatus(roleId);
|
||||
let goods = await handleFixedReward(roleId, roleName, curDicExpeditionPoint.reward, 1);
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
pointRewards,
|
||||
goods
|
||||
}
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
pointRewards,
|
||||
goods
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,7 +330,7 @@ export class ExpeditionBattleHandler {
|
||||
|
||||
let pointStatusInDatabase = await ExpeditionPointModel.getExpeditionPoint(roleId);
|
||||
if(!pointStatusInDatabase) {
|
||||
return {code: 202, data: '已刷新'}
|
||||
return resResult(STATUS.EXPEDITION_POINT_RECORD_NOT_FOUND);
|
||||
}
|
||||
let { rewards } = pointStatusInDatabase;
|
||||
let dicExpeditionPoint = getGamedata('dic_expedition_point');
|
||||
@@ -359,7 +343,7 @@ export class ExpeditionBattleHandler {
|
||||
if(dic.point > maxPoint) maxPoint = dic.point;
|
||||
}
|
||||
if(!flag) {
|
||||
return {code: 202, data: '宝箱需要领取完才可以刷新'}
|
||||
return resResult(STATUS.EXPEDITION_POINT_NEED_ALL_RECEIVED);
|
||||
}
|
||||
|
||||
// 刷新
|
||||
@@ -368,11 +352,8 @@ export class ExpeditionBattleHandler {
|
||||
|
||||
let pointRewards = await getPointRewardStatus(roleId);
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
pointRewards
|
||||
}
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
pointRewards
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user