寻宝:增加 boss 返回字段;修改领取奖励更新
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
* @Author: 梁桐川
|
||||
* @Date: 2020-11-30 15:05:48
|
||||
* @Last Modified by: 梁桐川
|
||||
* @Last Modified time: 2020-12-02 17:33:14
|
||||
* @Last Modified time: 2020-12-02 21:05:48
|
||||
*/
|
||||
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, COM_BATTLE_CAP_START_TIME, COM_BATTLE_ASSIST_REWARD_RATIO } from './../../../consts/consts';
|
||||
import { getGoodById, getBossHpByBlueprtId, getComBtlSetByQuality, getBlueprtComposeByQuality, getBluePrtByQuality, getWarById, getWarIdByBlueprtId } from '../../../pubUtils/gamedata';
|
||||
import { COM_TEAM_ENABLE_LV } from '../../../consts/consts';
|
||||
import { ComBattleTeamModel } from '../../../db/ComBattleTeam';
|
||||
import { ComBattleTeamModel, BossHp } from '../../../db/ComBattleTeam';
|
||||
import Role, { RoleModel } from '../../../db/Role';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
@@ -48,14 +48,14 @@ class ComTeam {
|
||||
// boss 当前血量
|
||||
bossCurHp: number;
|
||||
// 单个 boss 血量状态
|
||||
bossHpArr: Array<{dataId: number, hp: number, curHp: number}>;
|
||||
bossHpArr: Array<BossHp>;
|
||||
// 品质
|
||||
quality: number;
|
||||
// 当前回合
|
||||
curRnd: number;
|
||||
// 队伍中人数
|
||||
roleCnt: number;
|
||||
constructor(teamCode: string, pub: boolean, blueprtId: number, status: number, capId: string, ceLimit: number, bossHp: number, quality: number, bossHpArr:Array<{dataId: number, hp: number, curHp: number}> ) {
|
||||
constructor(teamCode: string, pub: boolean, blueprtId: number, status: number, capId: string, ceLimit: number, bossHp: number, quality: number, bossHpArr:Array<BossHp> ) {
|
||||
this.teamCode = teamCode;
|
||||
this.pub = pub;
|
||||
this.blueprtId = blueprtId;
|
||||
@@ -170,7 +170,7 @@ export class ComBattleHandler {
|
||||
channel.pushMessage('onTeamJoin', {teamInfo: team});
|
||||
}
|
||||
// TODO: 代码抽象
|
||||
if (team.roleIds && team.roleIds.length === 3) {
|
||||
if (team && team.roleIds && team.roleIds.length === 3) {
|
||||
let timer = setTimeout(async () => {
|
||||
thiz.dismiss({teamCode}, session);
|
||||
}, COM_BATTLE_CAP_START_TIME);
|
||||
@@ -503,7 +503,7 @@ export class ComBattleHandler {
|
||||
let thiz = this;
|
||||
setTimeout(async () => {
|
||||
let teamStatus = thiz.teamMap.get(teamCode);
|
||||
if (teamStatus.status === COM_TEAM_STATUS.FIGHTING) {
|
||||
if (teamStatus && teamStatus.status === COM_TEAM_STATUS.FIGHTING) {
|
||||
let channelService = thiz.app.get('channelService');
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
let team = await ComBattleTeamModel.syncTeamData({teamCode, status: COM_TEAM_STATUS.LOOSE, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr});
|
||||
@@ -672,11 +672,19 @@ export class ComBattleHandler {
|
||||
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
|
||||
}
|
||||
|
||||
await ComBattleTeamModel.updateRewardSt(roleId, true);
|
||||
await ComBattleTeamModel.updateRewardSt(teamCode, roleId, true);
|
||||
const goods = await handleFixedReward(roleId, roleName, roleSt.fixReward, 1);
|
||||
let actordata = await roleLevelup(roleId, warInfo.kingExp, this.app, session);// 主公升级经验
|
||||
|
||||
return resResult(STATUS.SUCCESS, { ...goods, ...actordata, teamInfo: {status, roleStatus, bossHpArr} });
|
||||
return resResult(STATUS.SUCCESS, { ...goods, ...actordata, teamInfo: {status, teamCode, roleStatus, bossHpArr} });
|
||||
}
|
||||
|
||||
async getComBtlStatus(msg: {teamCode: string}, session: BackendSession) {
|
||||
let { teamCode } = msg;
|
||||
let team = await ComBattleTeamModel.getTeamByCode(teamCode);
|
||||
let { roleStatus, status, bossHpArr } = team;
|
||||
|
||||
return resResult(STATUS.SUCCESS, { teamInfo: {status, teamCode, roleStatus, bossHpArr} });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -379,7 +379,7 @@ export function getRandRobot(cnt = 1, withAttr = false) {
|
||||
* 拷贝敌军数组并添加当前血量字段
|
||||
* @param source 原敌军数组,不包含当前血量字段
|
||||
*/
|
||||
export function transBossHpArr(source: Array<{dataId: number, hp: number}>): Array<{dataId: number, hp: number, curHp: number}> {
|
||||
export function transBossHpArr(source: Array<{dataId: number, hp: number, actorId: number}>): Array<{dataId: number, hp: number, curHp: number, actorId: number}> {
|
||||
let desArr = [];
|
||||
source.forEach(elem => {
|
||||
let { hp } = elem;
|
||||
|
||||
@@ -100,7 +100,7 @@ export async function checkComBattleDrop(roleId: string, battleCode: string) {
|
||||
fixReward = ratioReward(fixReward, COM_BATTLE_ASSIST_REWARD_RATIO);
|
||||
}
|
||||
}
|
||||
await ComBattleTeamModel.updateRewardSt(roleId, true);
|
||||
await ComBattleTeamModel.updateRewardSt(team.teamCode, roleId, true);
|
||||
return {status: 0, fixReward};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user