装备:获得天晶石&合成装备
This commit is contained in:
@@ -8,12 +8,12 @@ import { EquipModel, EquipType } from "../../../db/Equip";
|
||||
import { HeroModel, EPlace, HeroType } from "../../../db/Hero";
|
||||
import Role from "../../../db/Role";
|
||||
import { calPlayerCeAndSave } from "../../../services/playerCeService";
|
||||
import { getGoodById, gameData } from "../../../pubUtils/data";
|
||||
import { getGoodById, gameData, getEquipByJobClassAndEPlace } from "../../../pubUtils/data";
|
||||
import { BAG, EQUIP } from "../../../pubUtils/dicParam";
|
||||
import { ITID, QUALITY_TYPE, equipTypeToSortAttr, IT_TYPE, QUENCH_TYPE, REFINE_TYPE } from "../../../consts";
|
||||
import { checkMaterialEnough, checkEquipCanPut, quenchOnce, checkQuenchMaxByQualityAndGrade, getRandSeResult, refineOnce, checkRefineReachNextLv, calEquipCe } from "../../../services/equipService";
|
||||
|
||||
import { findIndex, pick } from 'underscore';
|
||||
import { findIndex, isNumber, pick } from 'underscore';
|
||||
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
|
||||
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, checkActivityTask } from "../../../services/taskService";
|
||||
import { QuenchLogParam } from "../../../domain/roleField/equip";
|
||||
@@ -29,72 +29,38 @@ export class EquipHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
public async composeEquip(msg: { hid: number, eplaceId: number }, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let { hid, eplaceId } = msg;
|
||||
if(!isNumber(eplaceId) || eplaceId > 4 || eplaceId < 1) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
// // test接口添加任意道具
|
||||
// public async addItem(msg: { id: number, count: number }, session: BackendSession) {
|
||||
// let roleId: string = session.get('roleId');
|
||||
// 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 }], ITEM_CHANGE_REASON.DEBUG);
|
||||
// return resResult(STATUS.SUCCESS, { goods });
|
||||
// }
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if(!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
// // 合成装备
|
||||
// public async composeEquip(msg: { gid: number, originalEquip: number[] }, session: BackendSession) {
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
// let sid: string = session.get('sid');
|
||||
// const serverId: number = session.get('serverId');
|
||||
// // 消耗材料
|
||||
// // 获得装备
|
||||
// let { gid, originalEquip } = msg;
|
||||
let curEquip = hero.ePlace?.find(equip => equip.id == eplaceId );
|
||||
if(curEquip) return resResult(STATUS.EQUIP_HAS_COMPOSE);
|
||||
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
let dicEquip = getEquipByJobClassAndEPlace(dicHero?.jobClass, eplaceId);
|
||||
if(!dicEquip) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
// let targetGood = gameData.goods.get(gid);
|
||||
// if (!targetGood) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let consumeResult = await handleCost(roleId, sid, dicEquip.composeMaterial, ITEM_CHANGE_REASON.EQUIP_COMPOSE);
|
||||
if(!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
// let cost: ItemInter[] = [];
|
||||
// let jewels: ItemInter[] = []; // 需要返还的镶嵌在装备上的宝石
|
||||
// if (targetGood.suitId > 0) { // 套装
|
||||
// cost = cost.concat(targetGood.composeMaterial);
|
||||
// let specialMaterial = targetGood.specialMaterial;
|
||||
// let costCount = 0;
|
||||
// let equips = await EquipModel.getEquips(roleId, originalEquip);
|
||||
// for (let equip of equips) {
|
||||
// let { id, seqId, holes } = equip;
|
||||
// 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 });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (specialMaterial.count > costCount) {
|
||||
// return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
// }
|
||||
let newEquip = new EPlace(eplaceId, dicEquip.id);
|
||||
let newEplace = hero.ePlace? [...hero.ePlace, newEquip]: [newEquip];
|
||||
|
||||
// } else { // 普通装备
|
||||
// cost.push({
|
||||
// id: targetGood.pieceId,
|
||||
// count: targetGood.pieces
|
||||
// });
|
||||
// }
|
||||
// let result = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.EQUIP_COMPOSE);
|
||||
// if (!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.COMPOSE_EQUIP, sid, roleId, hero, { ePlace: newEplace }, [eplaceId]);
|
||||
|
||||
// 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, ITEM_CHANGE_REASON.EQUIP_COMPOSE);
|
||||
// if (targetGood.suitId) {
|
||||
// pushNormalEquipMsg(roleId, roleName, serverId, MSG_SOURCE.EQUIP_COMPOSE_SUIT, gid, targetGood.name, targetGood.quality);
|
||||
// }
|
||||
// if (targetGood.quality >= QUALITY_TYPE.ORANGE) {
|
||||
// pushNormalEquipMsg(roleId, roleName, serverId, MSG_SOURCE.EQUIP_COMPOSE_ORANGE, gid, targetGood.name, targetGood.quality);
|
||||
// }
|
||||
// return resResult(STATUS.SUCCESS, { goods });
|
||||
// }
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
curHero: {
|
||||
hid: hero.hid,
|
||||
ePlace: [newEquip]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// // 装备栏强化
|
||||
// public async strengthen(msg: { hid: number, ePlaceId: number, type: number }, session: BackendSession) {
|
||||
|
||||
@@ -567,7 +567,7 @@ export class HeroHandler {
|
||||
let dicSkin = gameData.fashion.get(id);
|
||||
// console.log('*****', id, dicSkin)
|
||||
if (!dicSkin) return resResult(STATUS.HERO_SKIN_NOT_FIND);
|
||||
let hero = await HeroModel.findByHidAndRoleWithEquip(dicSkin.actorId, roleId);
|
||||
let hero = await HeroModel.findByHidAndRole(dicSkin.actorId, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let newHeroSkins: HeroSkin[] = [];
|
||||
|
||||
@@ -110,7 +110,7 @@ export class MailHandler {
|
||||
let sid: string = session.get('sid');
|
||||
let serverId: number = session.get('serverId');
|
||||
let { id, type, mailType } = msg;
|
||||
let { equipCount } = await RoleModel.findByRoleId(roleId, 'equipCount');
|
||||
let { jewelCount } = await RoleModel.findByRoleId(roleId, 'jewelCount');
|
||||
|
||||
let originMails: {mailType: GM_MAIL_TYPE, mail: MailType|GroupMailType|ServerMailType}[] = []
|
||||
|
||||
@@ -156,7 +156,7 @@ export class MailHandler {
|
||||
|
||||
let mailGoods: ItemInter[] = [], mails: MailParam[] = [];
|
||||
for(let { mail, mailType } of originMails) {
|
||||
let { isEquipOver, equipCount: newEquipCount } = checkMailGoods(mail, equipCount);
|
||||
let { isEquipOver, jewelCount: newEquipCount } = checkMailGoods(mail, jewelCount);
|
||||
if(isEquipOver) {
|
||||
if(type == RECEIVE_MAIL_TYPE.SINGLE) {
|
||||
return resResult(STATUS.EQUIP_IS_OVER);
|
||||
@@ -164,7 +164,7 @@ export class MailHandler {
|
||||
continue; // 如果有装备数量超过,那么一键领取这条邮件就不领了
|
||||
}
|
||||
}
|
||||
equipCount = newEquipCount;
|
||||
jewelCount = newEquipCount;
|
||||
|
||||
if(mailType == GM_MAIL_TYPE.SINGLE) {
|
||||
mail = await MailModel.updateStatusWithCondition(mail._id, MAIL_STATUS.RECEIVED);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { mergeSameGoods, getRandEelm, getRandValueByMinMax } from '../pubUtils/util';
|
||||
import { EquipModel, RandMain, RandSe } from "../db/Equip";
|
||||
import { HeroModel, HeroType } from "../db/Hero";
|
||||
import { getGoodById, gameData, getJewelById, getQuenchGradeByValue, getQuenchConsume, getQuenchByQualityAndGrade } from "../pubUtils/data";
|
||||
import { getGoodById, gameData, getQuenchGradeByValue, getQuenchConsume, getQuenchByQualityAndGrade } from "../pubUtils/data";
|
||||
import { calPlayerCeAndSave } from "./playerCeService";
|
||||
import { CONSUME_TYPE, HERO_SYSTEM_TYPE, ITID, TASK_TYPE } from "../consts";
|
||||
import { dicGoods, DicGoods } from '../pubUtils/dictionary/DicGoods';
|
||||
|
||||
@@ -244,13 +244,13 @@ export class SendMailFun {
|
||||
}
|
||||
}
|
||||
|
||||
export function checkMailGoods(mail: MailType | GroupMailType | ServerMailType, equipCount: number) {
|
||||
export function checkMailGoods(mail: MailType | GroupMailType | ServerMailType, jewelCount: number) {
|
||||
let isEquipOver = false;
|
||||
for (let good of mail.goods) {
|
||||
let dicGoods = gameData.goods.get(good.id);
|
||||
let dicItid = ITID.get(dicGoods.itid);
|
||||
if (dicItid.table == 'equip') { // 装备
|
||||
if (++equipCount > BAG.BAG_EQUIP_UPLIMITED) {
|
||||
if (dicItid.table == 'jewel') { // 装备
|
||||
if (++jewelCount > BAG.BAG_EQUIP_UPLIMITED) {
|
||||
isEquipOver = true;
|
||||
break;
|
||||
}
|
||||
@@ -258,6 +258,6 @@ export function checkMailGoods(mail: MailType | GroupMailType | ServerMailType,
|
||||
}
|
||||
|
||||
return {
|
||||
isEquipOver, equipCount
|
||||
isEquipOver, jewelCount
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { pushCalPlayerCe, pushCalAllHeroCe, calPlayerCeAndSave } from './playerC
|
||||
import { ItemModel, ItemType } from '../db/Item';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { pinus } from 'pinus';
|
||||
import { addEquips, addBags, addSkin, addFigure, unlockFigure as pubUnlockFigure, transPiece, getGoldObject, getCoinObject, getApObject } from '../pubUtils/itemUtils';
|
||||
import { addJewels, addBags, addSkin, addFigure, unlockFigure as pubUnlockFigure, transPiece, getGoldObject, getCoinObject, getApObject } from '../pubUtils/itemUtils';
|
||||
import { ItemInter, RewardInter, } from '../pubUtils/interface';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { uniq } from 'underscore';
|
||||
@@ -27,6 +27,7 @@ import { getInitHeroById } from './roleService';
|
||||
import { getActivities } from './activity/activityService';
|
||||
import { reportTAEvent, reportTAUserSet } from './sdkService';
|
||||
import { saveCoinChangeLog, saveFigureInfoLog, saveGoldChangeLog, saveItemChangeLog } from '../pubUtils/logUtil';
|
||||
import { JewelModel, JewelType } from '../db/Jewel';
|
||||
|
||||
export class CheckMeterial {
|
||||
private roleId: string;
|
||||
@@ -98,9 +99,9 @@ export class CheckMeterial {
|
||||
export async function handleCost(roleId: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
|
||||
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
let { items, equips, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
|
||||
let equipSeqIds = equips.map(cur => cur.seqId);
|
||||
let resEquips: EquipType[] = [];
|
||||
let { items, jewels, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
|
||||
let jewelSeqIds = jewels.map(cur => cur.seqId);
|
||||
let resJewels: JewelType[] = [];
|
||||
|
||||
// 检查货币是否充足
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
@@ -111,9 +112,9 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
if(originGold < 0 || originCoin < 0) return false;
|
||||
}
|
||||
//检查装备是否存在
|
||||
if (equips.length > 0) {
|
||||
resEquips = await EquipModel.getEquips(roleId, equipSeqIds);
|
||||
if (resEquips.length < equips.length)
|
||||
if (jewels.length > 0) {
|
||||
resJewels = await JewelModel.findbySeqIds(jewelSeqIds);
|
||||
if (resJewels.length < jewels.length)
|
||||
return false;
|
||||
}
|
||||
//检查并修改道具
|
||||
@@ -125,33 +126,31 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
}
|
||||
|
||||
//删除装备
|
||||
// if (resEquips.length > 0) {
|
||||
// let heroMap = new Map<number, { hero: HeroType, equips: EquipType[]}>();
|
||||
// for(let equip of resEquips) {
|
||||
// if(equip.hid > 0) {
|
||||
// if(!heroMap.has(equip.hid)) {
|
||||
// let hero = await HeroModel.findByHidAndRoleWithEquip(equip.hid, roleId);
|
||||
// heroMap.set(equip.hid, { hero, equips: [] });
|
||||
// }
|
||||
// heroMap.get(equip.hid).equips.push(equip);
|
||||
// }
|
||||
// }
|
||||
// for(let [_hid, {hero, equips} ] of heroMap) {
|
||||
// let oldCount = hero.ePlace.filter(cur => cur.equip).length;
|
||||
// let args = calEquipSeids(hero);
|
||||
// for(let equip of equips) {
|
||||
// hero = await HeroModel.removeEquip(roleId, hero.hid, equip.ePlaceId, equip._id);
|
||||
// }
|
||||
if (resJewels.length > 0) {
|
||||
let heroMap = new Map<number, { hero: HeroType, jewels: JewelType[]}>();
|
||||
for(let jewel of resJewels) {
|
||||
if(jewel.hid > 0) {
|
||||
if(!heroMap.has(jewel.hid)) {
|
||||
let hero = await HeroModel.findByHidAndRole(jewel.hid, roleId);
|
||||
heroMap.set(jewel.hid, { hero, jewels: [] });
|
||||
}
|
||||
heroMap.get(jewel.hid).jewels.push(jewel);
|
||||
}
|
||||
}
|
||||
for(let [_hid, {hero, jewels} ] of heroMap) {
|
||||
// TODO 脱下天晶石
|
||||
// for(let equip of jewels) {
|
||||
// hero = await HeroModel.putOffJewel(roleId, hero.hid, equip.ePlaceId, equip._id);
|
||||
// }
|
||||
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, args);
|
||||
// await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [-1, oldCount]);
|
||||
// }
|
||||
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, args);
|
||||
}
|
||||
|
||||
|
||||
// let equips = await EquipModel.deleteEquips(roleId, equipSeqIds);
|
||||
// saveItemChangeLog(roleId, equips.map(equip => ({ id: equip.id, count: equip.count, inc: -1 })), reason);
|
||||
// pinus.app.get('channelService').pushMessageByUids('onEquipDel', resResult(STATUS.SUCCESS, { equipInfos: equips.map(equip => ({ seqId: equip.seqId, id: equip.id, inc: -1, reason })) }), uids);
|
||||
// }
|
||||
let jewels = await JewelModel.deleteBySeqIds(roleId, jewelSeqIds);
|
||||
saveItemChangeLog(roleId, jewels.map(jewel => ({ id: jewel.id, count: 1, inc: -1 })), reason);
|
||||
pinus.app.get('channelService').pushMessageByUids('onJewelDel', resResult(STATUS.SUCCESS, { jewels: jewels.map(jewel => ({ seqId: jewel.seqId, id: jewel.id, inc: -1, reason })) }), uids);
|
||||
}
|
||||
|
||||
//消耗玩家货币
|
||||
if (gold.length > 0 || coin.length > 0) {
|
||||
@@ -181,41 +180,39 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
// TODO: sid 在方法内部获取,且不一定存在
|
||||
export async function addItems(roleId: string, roleName: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
let { items, equips, gold, coin, ap, skins, figures } = sortItems(goods, HANDLE_REWARD_TYPE.RECEIVE);
|
||||
let { items, jewels, gold, coin, ap, skins, figures } = sortItems(goods, HANDLE_REWARD_TYPE.RECEIVE);
|
||||
let showItems: { id: number, seqId?: number, count: number, isBag?: boolean }[] = [];
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
// 1. 装备处理
|
||||
if(equips.length > 0) {
|
||||
let { equipCount = 0 } = role;
|
||||
let incEquips = equips, mailEquips: { id?: number, hid?: number, seqId?: number }[] = [];
|
||||
if(equips.length + equipCount > BAG.BAG_EQUIP_UPLIMITED) { // 装备上限
|
||||
let inc = BAG.BAG_EQUIP_UPLIMITED - equipCount;
|
||||
if(jewels.length > 0) {
|
||||
let { jewelCount = 0 } = role;
|
||||
let incJewels = jewels, mailJewels: { id?: number, hid?: number, seqId?: number }[] = [];
|
||||
if(jewels.length + jewelCount > BAG.BAG_EQUIP_UPLIMITED) { // 装备上限
|
||||
let inc = BAG.BAG_EQUIP_UPLIMITED - jewelCount;
|
||||
if(inc < 0) inc = 0;
|
||||
incEquips = equips.slice(0, inc);
|
||||
mailEquips = equips.slice(inc);
|
||||
incJewels = jewels.slice(0, inc);
|
||||
mailJewels = jewels.slice(inc);
|
||||
}
|
||||
|
||||
// 直接加的
|
||||
let { equips: equipInfos, pushMessages } = await addEquips(roleId, roleName, <{id: number, hid?: number}[]>incEquips, reason);
|
||||
for (let equip of equipInfos) {
|
||||
showItems.push({ seqId: equip.seqId, id: equip.id, count: 1, isBag: true });
|
||||
let { jewels: jewelInfos, pushMessages } = await addJewels(roleId, roleName, <{id: number, hid?: number}[]>incJewels, reason);
|
||||
for (let jewel of jewelInfos) {
|
||||
showItems.push({ seqId: jewel.seqId, id: jewel.id, count: 1, isBag: true });
|
||||
}
|
||||
for(let equip of combineItems(mailEquips)) {
|
||||
showItems.push({ id: equip.id, count: equip.count, isBag: false });
|
||||
for(let jewel of combineItems(mailJewels)) {
|
||||
showItems.push({ id: jewel.id, count: jewel.count, isBag: false });
|
||||
}
|
||||
//装备推送
|
||||
if (!!equipInfos.length)
|
||||
pinus.app.get('channelService').pushMessageByUids('onEquipAdd', resResult(STATUS.SUCCESS, { equipInfos }), uids);
|
||||
if (!!jewelInfos.length)
|
||||
pinus.app.get('channelService').pushMessageByUids('onJewelAdd', resResult(STATUS.SUCCESS, { jewelInfos }), uids);
|
||||
pushTaskUpdate(roleId, sid, pushMessages);
|
||||
//统计装备
|
||||
if (equipInfos.length > 0) {
|
||||
let { serverId } = await RoleModel.findByRoleId(roleId);
|
||||
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_COUNT, equipInfos.length, { equips: equipInfos.map(obj => { return { quality: obj.quality } }) })
|
||||
saveItemChangeLog(roleId, equipInfos, reason);
|
||||
if (jewelInfos.length > 0) {
|
||||
saveItemChangeLog(roleId, jewelInfos, reason);
|
||||
}
|
||||
// 发邮件的
|
||||
if(mailEquips.length > 0) {
|
||||
await sendMailByContent(MAIL_TYPE.EQUIP_OVER, roleId, { goods: combineItems(mailEquips) });
|
||||
if(mailJewels.length > 0) {
|
||||
await sendMailByContent(MAIL_TYPE.EQUIP_OVER, roleId, { goods: combineItems(mailJewels) });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,12 +332,12 @@ export function combineItems(items: { id?: number, count?: number }[]) {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function combineItemAndEquips(items: { id?: number, count?: number }[]) {
|
||||
export function combineItemAndJewels(items: { id?: number, count?: number }[]) {
|
||||
let result: { id: number, count: number }[] = [];
|
||||
for(let { id, count = 1 } of items) {
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
let dicItid = ITID.get(dicGoods.itid);
|
||||
if(dicItid.table != 'equip') {
|
||||
if(dicItid.table != 'jewel') {
|
||||
let index = result.findIndex(cur => cur.id == id);
|
||||
if(index == -1) {
|
||||
result.push({ id, count });
|
||||
@@ -356,7 +353,7 @@ export function combineItemAndEquips(items: { id?: number, count?: number }[]) {
|
||||
|
||||
function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) {
|
||||
let items: { id: number, count: number }[] = []; // 可叠加道具
|
||||
let equips: { seqId?: number, id?: number, hid?: number }[] = []; // 不可叠加装备
|
||||
let jewels: { seqId?: number, id?: number, hid?: number }[] = []; // 不可叠加装备
|
||||
let gold: { count: number, isPay: boolean }[] = []; // 金币
|
||||
let coin: number[] = [];
|
||||
let ap: number = 0;
|
||||
@@ -376,14 +373,14 @@ function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) {
|
||||
continue;
|
||||
}
|
||||
let { type, table, isCurrency } = dicItid;
|
||||
if(table == ITEM_TABLE.EQUIP) { // 装备
|
||||
if(table == ITEM_TABLE.JEWEL) { // 装备
|
||||
if(handleType == HANDLE_REWARD_TYPE.RECEIVE) {
|
||||
for(let i = 0; i < good.count; i++) {
|
||||
equips.push({ id: good.id, hid: good.hid })
|
||||
jewels.push({ id: good.id, hid: good.hid })
|
||||
}
|
||||
} else {
|
||||
if(!!good.seqId) {
|
||||
equips.push({ seqId: good.seqId });
|
||||
jewels.push({ seqId: good.seqId });
|
||||
}
|
||||
}
|
||||
} else if (table == ITEM_TABLE.ITEM) { // 可叠加道具
|
||||
@@ -429,11 +426,11 @@ function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) {
|
||||
|
||||
}
|
||||
|
||||
return { items, equips, gold, coin, ap, skins, figures }
|
||||
return { items, jewels, gold, coin, ap, skins, figures }
|
||||
}
|
||||
|
||||
export async function checkGoods(roleId: string, goodIds: Array<number>) {
|
||||
let equipIds: Array<number> = [];
|
||||
let jewelSeqIds: Array<number> = [];
|
||||
let itemIds: Array<number> = [];
|
||||
let hids: Array<number> = [];
|
||||
goodIds = uniq(goodIds);
|
||||
@@ -442,7 +439,7 @@ export async function checkGoods(roleId: string, goodIds: Array<number>) {
|
||||
if (!!goodInfo) {
|
||||
let { table } = ITID.get(goodInfo.itid);
|
||||
if (table == ITEM_TABLE.EQUIP) {
|
||||
equipIds.push(goodId);
|
||||
jewelSeqIds.push(goodId);
|
||||
} else if (table == ITEM_TABLE.ITEM) {
|
||||
itemIds.push(goodId);
|
||||
}
|
||||
@@ -450,12 +447,12 @@ export async function checkGoods(roleId: string, goodIds: Array<number>) {
|
||||
}
|
||||
|
||||
//检查装备是否存在
|
||||
if (!!equipIds.length) {
|
||||
let resEquips = await EquipModel.getEquipsByIds(roleId, equipIds);
|
||||
resEquips = uniq(resEquips, function (resEquip) {
|
||||
if (!!jewelSeqIds.length) {
|
||||
let resJewels = await JewelModel.findbySeqIds(jewelSeqIds);
|
||||
resJewels = uniq(resJewels, function (resEquip) {
|
||||
return resEquip.id;
|
||||
});
|
||||
if (resEquips.length < equipIds.length)
|
||||
if (resJewels.length < jewelSeqIds.length)
|
||||
return false;
|
||||
}
|
||||
//检查并修改道具
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { BattleDropModel } from '../db/BattleDrop';
|
||||
import { getRandEelmWithWeight, getRandSingleEelm, getReasonByWarType } from '../pubUtils/util';
|
||||
import { BATTLE_REWARD_TYPE, BLUEPRT_CONST } from '../consts';
|
||||
import { addItems, combineItemAndEquips } from './rewardService';
|
||||
import { addItems, combineItemAndJewels } from './rewardService';
|
||||
import { BattleBlueprtDropModel } from '../db/BattleBlueprtDrop'
|
||||
import { RoleModel } from '../db/Role';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
@@ -184,7 +184,7 @@ export class WarReward {
|
||||
|
||||
let rewards = this.rewards;
|
||||
if(combine) {
|
||||
rewards = combineItemAndEquips(rewards);
|
||||
rewards = combineItemAndJewels(rewards);
|
||||
}
|
||||
await addItems(this.roleId, this.roleName, this.sid, rewards, getReasonByWarType(this.warInfo.warType));
|
||||
return rewards;
|
||||
|
||||
@@ -11,10 +11,10 @@ module.exports = {
|
||||
"required string from": 3,
|
||||
"required string target": 4
|
||||
},
|
||||
"role.equipHandler.composeEquip": {
|
||||
"required uInt32 gid": 1,
|
||||
"repeated uInt32 originalEquip": 2
|
||||
},
|
||||
// "role.equipHandler.composeEquip": {
|
||||
// "required uInt32 hid": 1,
|
||||
// "repeated uInt32 eplaceId": 2
|
||||
// },
|
||||
"role.equipHandler.decomposeEquip": {
|
||||
"repeated uInt32 originalEquip": 1
|
||||
},
|
||||
|
||||
@@ -116,7 +116,7 @@ module.exports = {
|
||||
// 'required uInt32 code': 2,
|
||||
// 'required Data data': 3
|
||||
// },
|
||||
// 'onEquipAdd': {
|
||||
// 'onJewelAdd': {
|
||||
// 'message Data': {
|
||||
// "message EquipInfo": {
|
||||
// "message RandSe": {
|
||||
@@ -147,7 +147,7 @@ module.exports = {
|
||||
// 'required uInt32 code': 2,
|
||||
// 'required Data data': 3
|
||||
// },
|
||||
// 'onEquipDel': {
|
||||
// 'onJewelDel': {
|
||||
// 'message Data': {
|
||||
// 'repeated uInt32 equips': 1
|
||||
// },
|
||||
|
||||
@@ -105,7 +105,7 @@ describe('拍卖行测试', function () {
|
||||
|
||||
it('出价,竞价和一口价', function (done) {
|
||||
let gid = null;
|
||||
pinusClient.on('onEquipAdd', (res) => {
|
||||
pinusClient.on('onJewelAdd', (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.equipInfos).to.be.an('array');
|
||||
for (let info of res.data.equipInfos) {
|
||||
|
||||
Reference in New Issue
Block a user