任务:埋点30/70

This commit is contained in:
luying
2021-04-18 11:21:04 +08:00
parent bc07e1ea31
commit 9f4f346447
38 changed files with 1088 additions and 692 deletions

View File

@@ -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 } 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 } from "../../../consts";
import { ItemInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
@@ -15,6 +15,7 @@ import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerC
import { indexOf, findIndex } from 'underscore';
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs } from "../../../services/taskService";
export default function (app: Application) {
return new EquipHandler(app);
@@ -97,6 +98,7 @@ export class EquipHandler {
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let { ePlace, lv: playerLv } = hero; // 装备栏
let oldLvs = ePlace.map(cur => cur.lv);
let strengthenArr = new Array<EPlace>();
if (type == EQUIP_STRENGTHEN_TYPE.SINGLE || type == EQUIP_STRENGTHEN_TYPE.SINGLE_QUICK) { // 单装备强化
strengthenArr = ePlace.filter(cur => cur.id == ePlaceId && cur.equip);
@@ -146,6 +148,10 @@ export class EquipHandler {
hero.ePlace = ePlace;
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_BASE, sid, roleId, hero, { ePlace });
// 任务
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_STRENGTHEN, hero, oldLvs);
const curHero = {
hid,
ePlace: strengthenArr
@@ -165,6 +171,7 @@ export class EquipHandler {
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let { ePlace, lv: playerLv } = hero; // 装备栏
let oldLvs = ePlace.map(cur => cur.lv);
let strengthenArr = ePlace.filter(cur => cur.equip);
if (strengthenArr.length <= 0) {
@@ -205,6 +212,10 @@ export class EquipHandler {
hero.ePlace = ePlace;
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_BASE, sid, roleId, hero, { ePlace });
// 任务
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_STRENGTHEN, hero, oldLvs);
const curHero = {
hid,
ePlace: strengthenArr
@@ -279,6 +290,7 @@ export class EquipHandler {
if (isSuccess) {
let curEquip = <EquipType>equip;
pushEquipRefineSucMsg(roleId, roleName, serverId, curEplace, curEquip?curEquip.quality: 0);
await checkTask(roleId, sid, TASK_TYPE.EQUIP_REFINE, 1, true, {});
}
return resResult(STATUS.SUCCESS, { isSuccess, curHero });
}
@@ -396,6 +408,7 @@ export class EquipHandler {
const hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.RESTRENGTHEN, sid, roleId, hero, {}, [ePlaceId, ...removeSeidList]);
await checkTask(roleId, sid, TASK_TYPE.EQUIP_RESTRENGTHEN, 1, true, {});
return resResult(STATUS.SUCCESS,{curEquip});
}
@@ -452,7 +465,7 @@ export class EquipHandler {
if (index < 0)
return resResult(STATUS.WRONG_PARMS);
let equipOffInfo = <EquipType>hero.ePlace[index].equip;
let curEquip = await changeEquip(roleId, sid, equipOffInfo, equip.hid, id, eid);
let curEquip = await changeEquip(roleId, sid, equipOffInfo, equip.hid, id, equip);
if (!!curEquip)
curEquips.push(curEquip);
curEquip = await dressEquip(roleId, sid, hero, equip);
@@ -502,6 +515,8 @@ export class EquipHandler {
let consumes: Array<{ id: number, count: number }> = [];
let goods: Array<{ id: number, count: number }> = [];
let equip = await EquipModel.getEquip(eid);
let oldJewelCount = equip.holes.filter(cur => cur.jewel > 0).length;
let { itid } = getGoodById(equip.id);
let {equipJewel} = ITID.get(itid);
let jewelInfo = getGoodById(jewel);
@@ -528,6 +543,12 @@ export class EquipHandler {
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_ON, sid, roleId, hero, {}, [jewel, oldJewel]);
}
// 任务
await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL, equip, [oldJewelCount]);
await checkTaskWithArgs(roleId, sid, TASK_TYPE.EQUIP_JEWEL_STAGE, [jewel, oldJewel]);
await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
}
@@ -567,6 +588,7 @@ export class EquipHandler {
let sid: string = session.get('sid');
let goods: Array<{ id: number, count: number }> = [];
let equip = await EquipModel.getEquip(eid);
let oldJewelCount = equip.holes.filter(cur => cur.jewel > 0).length;
let index = findIndex(equip.holes, { id });
if (index > 0)
return resResult(STATUS.EQUIP_HOLE_NOT_FIND);
@@ -581,6 +603,11 @@ export class EquipHandler {
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_OFF, sid, roleId, hero, {}, [jewel]);
}
// 任务
await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL, equip, [oldJewelCount]);
await checkTaskWithArgs(roleId, sid, TASK_TYPE.EQUIP_JEWEL_STAGE, [0, jewel]);
await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
}
@@ -646,22 +673,24 @@ export class EquipHandler {
let goodInfo = getGoodById(jewel);
let good = ITID.get(goodInfo.itid);
let needUpdate = false;
let oldJewel;
let oldJewel: number;
let consumes: Array<{id: number, count: number, ratio?: number}> = [];
if (good.type != CONSUME_TYPE.JEWEL)
if (good.type != CONSUME_TYPE.JEWEL || !eid || eid < 0)
return resResult(STATUS.WRONG_PARMS);
let equip;
if (!!eid) {//合成并穿戴
equip = await EquipModel.getEquip(eid);
let index = findIndex(equip.holes,{id});
//装备上该位置有穿戴该宝石,且在合成的材料中
if (!!equip.holes[index] && equip.holes[index].jewel == goodInfo.composeMaterial[0].id) {
oldJewel = equip.holes[index].jewel;
equip.holes[index].jewel = jewel;//合成后的新宝石穿戴到装备上
needUpdate = true;
consumes.push({id: goodInfo.composeMaterial[0].id, count: 1, ratio: 1});//ratio1表示可以释放掉一颗宝石
}
let equip = await EquipModel.getEquip(eid);
if(!equip) return resResult(STATUS.EQUIP_NOT_FIND);
let oldJewelCount = equip.holes.filter(cur => cur.jewel > 0).length;
let index = findIndex(equip.holes,{id});
//装备上该位置有穿戴该宝石,且在合成的材料中
if (!!equip.holes[index] && equip.holes[index].jewel == goodInfo.composeMaterial[0].id) {
oldJewel = equip.holes[index].jewel;
equip.holes[index].jewel = jewel;//合成后的新宝石穿戴到装备上
needUpdate = true;
consumes.push({id: goodInfo.composeMaterial[0].id, count: 1, ratio: 1});//ratio1表示可以释放掉一颗宝石
}
consumes = consumes.concat(goodInfo.composeMaterial);
if (goodInfo.specialMaterial.count) {
consumes.push({id: goodInfo.specialMaterial.ids[0], count: goodInfo.specialMaterial.count})
@@ -677,11 +706,17 @@ export class EquipHandler {
let result = {};
if (needUpdate) {
//穿戴宝石
await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
equip = await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
if (!!equip.hid) {
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_ON, sid, roleId, hero, {}, [jewel, oldJewel]);
}
// 任务
await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL, equip, [oldJewelCount]);
await checkTaskWithArgs(roleId, sid, TASK_TYPE.EQUIP_JEWEL_STAGE, [jewel, oldJewel]);
await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_JEWEL_SUM, equip, [oldJewelCount]);
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
} else {
result = await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);