From 7d0900c3214f376bda2a0ece345d95300891911a Mon Sep 17 00:00:00 2001 From: liangtongchuan Date: Fri, 20 Nov 2020 23:34:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BB=E5=AE=9D=E9=83=A8=E5=88=86=E5=81=87?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=94=B9=E4=B8=BA=E8=AF=BB=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/handler/comBattleHandler.ts | 18 ++++--- shared/consts/statusCode.ts | 4 +- shared/pubUtils/gamedata.ts | 50 +++++++++++++++++++ shared/pubUtils/util.ts | 1 + 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/game-server/app/servers/battle/handler/comBattleHandler.ts b/game-server/app/servers/battle/handler/comBattleHandler.ts index 754f02039..c37d98de5 100644 --- a/game-server/app/servers/battle/handler/comBattleHandler.ts +++ b/game-server/app/servers/battle/handler/comBattleHandler.ts @@ -1,12 +1,12 @@ import { IT_TYPE } from '../../../consts/consts'; -import { getGoodById } from '../../../pubUtils/gamedata'; +import { getGoodById, getBossHpByBlueprtId, getComBtlSetByQuality } from '../../../pubUtils/gamedata'; import { COM_TEAM_STATUS, COM_TEAM_ENABLE_LV } from '../../../consts/consts'; -import { ComBattleTeamModel } from './../../../db/ComBattleTeam'; -import Role, { RoleModel } from './../../../db/Role'; +import { ComBattleTeamModel } from '../../../db/ComBattleTeam'; +import Role, { RoleModel } from '../../../db/Role'; import { STATUS } from '../../../consts/statusCode'; import { Application, BackendSession } from 'pinus'; import { resResult } from '../../../pubUtils/util'; -import { RoleStatus } from './../../../db/ComBattleTeam'; +import { RoleStatus } from '../../../db/ComBattleTeam'; export default function(app: Application) { return new ComBattleHandler(app); @@ -67,8 +67,7 @@ export class ComBattleHandler { comTeam.roleIds = [roleId]; comTeam.status = COM_TEAM_STATUS.DEFAULT; comTeam.ceLimit = ceLimit; - // TODO: boss 血量读表 - comTeam.bossHp = 10000; + comTeam.bossHp = getBossHpByBlueprtId(blueprtId) || 10000; let roleStatus = new RoleStatus(); roleStatus.heroes = heroes; @@ -97,17 +96,20 @@ export class ComBattleHandler { async joinTeam(msg: {teamCode: string, isFrd: boolean}, session: BackendSession) { let roleId = session.get('roleId'); - let roleName = session.get('roleName'); let sid = session.get('sid'); console.log('teamMap:' + JSON.stringify(this.teamMap)); let { teamCode, isFrd } = msg; let teamStatus = this.teamMap.get(teamCode); if (!teamStatus || teamStatus.status !== 0 || teamStatus.roleIds.length === 3) return resResult(STATUS.COM_BATTLE_MEMBER_LIMIT); if (teamStatus.roleIds.indexOf(roleId) !== -1) return resResult(STATUS.COM_BATTLE_DUP_ENTER); - // TODO:助战等级限制,等表 + // TODO: 助战次数限制 let { lv, headHid, topFiveCe } = await Role.findByRoleId(roleId); + let { quality } = getGoodById(teamStatus.blueprtId); + let { assistanceLevel } = getComBtlSetByQuality(quality); if (lv < COM_TEAM_ENABLE_LV) { return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH); + } else if (lv < assistanceLevel) { + return resResult(STATUS.COM_BATTLE_ASSIST_LV_NOT_ENOUGH); } else if (topFiveCe < teamStatus.ceLimit) { return resResult(STATUS.COM_BATTLE_CE_LIMIT); } diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index 7bff2b56b..e7244d292 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -86,7 +86,9 @@ export const STATUS = { COM_BATTLE_TEAM_NO_READY: { code: 20614, simStr: '队友未准备好' }, COM_BATTLE_RESULT_ERR: { code: 20615, simStr: '结算信息更新失败' }, COM_BATTLE_NOT_START: { code: 20616, simStr: '寻宝未开始' }, - COM_BATTLE_ALREADY_START: { code: 20616, simStr: '寻宝已开始' }, + COM_BATTLE_ALREADY_START: { code: 20617, simStr: '寻宝已开始' }, + COM_BATTLE_ASSIST_NOT_ENOUGH: { code: 20618, simStr: '助战次数不足' }, + COM_BATTLE_ASSIST_LV_NOT_ENOUGH: { code: 20618, simStr: '助阵等级不够' }, // 秘境 20700 - 20799 DUNGEON_REFRESH_TIMES_LACK: { code: 20701, simStr: '购买次数不足' }, diff --git a/shared/pubUtils/gamedata.ts b/shared/pubUtils/gamedata.ts index c27a01cef..fd030c1f8 100644 --- a/shared/pubUtils/gamedata.ts +++ b/shared/pubUtils/gamedata.ts @@ -1,6 +1,7 @@ import fs = require('fs'); import path = require('path'); import { ABI_TYPE } from '../consts/abilityConst'; +import { decodeIdCntArrayStr } from './util'; let gamedata = {}; const wars = ['dic_zyz_gk_main', 'dic_zyz_gk_mainElite', 'dic_zyz_gk_daily', 'dic_zyz_gk_event', 'dic_zyz_gk_tower', 'dic_zyz_gk_expedition', 'dic_zyz_gk_dungeon','dic_zyz_gk_dungeonElite']; // 关卡相关的表 @@ -15,6 +16,9 @@ const heroSkillInfo = new Map() const seidInfo = new Map(); const olySeidInfo = new Map(); const expeditionInfo = new Map (); +const comBtlInfo = new Map(); +const btlBossHp = new Map(); +const blueprtBossHp = new Map(); function parseWarData() { let result = null; @@ -176,6 +180,15 @@ function parseExpedition() { } +function parseComBtlData() { + const file = 'dic_zyz_xunbao'; + const data = gamedata['jsons'][file] || []; + data.forEach(elem => { + if (elem && elem.quality) { + comBtlInfo.set(elem.quality, elem); + } + }); +} function initData (folder: string) { if(!gamedata.hasOwnProperty(folder)) { @@ -213,6 +226,7 @@ function parseData() { parseSeidList(); parseOlySeidList(); parseExpedition(); + parseComBtlData(); } initData('jsons'); // 加载一般json @@ -301,6 +315,42 @@ export function getExpeditionById(id: number) { return expeditionInfo.get(id); } +export function getComBtlSetByQuality(quality: number) { + return comBtlInfo.get(quality); +} + +export function getBossHpByWarId(warId: number) { + let bossHp = btlBossHp.get(warId) || 0; + if (!bossHp) { + const warInfo = getWarJsons(warId).json; + if (warInfo && warInfo.length) { + warInfo.forEach(hero => { + if (hero.relation === 2) { + let { attribute } = hero; + let attriData = decodeIdCntArrayStr(attribute, 1); + const hp = parseInt(attriData.get('1')); + if (hp > 0) { + bossHp += hp; + } + } + }) + } + btlBossHp.set(warId, bossHp); + } + return bossHp; +} + +export function getBossHpByBlueprtId(blueprtId: number) { + let bossHp = blueprtBossHp.get(blueprtId) || 0; + if (!bossHp) { + const { specialAttr } = getGoodById(blueprtId); + const attrData = decodeIdCntArrayStr(specialAttr, 1); + const warId = parseInt(attrData.get('1')); + bossHp = getBossHpByWarId(warId); + blueprtBossHp.set(blueprtId, bossHp); + } + return bossHp; +} export function hasExpeditionById(id: number) { return expeditionInfo.has(id); } \ No newline at end of file diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index da9324689..2380e9a67 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -123,6 +123,7 @@ export function decodeArrayStr(str: string, splitForm='|') { */ export function decodeIdCntArrayStr(str: string, multi: number) { const strArr = decodeArrayStr(str); + console.log('decodeIdCntArrayStr: ', strArr); const strMap = new Map(); strArr.forEach(item => { const kv = item.split('&');