@@ -1,5 +1,5 @@
|
||||
import { Application, BackendSession } 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 } from "../../../consts";
|
||||
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";
|
||||
|
||||
import { resResult, parseGoodStr, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
|
||||
@@ -10,12 +10,13 @@ import Role from "../../../db/Role";
|
||||
import { calPlayerCeAndSave } from "../../../services/playerCeService";
|
||||
import { getHeroJob, getGoodById, gameData, getHeroEquipByClassId } from "../../../pubUtils/data";
|
||||
import { EQUIP } from "../../../pubUtils/dicParam";
|
||||
import { ITID, SPEICAL_ITEM, QUALITY_TYPE } from "../../../consts/constModules/itemConst";
|
||||
import { ITID, SPEICAL_ITEM, QUALITY_TYPE, equipTypeToSortAttr } from "../../../consts/constModules/itemConst";
|
||||
import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe } from "../../../services/equipService";
|
||||
|
||||
import { indexOf, findIndex } from 'underscore';
|
||||
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
|
||||
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, checkTaskConditionEquipSuitJewelStage, checkActivityTask } from "../../../services/taskService";
|
||||
import { Attribute } from "../../../domain/roleField/attribute";
|
||||
|
||||
export default function (app: Application) {
|
||||
return new EquipHandler(app);
|
||||
@@ -528,6 +529,66 @@ export class EquipHandler {
|
||||
return resResult(STATUS.SUCCESS, { curEquips: curEquips });
|
||||
}
|
||||
|
||||
// 一次性装备上
|
||||
public async putOnOnce(msg: { hid: number }, session: BackendSession) {
|
||||
let { hid } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
let sid: string = session.get('sid');
|
||||
let funcs: number[] = session.get('funcs');
|
||||
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);
|
||||
let dicJob = gameData.job.get(dicHero.jobid);
|
||||
|
||||
|
||||
let allEquips = await EquipModel.findNotWearEquips(roleId);
|
||||
let sortEquips = allEquips.map(equip => {
|
||||
let { id, quality, randRange, ePlaceId } = equip;
|
||||
let { goodsAbility, lvLimited, itid } = gameData.goods.get(id);
|
||||
let attrObj = new Attribute();
|
||||
attrObj.setByMap(goodsAbility, HERO_CE_RATIO + randRange);
|
||||
let ce = attrObj.calEquipCe();
|
||||
let { classId } = getHeroEquipByClassId(itid);
|
||||
|
||||
return { id, quality, ce, equip, goodsAbility, lvLimited, classId, ePlaceId }
|
||||
});
|
||||
let { ePlace, lv } = hero;
|
||||
|
||||
let curEquips: Array<{ seqId: number, hid: number }> = [];
|
||||
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;
|
||||
return b.quality - a.quality;
|
||||
});
|
||||
|
||||
if(sortedAndSuitEquips.length > 0) {
|
||||
let { equip } = sortedAndSuitEquips.shift();
|
||||
let curEquip = await dressEquip(serverId, roleId, sid, hero,equip, funcs);
|
||||
if(!!curEquip) curEquips.push(curEquip);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//任务
|
||||
//英雄满装备且都镶嵌相同阶数的宝石
|
||||
let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero)
|
||||
if (isTask) {
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.EQUIP_SUIT_JEWEL_STAGE, 1, { stage: jewelLevel })
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { curEquips });
|
||||
}
|
||||
|
||||
//装备打孔
|
||||
public async digHole(msg: { eid: number, id: number }, session: BackendSession) {
|
||||
let { eid, id } = msg;
|
||||
|
||||
Reference in New Issue
Block a user