数数:消耗来源
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
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 { 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, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { ItemInter } from "../../../pubUtils/interface";
|
||||
|
||||
import { resResult, parseGoodStr } from "../../../pubUtils/util";
|
||||
import { addItems, handleCost, decreaseItems, combineItems, CheckMeterial } from "../../../services/rewardService";
|
||||
import { addItems, handleCost, combineItems, CheckMeterial } from "../../../services/rewardService";
|
||||
import { EquipModel, EquipType } from "../../../db/Equip";
|
||||
import { HeroModel, EPlace, HeroType } from "../../../db/Hero";
|
||||
import Role from "../../../db/Role";
|
||||
@@ -36,7 +36,7 @@ export class EquipHandler {
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
let { id, count } = msg;
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id, count }]);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id, count }], ITEM_CHANGE_REASON.DEBUG);
|
||||
return resResult(STATUS.SUCCESS, { goods });
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ export class EquipHandler {
|
||||
count: targetGood.pieces
|
||||
});
|
||||
}
|
||||
let result = await handleCost(roleId, sid, cost);
|
||||
let result = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.EQUIP_COMPOSE);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
await addItems(roleId, roleName, sid, jewels); // 宝石返还
|
||||
await addItems(roleId, roleName, sid, jewels, ITEM_CHANGE_REASON.EQUIP_DEL_RETURN_JEWEL); // 宝石返还
|
||||
let items = [{ id: gid, count: 1 }];
|
||||
let goods = await addItems(roleId, roleName, sid, items);
|
||||
let goods = await addItems(roleId, roleName, sid, items, ITEM_CHANGE_REASON.EQUIP_COMPOSE);
|
||||
if (targetGood.suitId) {
|
||||
pushNormalEquipMsg(roleId, roleName, serverId, MSG_SOURCE.EQUIP_COMPOSE_SUIT, gid, targetGood.name, targetGood.quality);
|
||||
}
|
||||
@@ -166,7 +166,7 @@ export class EquipHandler {
|
||||
let result = await handleCost(roleId, sid, [{
|
||||
id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN),
|
||||
count: costCoin
|
||||
}]);
|
||||
}], ITEM_CHANGE_REASON.EQUIP_STRENTHEN);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
hero.ePlace = ePlace;
|
||||
@@ -248,7 +248,7 @@ export class EquipHandler {
|
||||
let result = await handleCost(roleId, sid, [{
|
||||
id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN),
|
||||
count: costCoin
|
||||
}]);
|
||||
}], ITEM_CHANGE_REASON.EQUIP_STRENTHEN);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
hero.ePlace = ePlace;
|
||||
@@ -305,7 +305,7 @@ export class EquipHandler {
|
||||
return resResult(STATUS.EQUIP_REFINE_ERR);
|
||||
}
|
||||
let consumes = check.getConsume();
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_REFINE);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
@@ -358,7 +358,7 @@ export class EquipHandler {
|
||||
} else {
|
||||
return resResult(STATUS.ROLE_ALL_SE_LOCK);
|
||||
}
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_LOCK_RANDSE);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ export class EquipHandler {
|
||||
consumes = parseGoodStr(EQUIP.EQUIP_FOUR_REFORGED);
|
||||
}
|
||||
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_RESTRENGTHEN);
|
||||
if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
equip = await EquipModel.updateEquipInfo(eid, { previewRandSe });
|
||||
@@ -519,7 +519,7 @@ export class EquipHandler {
|
||||
|
||||
if (times == 0) return resResult(STATUS.EQUIP_QUENCH_ERR);
|
||||
let consumes = check.getConsume();
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_QUENCH);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
@@ -572,12 +572,12 @@ export class EquipHandler {
|
||||
goods = goods.concat(goodInfo.decomposeItem);
|
||||
cost.push({ seqId: equip.seqId, id: equip.id, count: 1 });
|
||||
}
|
||||
let costResult = await handleCost(roleId, sid, cost); // 删掉装备
|
||||
let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.EQUIP_DECOMPOSE); // 删掉装备
|
||||
if(!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
|
||||
await addItems(roleId, roleName, sid, jewels); // 把原本镶嵌在装备上的宝石返还了
|
||||
let result = await addItems(roleId, roleName, sid, goods);
|
||||
await addItems(roleId, roleName, sid, jewels, ITEM_CHANGE_REASON.EQUIP_DEL_RETURN_JEWEL); // 把原本镶嵌在装备上的宝石返还了
|
||||
let result = await addItems(roleId, roleName, sid, goods, ITEM_CHANGE_REASON.EQUIP_DECOMPOSE);
|
||||
return resResult(STATUS.SUCCESS, { goods: combineItems(result) });
|
||||
}
|
||||
|
||||
@@ -601,9 +601,9 @@ export class EquipHandler {
|
||||
}
|
||||
}
|
||||
|
||||
let costResult = await handleCost(roleId, sid, originalPiece);
|
||||
let costResult = await handleCost(roleId, sid, originalPiece, ITEM_CHANGE_REASON.EQUIP_PIECE_DECOMPOSE);
|
||||
if(!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
let result = await addItems(roleId, roleName, sid, goods);
|
||||
let result = await addItems(roleId, roleName, sid, goods, ITEM_CHANGE_REASON.EQUIP_PIECE_DECOMPOSE);
|
||||
return resResult(STATUS.SUCCESS, { goods: combineItems(result) });
|
||||
}
|
||||
|
||||
@@ -801,7 +801,7 @@ export class EquipHandler {
|
||||
} else if (id == 3) {
|
||||
consumes = parseGoodStr(EQUIP.EQUIP_THREE_HOLE);
|
||||
}
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_DIG_HOLE);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
equip.holes[index].isOpen = true;
|
||||
@@ -835,14 +835,14 @@ export class EquipHandler {
|
||||
if (!!oldJewel)
|
||||
goods.push({ id: oldJewel, count: 1 });
|
||||
consumes.push({ id: jewel, count: 1 });
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.EQUIP_FILL_HOLE);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
equip.holes[index].jewel = jewel;
|
||||
await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
|
||||
let roleName: string = session.get('roleName');
|
||||
if (goods.length)
|
||||
await addItems(roleId, roleName, sid, goods);
|
||||
await addItems(roleId, roleName, sid, goods, ITEM_CHANGE_REASON.TAKE_OUT_JEWEL);
|
||||
if (!!equip.hid) {
|
||||
let hero = await HeroModel.findByHidAndRoleWithEquip(equip.hid, roleId);
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_ON, sid, roleId, hero, {}, [jewel, oldJewel]);
|
||||
@@ -879,10 +879,10 @@ export class EquipHandler {
|
||||
let needConsumes = checkMaterialEnough(consumes, jewel, count);//检查是否可以合成,并返回最终需要消耗的材料
|
||||
if (!needConsumes)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let res = await handleCost(roleId, sid, needConsumes);
|
||||
let res = await handleCost(roleId, sid, needConsumes, ITEM_CHANGE_REASON.JEWEL_COMPOSE);
|
||||
if (!res)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
let result = await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);
|
||||
let result = await addItems(roleId, roleName, sid, [{ id: jewel, count: count }], ITEM_CHANGE_REASON.JEWEL_COMPOSE);
|
||||
|
||||
if (goodInfo.lvLimited >= JEWEL_PUSH_LV) {
|
||||
pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.JEWEL_COMPOSE, jewel, goodInfo.name);
|
||||
@@ -912,7 +912,7 @@ export class EquipHandler {
|
||||
goods.push({ id: jewel, count: 1 });
|
||||
equip.holes[index].jewel = 0;
|
||||
await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
|
||||
await addItems(roleId, roleName, sid, goods);
|
||||
await addItems(roleId, roleName, sid, goods, ITEM_CHANGE_REASON.TAKE_OUT_JEWEL);
|
||||
if (!!equip.hid) {
|
||||
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_OFF, sid, roleId, hero, {}, [jewel]);
|
||||
@@ -943,15 +943,15 @@ export class EquipHandler {
|
||||
let needConsumes = checkMaterialEnough(consumes.concat(purchaseGoods), jewel, count);//检查是否可以合成,并返回最终需要消耗的材料
|
||||
if (!needConsumes)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let items: Array<{ id: number, count: number, ratio?: number }> = [];
|
||||
let items: ItemInter[] = [];
|
||||
for (let item of purchaseGoods) {
|
||||
items.push({ id: item.id, count: item.count, ratio: 1 })//加上购买的数量
|
||||
items.push({ id: item.id, count: item.count })//加上购买的数量
|
||||
}
|
||||
items = items.concat(needConsumes);
|
||||
let hasError = await decreaseItems(roleId, sid, items);//合并消耗是否足够
|
||||
if (!!hasError)
|
||||
let costResult = await handleCost(roleId, sid, items, ITEM_CHANGE_REASON.JEWEL_COMPOSE);//合并消耗是否足够
|
||||
if (!costResult)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);
|
||||
await addItems(roleId, roleName, sid, [{ id: jewel, count: count }], ITEM_CHANGE_REASON.JEWEL_COMPOSE);
|
||||
if (goodInfo.lvLimited >= JEWEL_PUSH_LV) {
|
||||
pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.JEWEL_COMPOSE, jewel, goodInfo.name);
|
||||
}
|
||||
@@ -967,7 +967,7 @@ export class EquipHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
let result = await addItems(roleId, roleName, sid, purchaseGoods);
|
||||
let result = await addItems(roleId, roleName, sid, purchaseGoods, ITEM_CHANGE_REASON.DEBUG);
|
||||
if (!result) {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
@@ -989,7 +989,7 @@ export class EquipHandler {
|
||||
let good = ITID.get(goodInfo.itid);
|
||||
let needUpdate = false;
|
||||
let oldJewel: number;
|
||||
let consumes: Array<{ id: number, count: number, ratio?: number }> = [];
|
||||
let consumes: Array<{ id: number, count: number }> = [];
|
||||
if (good.type != CONSUME_TYPE.JEWEL || !eid || eid < 0)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let equip = await EquipModel.getEquip(eid);
|
||||
@@ -1003,15 +1003,15 @@ export class EquipHandler {
|
||||
oldJewel = equip.holes[index].jewel;
|
||||
equip.holes[index].jewel = jewel;//合成后的新宝石穿戴到装备上
|
||||
needUpdate = true;
|
||||
consumes.push({ id: goodInfo.composeMaterial[0].id, count: 1, ratio: 1 });//ratio:1表示可以释放掉一颗宝石
|
||||
consumes.push({ id: goodInfo.composeMaterial[0].id, count: 1 });//ratio:1表示可以释放掉一颗宝石
|
||||
}
|
||||
|
||||
consumes = consumes.concat(goodInfo.composeMaterial);
|
||||
if (goodInfo.specialMaterial.count) {
|
||||
consumes.push({ id: goodInfo.specialMaterial.ids[0], count: goodInfo.specialMaterial.count })
|
||||
}
|
||||
let hasError = await decreaseItems(roleId, sid, consumes);//检查是消耗是否足够
|
||||
if (!!hasError)
|
||||
let costResult = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.JEWEL_COMPOSE);//检查是消耗是否足够
|
||||
if (!costResult)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
if (goodInfo.lvLimited >= JEWEL_PUSH_LV) {
|
||||
@@ -1043,7 +1043,7 @@ export class EquipHandler {
|
||||
|
||||
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
|
||||
} else {
|
||||
result = await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);
|
||||
result = await addItems(roleId, roleName, sid, [{ id: jewel, count: count }], ITEM_CHANGE_REASON.JEWEL_COMPOSE);
|
||||
return resResult(STATUS.SUCCESS, { goods: [{ id: jewel, count }] });
|
||||
}
|
||||
}
|
||||
@@ -1094,11 +1094,11 @@ export class EquipHandler {
|
||||
|
||||
// 消耗藏宝图和寻宝币
|
||||
|
||||
let costResult = await handleCost(roleId, sid, [...original, ...dicCompose.coinNum]);
|
||||
let costResult = await handleCost(roleId, sid, [...original, ...dicCompose.coinNum], ITEM_CHANGE_REASON.BLUEPRT_COMPOSE);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
const reward = [{ id: target, count: 1 }];
|
||||
const goods = await addItems(roleId, roleName, sid, reward);
|
||||
const goods = await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.BLUEPRT_COMPOSE);
|
||||
if (dicCompose.targetQuality >= QUALITY_TYPE.ORANGE) {
|
||||
const { name } = gameData.goods.get(target);
|
||||
pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.ORANGE_BLUEPRT_COMPOSE, target, name);
|
||||
|
||||
Reference in New Issue
Block a user