热更新:handler监听热更新
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, HERO_GROW_MAX, MSG_SOURCE, JEWEL_PUSH_LV, TASK_TYPE, HERO_CE_RATIO } from "../../../consts";
|
||||
import { ItemInter } from "../../../pubUtils/interface";
|
||||
|
||||
@@ -19,6 +19,7 @@ import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, ch
|
||||
import { Attribute } from "../../../domain/roleField/attribute";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new EquipHandler(app);
|
||||
}
|
||||
|
||||
@@ -64,8 +65,8 @@ export class EquipHandler {
|
||||
if (specialMaterial.ids.includes(id)) {
|
||||
costCount++;
|
||||
cost.push({ id, seqId, count: 1 });
|
||||
for(let { jewel } of holes) {
|
||||
if(jewel > 0) jewels.push({ id: jewel, count: 1});
|
||||
for (let { jewel } of holes) {
|
||||
if (jewel > 0) jewels.push({ id: jewel, count: 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -476,8 +477,8 @@ export class EquipHandler {
|
||||
if (!goodInfo)
|
||||
return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
|
||||
let holes = equip.holes||[];
|
||||
for(let { jewel } of holes) {
|
||||
let holes = equip.holes || [];
|
||||
for (let { jewel } of holes) {
|
||||
jewels.push({ id: jewel, count: 1 });
|
||||
}
|
||||
goods = goods.concat(goodInfo.decomposeItem);
|
||||
@@ -552,7 +553,7 @@ export class EquipHandler {
|
||||
let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
if(!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let dicJob = gameData.job.get(dicHero.jobid);
|
||||
|
||||
|
||||
@@ -570,29 +571,29 @@ export class EquipHandler {
|
||||
let { ePlace, lv } = hero;
|
||||
|
||||
let curEquips: Array<{ seqId: number, hid: number }> = [];
|
||||
for(let curEPlace of ePlace) {
|
||||
if(!curEPlace.equip) { // 未装备
|
||||
for (let curEPlace of ePlace) {
|
||||
if (!curEPlace.equip) { // 未装备
|
||||
let sortAttrId = equipTypeToSortAttr.get(curEPlace.id);
|
||||
let sortedAndSuitEquips = sortEquips.filter(equipInfos => { // 筛选可穿的
|
||||
let { lvLimited, classId, ePlaceId } = equipInfos;
|
||||
return lv >= lvLimited && classId.indexOf(dicJob.job_class) != -1 && curEPlace.id == ePlaceId;
|
||||
}).sort((a, b) => { // 排序按:战力 => 根据位置看个别属性 => 品质
|
||||
if(b.ce - a.ce != 0) return b.ce - a.ce;
|
||||
let abilityA = a.goodsAbility.get(sortAttrId)||0;
|
||||
let abilityB = b.goodsAbility.get(sortAttrId)||0;
|
||||
if( abilityA - abilityB != 0) return abilityB - abilityA;
|
||||
if (b.ce - a.ce != 0) return b.ce - a.ce;
|
||||
let abilityA = a.goodsAbility.get(sortAttrId) || 0;
|
||||
let abilityB = b.goodsAbility.get(sortAttrId) || 0;
|
||||
if (abilityA - abilityB != 0) return abilityB - abilityA;
|
||||
return b.quality - a.quality;
|
||||
});
|
||||
|
||||
if(sortedAndSuitEquips.length > 0) {
|
||||
if (sortedAndSuitEquips.length > 0) {
|
||||
let { equip } = sortedAndSuitEquips.shift();
|
||||
let curEquip = await dressEquip(serverId, roleId, sid, hero,equip, funcs);
|
||||
if(!!curEquip) curEquips.push(curEquip);
|
||||
let curEquip = await dressEquip(serverId, roleId, sid, hero, equip, funcs);
|
||||
if (!!curEquip) curEquips.push(curEquip);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(curEquips.length > 0) {
|
||||
if (curEquips.length > 0) {
|
||||
//任务
|
||||
//英雄满装备且都镶嵌相同阶数的宝石
|
||||
let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero)
|
||||
@@ -878,41 +879,41 @@ export class EquipHandler {
|
||||
* @returns
|
||||
* @memberof ComBattleHandler
|
||||
*/
|
||||
async composeBlueprt(msg: { target: number, original: Array<{id: number, count: number}>}, session: BackendSession) {
|
||||
async composeBlueprt(msg: { target: number, original: Array<{ id: number, count: number }> }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const sid = session.get('sid');
|
||||
const serverId = session.get('serverId');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
|
||||
|
||||
const { target, original } = msg;
|
||||
|
||||
// 原材料检查
|
||||
let originalQuality: number, originalSum: number = 0;
|
||||
for(let {id, count} of original) {
|
||||
for (let { id, count } of original) {
|
||||
const goodInfo = gameData.goods.get(id);
|
||||
if(!originalQuality) originalQuality = goodInfo.quality;
|
||||
if(originalQuality != goodInfo.quality) {
|
||||
if (!originalQuality) originalQuality = goodInfo.quality;
|
||||
if (originalQuality != goodInfo.quality) {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
}
|
||||
|
||||
if(goodInfo.itid == IT_TYPE.BLUEPRT) {
|
||||
if (goodInfo.itid == IT_TYPE.BLUEPRT) {
|
||||
originalSum += count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const dicCompose = gameData.blurprtCompose.get(originalQuality);
|
||||
if(!dicCompose) {
|
||||
if (!dicCompose) {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_CANNOT_COMPOSE);
|
||||
}
|
||||
if(originalSum != dicCompose.blueprtNum) {
|
||||
}
|
||||
if (originalSum != dicCompose.blueprtNum) {
|
||||
return resResult(STATUS.COM_BLUEPRT_COUNT_ERROR);
|
||||
}
|
||||
|
||||
let dicTargetInfo = gameData.goods.get(target);
|
||||
if(!dicTargetInfo) return resResult(STATUS.WRONG_PARMS);
|
||||
if(dicTargetInfo.quality != dicCompose.targetQuality) return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
if (!dicTargetInfo) return resResult(STATUS.WRONG_PARMS);
|
||||
if (dicTargetInfo.quality != dicCompose.targetQuality) return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
|
||||
// 添加寻宝币
|
||||
original.push({
|
||||
@@ -922,16 +923,16 @@ export class EquipHandler {
|
||||
// 消耗藏宝图和寻宝币
|
||||
|
||||
let costResult = await handleCost(roleId, sid, original);
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
const reward = [{id: target, count: 1}];
|
||||
const reward = [{ id: target, count: 1 }];
|
||||
const goods = await addItems(roleId, roleName, sid, reward);
|
||||
if (dicCompose.targetQuality >= QUALITY_TYPE.ORANGE) {
|
||||
const { name } = gameData.goods.get(target);
|
||||
pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.ORANGE_BLUEPRT_COMPOSE, target, name);
|
||||
}
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.COM_BATTLE_BLUEPRT, 1, true, { quality: dicCompose.targetQuality });
|
||||
|
||||
|
||||
return resResult(STATUS.SUCCESS, { goods, costGold: 0 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user