装备:分解
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
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, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { ItemInter } from "../../../pubUtils/interface";
|
||||
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
|
||||
|
||||
import { resResult, parseGoodStr } from "../../../pubUtils/util";
|
||||
import { addItems, handleCost, combineItems, CheckMeterial } from "../../../services/rewardService";
|
||||
@@ -344,7 +344,7 @@ export class EquipHandler {
|
||||
|
||||
let curJewel = await JewelModel.putOnOrOff(curEquip.jewel, 0, 0);
|
||||
let { newEplace, updatedEplace } = updateEplace(hero.ePlace, ePlaceId, { jewel: 0 });
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]);
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId], { oldJewel: curJewel });
|
||||
let curHero = {
|
||||
hid,
|
||||
eplace: updatedEplace
|
||||
@@ -597,71 +597,62 @@ export class EquipHandler {
|
||||
|
||||
}
|
||||
|
||||
// //分解装备
|
||||
// public async decomposeEquip(msg: { originalEquip: Array<number> }, session: BackendSession) {
|
||||
// let { originalEquip } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
// let sid: string = session.get('sid');
|
||||
// if(originalEquip.length > BAG.BAG_RESOLVE_UPLIMITED) {
|
||||
// return resResult(STATUS.EQUIP_DECOMPOSE_IS_UPLIMIT);
|
||||
// }
|
||||
// let equips = await EquipModel.getEquips(roleId, originalEquip);
|
||||
// if (equips.length < originalEquip.length)
|
||||
// return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
// let goods: Array<{ id: number, count: number }> = [];
|
||||
// let cost: ItemInter[] = [];
|
||||
// let jewels: ItemInter[] = []; // 宝石返还
|
||||
// for (let equip of equips) {
|
||||
// if (!!equip.hid)
|
||||
// return resResult(STATUS.EQUIP_IS_EQUIPED_NOT_DECOMPOSE);
|
||||
// let goodInfo = getGoodById(equip.id);
|
||||
// if (!goodInfo)
|
||||
// return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
// 地玉石和图纸分解
|
||||
public async decomposeItem(msg: { origin: { id: number, count: number }[] }, session: BackendSession) {
|
||||
let { origin } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
let goods: ItemInter[] = [];
|
||||
|
||||
// let holes = equip.holes || [];
|
||||
// for (let { jewel } of holes) {
|
||||
// if(jewel) {
|
||||
// jewels.push({ id: jewel, count: 1 });
|
||||
// }
|
||||
// }
|
||||
// goods = goods.concat(goodInfo.decomposeItem);
|
||||
// cost.push({ seqId: equip.seqId, id: equip.id, count: 1 });
|
||||
// }
|
||||
// let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.EQUIP_DECOMPOSE); // 删掉装备
|
||||
// if(!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
for (let { id, count } of origin) {
|
||||
let dicGoods = getGoodById(id);
|
||||
if (!dicGoods) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicGoods.decomposeItem) return resResult(STATUS.CONSUME_TYPE_ERR);
|
||||
|
||||
for(let result of dicGoods.decomposeItem) {
|
||||
goods.push({ id: result.id, count: result.count * count });
|
||||
}
|
||||
}
|
||||
|
||||
let costResult = await handleCost(roleId, sid, origin, ITEM_CHANGE_REASON.EQUIP_PIECE_DECOMPOSE);
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let result = await addItems(roleId, roleName, sid, goods, ITEM_CHANGE_REASON.EQUIP_PIECE_DECOMPOSE);
|
||||
return resResult(STATUS.SUCCESS, { goods: combineItems(result) });
|
||||
}
|
||||
|
||||
//分解装备
|
||||
public async decomposeJewel(msg: { origin: number[] }, session: BackendSession) {
|
||||
let { origin } = msg;
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleName: string = session.get('roleName');
|
||||
let sid: string = session.get('sid');
|
||||
if(origin.length > BAG.BAG_RESOLVE_UPLIMITED) {
|
||||
return resResult(STATUS.EQUIP_DECOMPOSE_IS_UPLIMIT);
|
||||
}
|
||||
let jewels = await JewelModel.findbySeqIds(origin);
|
||||
if (jewels.length < origin.length) return resResult(STATUS.JEWEL_IS_NOT_FIND);
|
||||
|
||||
let goods: RewardInter[] = [];
|
||||
let cost: ItemInter[] = [];
|
||||
|
||||
for(let jewel of jewels) {
|
||||
if(jewel.hid > 0) {
|
||||
return resResult(STATUS.JEWEL_IS_EQUIPED);
|
||||
}
|
||||
let dicGoods = gameData.goods.get(jewel.id);
|
||||
cost.push({ seqId: jewel.seqId, id: jewel.id, count: 1 });
|
||||
goods.push(...dicGoods.decomposeItem);
|
||||
}
|
||||
|
||||
let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.EQUIP_DECOMPOSE); // 删掉装备
|
||||
if(!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let result = await addItems(roleId, roleName, sid, goods, ITEM_CHANGE_REASON.EQUIP_DECOMPOSE);
|
||||
return resResult(STATUS.SUCCESS, { goods: combineItems(result) });
|
||||
}
|
||||
|
||||
|
||||
// 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) });
|
||||
// }
|
||||
|
||||
|
||||
// public async decomposeEquipPiece(msg: { originalPiece: { id: number, count: number }[] }, session: BackendSession) {
|
||||
// let { originalPiece } = msg;
|
||||
// let roleId: string = session.get('roleId');
|
||||
// let roleName: string = session.get('roleName');
|
||||
// let sid: string = session.get('sid');
|
||||
// let goods: ItemInter[] = [];
|
||||
|
||||
// for (let { id, count } of originalPiece) {
|
||||
// let goodInfo = getGoodById(id);
|
||||
// if (!goodInfo) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
// let dicItid = ITID.get(goodInfo.itid);
|
||||
// if(!dicItid || dicItid.type != CONSUME_TYPE.PIECE) {
|
||||
// return resResult(STATUS.CONSUME_TYPE_ERR);
|
||||
// }
|
||||
// for(let result of goodInfo.decomposeItem) {
|
||||
// goods.push({ id: result.id, count: result.count * count });
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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, ITEM_CHANGE_REASON.EQUIP_PIECE_DECOMPOSE);
|
||||
// return resResult(STATUS.SUCCESS, { goods: combineItems(result) });
|
||||
// }
|
||||
|
||||
// //穿戴或卸载装备 1-穿上装备(包括替换) 2-脱下装备
|
||||
// public async putOnOrOff(msg: { eid: number, hid: number, type: number }, session: BackendSession) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { addJewels, addBags, addSkin, addFigure, unlockFigure as pubUnlockFigure
|
||||
import { ItemInter, RewardInter, } from '../pubUtils/interface';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { uniq } from 'underscore';
|
||||
import { HeroModel, HeroType, HeroUpdate } from '../db/Hero';
|
||||
import { EPlace, HeroModel, HeroType, HeroUpdate } from '../db/Hero';
|
||||
import { Figure } from '../domain/dbGeneral';
|
||||
import { Rank } from './rankService';
|
||||
import { checkActivityTask, checkTaskWithHero, pushActivityUpdate, pushTaskUpdate } from './taskService';
|
||||
@@ -28,6 +28,7 @@ import { getActivities } from './activity/activityService';
|
||||
import { reportTAEvent, reportTAUserSet } from './sdkService';
|
||||
import { saveCoinChangeLog, saveFigureInfoLog, saveGoldChangeLog, saveItemChangeLog } from '../pubUtils/logUtil';
|
||||
import { JewelModel, JewelType } from '../db/Jewel';
|
||||
import { updateEplaces } from './equipService';
|
||||
|
||||
export class CheckMeterial {
|
||||
private roleId: string;
|
||||
@@ -138,12 +139,17 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
}
|
||||
}
|
||||
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);
|
||||
// 脱下天晶石
|
||||
let update = new Map<number, Partial<EPlace>>();
|
||||
for(let jewel of jewels) {
|
||||
await JewelModel.putOnOrOff(jewel.id, 0, 0);
|
||||
let curEquip = hero.ePlace.find(cur => cur.jewel == jewel.id);
|
||||
if(!!curEquip) {
|
||||
update.set(curEquip.id, { jewel: 0 });
|
||||
}
|
||||
}
|
||||
let { newEplace } = updateEplaces(hero.ePlace, update);
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, sid, roleId, hero, { ePlace: newEplace }, [...update.keys()]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ export const STATUS = {
|
||||
EQUIP_REFINE_ERR: { code: 30513, simStr: '该装备等级不足或材料不足' },
|
||||
EQUIP_RESTRENGTHEN_NOT_PREVIEW: { code: 30514, simStr: '该装备未预览洗练值' },
|
||||
EQUIP_QUENCH_MAX: { code: 30515, simStr: '该装备不能再淬火' },
|
||||
EQUIP_DECOMPOSE_IS_UPLIMIT: { code: 30516, simStr: '装备分解数量已达上限' },
|
||||
EQUIP_DECOMPOSE_IS_UPLIMIT: { code: 30516, simStr: '分解数量已达上限' },
|
||||
EQUIP_HAS_COMPOSE: { code: 30517, simStr: '该装备已合成' },
|
||||
EQUIP_QUALITY_MAX: { code: 30518, simStr: '该装备已升品到最高' },
|
||||
EQUIP_STAR_MAX: { code: 30519, simStr: '该装备已升星到最高' },
|
||||
@@ -326,8 +326,9 @@ export const STATUS = {
|
||||
JEWEL_DUPLICATE_LOCK: { code: 30530, simStr: '随机属性不可重复锁定' },
|
||||
JEWEL_NOT_PREVIEW: { code: 30531, simStr: '该天晶石未预览洗练值' },
|
||||
JEWEL_HAS_CHOOSEN_QUENCH: { code: 30532, simStr: '每个天晶石只能选择一个词条淬炼' },
|
||||
JEWEL_NOT_CHOOSEN_QUENCH: { code: 30533, simStr: '请选择一个可淬炼的词条' },
|
||||
JEWEL_NOT_CHOOSEN_QUENCH: { code: 30533, simStr: '请选择一个淬炼词条' },
|
||||
JEWEL_HAVE_NO_CUR_RANDSE: { code: 30534, simStr: '该天晶石上未找到该属性' },
|
||||
JEWEL_IS_EQUIPED: { code: 30535, simStr: '该天晶石被装备中无法分解' },
|
||||
|
||||
//全局养成30600-30699
|
||||
ROLE_REACH_MAX_TITLE_LEVEL: { code: 30600, simStr: '玩家已达到最高的爵位' },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// 武将特技表
|
||||
import { readFileAndParse, decodeArrayListStr } from '../util'
|
||||
import { readFileAndParse, decodeArrayListStr, parseNumberList } from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
|
||||
export interface DicRandomEffectPool {
|
||||
@@ -30,7 +30,8 @@ export function loadRandomEffectPool() {
|
||||
let arr = readFileAndParse(FILENAME.DIC_RANDOM_EFFECT_POOL);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.rate = parseRate(o.count)
|
||||
o.rate = parseRate(o.count);
|
||||
o.gainValueArr = parseNumberList(o.gainvalue);
|
||||
dicRandomEffectPool.set(o.id, o);
|
||||
});
|
||||
arr = undefined;
|
||||
|
||||
@@ -1016,6 +1016,7 @@ function addSeidEffect(heroAttrs: CeAttrData[], addSeidList: Array<number>, remo
|
||||
|
||||
// 获取dic_zyz_se内容
|
||||
function addSeid(effectList: Array<any>, seidId: number, rand: number, seidValue = new Array<number>()) {
|
||||
console.log('##### addSeid', effectList, seidId, rand, seidValue)
|
||||
let curSeid: DicSe | DicRandomEffectPool = gameData.se.get(seidId);
|
||||
if (!curSeid) curSeid = gameData.randomEffectPool.get(seidId);
|
||||
if (!curSeid) { console.log("seidId not found:" + seidId); return; }
|
||||
@@ -1028,6 +1029,7 @@ function addSeid(effectList: Array<any>, seidId: number, rand: number, seidValue
|
||||
return;
|
||||
}
|
||||
let seid: DicSe | DicRandomEffectPool = deepCopy(curSeid);
|
||||
console.log('#####', seid)
|
||||
if (curSeid.index > 0) {
|
||||
seid.gainValueArr[curSeid.index - 1] = rand;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user