军团捐献,许愿池,装备,养成 注释
This commit is contained in:
@@ -528,8 +528,7 @@ export class EquipHandler {
|
||||
let good = ITID.get(goodInfo.itid);
|
||||
if (good.type != CONSUME_TYPE.JEWEL)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
//检查宝石消耗是否合法TODO
|
||||
let needConsumes = checkMaterialEnough(consumes, jewel, count);
|
||||
let needConsumes = checkMaterialEnough(consumes, jewel, count);//检查是否可以合成,并返回最终需要消耗的材料
|
||||
if (!needConsumes)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let res = await handleCost(roleId, sid, needConsumes);
|
||||
@@ -576,26 +575,29 @@ export class EquipHandler {
|
||||
let good = ITID.get(goodInfo.itid);
|
||||
if (good.type != CONSUME_TYPE.JEWEL)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
//检查宝石消耗是否合法TODO
|
||||
if (!purchaseGoods)
|
||||
if (!purchaseGoods) //需要购买才可进行合成的物品
|
||||
purchaseGoods = [];
|
||||
if (!consumes)
|
||||
consumes = [];
|
||||
let needConsumes = checkMaterialEnough(consumes.concat(purchaseGoods), jewel, count);
|
||||
let needConsumes = checkMaterialEnough(consumes.concat(purchaseGoods), jewel, count);//检查是否可以合成,并返回最终需要消耗的材料
|
||||
if (!needConsumes)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let items:Array<{id: number, count: number, ratio?:number}> = [];
|
||||
for (let item of purchaseGoods) {
|
||||
items.push({id: item.id, count: item.count, ratio: 1})
|
||||
items.push({id: item.id, count: item.count, ratio: 1})//加上购买的数量
|
||||
}
|
||||
items = items.concat(needConsumes);
|
||||
let hasError = await decreaseItems(roleId, sid, items);
|
||||
let hasError = await decreaseItems(roleId, sid, items);//合并消耗是否足够
|
||||
if (!!hasError)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 临时使用的购买物品,后应该在商店中购买
|
||||
* @param msg
|
||||
* @param session
|
||||
*/
|
||||
public async purchaseGoods(msg: { purchaseGoods: Array<{ id: number, count: number }>}, session: BackendSession) {
|
||||
let { purchaseGoods } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
@@ -607,7 +609,11 @@ export class EquipHandler {
|
||||
}
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
//合成下一级宝石并穿戴(装备镶嵌界面)
|
||||
/**
|
||||
* 合成下一级宝石并穿戴(装备镶嵌界面)
|
||||
* @param msg
|
||||
* @param session
|
||||
*/
|
||||
public async composeNextLevelJewel(msg: { jewel: number, count: number, eid: number, id: number }, session: BackendSession) {
|
||||
let { count, jewel, eid, id } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
@@ -621,25 +627,27 @@ export class EquipHandler {
|
||||
if (good.type != CONSUME_TYPE.JEWEL)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let equip;
|
||||
if (!!eid) {
|
||||
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;
|
||||
equip.holes[index].jewel = jewel;//合成后的新宝石穿戴到装备上
|
||||
needUpdate = true;
|
||||
consumes.push({id: goodInfo.composeMaterial[0].id, count: 1, ratio: 1});
|
||||
consumes.push({id: goodInfo.composeMaterial[0].id, count: 1, ratio: 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);
|
||||
let hasError = await decreaseItems(roleId, sid, consumes);//检查是消耗是否足够
|
||||
if (!!hasError)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
let result = {};
|
||||
if (needUpdate) {
|
||||
//穿戴宝石
|
||||
await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
|
||||
if (!!equip.hid) {
|
||||
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
|
||||
|
||||
Reference in New Issue
Block a user