数数:消耗来源
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);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from "pinus";
|
||||
import { resResult, getRandEelm, getResStr, shouldRefresh, sortArrRandom, checkRoleIsRobot, getRobotSysType, makeRobotId } from "../../../pubUtils/util";
|
||||
import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_TYPE, BLOCK_OPEATE, CONSUME_TYPE, ITID, HERO_SELECT, EQUIP_SELECT, REDIS_KEY, MSG_SOURCE, MSG_TYPE, TASK_TYPE, ROBOT_SYS_TYPE } from "../../../consts";
|
||||
import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_TYPE, BLOCK_OPEATE, CONSUME_TYPE, ITID, HERO_SELECT, EQUIP_SELECT, REDIS_KEY, MSG_SOURCE, MSG_TYPE, TASK_TYPE, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { RoleModel, RoleType } from "../../../db/Role";
|
||||
import { getTimeFun, getZeroPointD } from "../../../pubUtils/timeUtil";
|
||||
import { FriendApplyModel } from "../../../db/FriendApply";
|
||||
@@ -550,7 +550,7 @@ export class FriendHandler {
|
||||
}
|
||||
if (todayReceiveInc <= 0) return resResult(STATUS.FRIEND_HAS_RECEIVE);
|
||||
let fp = getFriendPointObject(todayReceiveCnt);
|
||||
let goods = await addItems(roleId, roleName, sid, [fp])
|
||||
let goods = await addItems(roleId, roleName, sid, [fp], ITEM_CHANGE_REASON.RECEIVE_FRIEND_HEART)
|
||||
|
||||
frdPointRec = await FriendPointModel.updatePointToday(roleId, roleName, todayReceiveInc, max, FRIEND_DROP_TYPE.SEND_GIFT);
|
||||
|
||||
@@ -588,7 +588,7 @@ export class FriendHandler {
|
||||
}
|
||||
}
|
||||
|
||||
let costResult = await handleCost(roleId, sid, items);
|
||||
let costResult = await handleCost(roleId, sid, items, ITEM_CHANGE_REASON.FRIEND_SEND_PRESENT);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let result = await FriendShipModel.addFriendValue(roleId, hisRoleId, friendValueInc);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeServ
|
||||
import { resResult, deepCopy } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { HeroModel, Connect, HeroSkin, HeroUpdate, EPlace } from '../../../db/Hero';
|
||||
import { CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ABI_STAGE, DEBUG_MAGIC_WORD, HERO_INITIAL_QUALITY, REDIS_KEY, TASK_TYPE } from '../../../consts';
|
||||
import { CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ABI_STAGE, DEBUG_MAGIC_WORD, HERO_INITIAL_QUALITY, REDIS_KEY, TASK_TYPE, ITEM_CHANGE_REASON } from '../../../consts';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { ItemModel } from '../../../db/Item';
|
||||
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById, getFavourLvByExp, reloadDicParam } from '../../../pubUtils/data';
|
||||
@@ -46,7 +46,7 @@ export class HeroHandler {
|
||||
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let { pieceId, quality, pieceCount } = dicHero;
|
||||
// 碎片数量是否足够
|
||||
let costResult = await handleCost(roleId, sid, [{ id: pieceId, count: pieceCount }]);
|
||||
let costResult = await handleCost(roleId, sid, [{ id: pieceId, count: pieceCount }], ITEM_CHANGE_REASON.COMPOSE_HERO);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
// createHero
|
||||
let { heroes, resultHeroes } = await createHero(roleId, roleName, sid, serverId, { hid, count: 1 });
|
||||
@@ -107,7 +107,7 @@ export class HeroHandler {
|
||||
|
||||
let newLv = getHeroLvByExp(newExp);
|
||||
|
||||
let costResult = await handleCost(roleId, sid, material);
|
||||
let costResult = await handleCost(roleId, sid, material, ITEM_CHANGE_REASON.HERO_LV_UP);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let update = {
|
||||
@@ -124,7 +124,7 @@ export class HeroHandler {
|
||||
const curHero = {
|
||||
hid, lv: hero.lv, exp: hero.exp
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { curHero });
|
||||
return resResult(STATUS.SUCCESS, { curHero, cost: material });
|
||||
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ export class HeroHandler {
|
||||
}
|
||||
if (newStarStage == oldStarStage) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let consumes = check.getConsume();
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.HERO_STAR_UP);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
@@ -232,7 +232,7 @@ export class HeroHandler {
|
||||
if (!curDicHeroQualityUp) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let { fragmentNum } = curDicHeroQualityUp;
|
||||
|
||||
let costResult = await handleCost(roleId, sid, [{ id: pieceId, count: fragmentNum }]);
|
||||
let costResult = await handleCost(roleId, sid, [{ id: pieceId, count: fragmentNum }], ITEM_CHANGE_REASON.HERO_QUALITY_UP);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.QUALITY, sid, roleId, hero, {
|
||||
@@ -298,7 +298,7 @@ export class HeroHandler {
|
||||
}
|
||||
if (newColorStarStage == oldColorStarStage) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let consumes = check.getConsume();
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.HERO_WAKE_UP);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
@@ -367,7 +367,7 @@ export class HeroHandler {
|
||||
}
|
||||
if (newJobStage == hero.jobStage) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let consumes = check.getConsume();
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.HERO_JOB_TRAIN);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
@@ -401,7 +401,7 @@ export class HeroHandler {
|
||||
return resResult(STATUS.NOT_REACH_UNLOCK_LEVEL);
|
||||
if (curJob >= getMaxGradeByjobClass(heroJob.job_class))
|
||||
return resResult(STATUS.HERO_JOB_REACH_MAX_STAGE);
|
||||
let result = await handleCost(roleId, sid, heroJob.upGradeConsume);
|
||||
let result = await handleCost(roleId, sid, heroJob.upGradeConsume, ITEM_CHANGE_REASON.HERO_JOB_STAGEUP);
|
||||
if (!result) {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
@@ -459,7 +459,7 @@ export class HeroHandler {
|
||||
if (member.star + member.colorStar < friendShip.level)
|
||||
return resResult(STATUS.NOT_REACH_UNLOCK_LEVEL);
|
||||
}
|
||||
let result = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN), count: friendShip.costCoin }]);
|
||||
let result = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN), count: friendShip.costCoin }], ITEM_CHANGE_REASON.HERO_CONNECT_ACTIVE);
|
||||
if (!result) {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
@@ -528,7 +528,7 @@ export class HeroHandler {
|
||||
|
||||
let newLv = getFavourLvByExp(newExp);
|
||||
|
||||
let result = await handleCost(roleId, sid, material);
|
||||
let result = await handleCost(roleId, sid, material, ITEM_CHANGE_REASON.HERO_GIVE_FAVOR);
|
||||
if (!result) {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
@@ -545,7 +545,7 @@ export class HeroHandler {
|
||||
} else {
|
||||
hero = await HeroModel.updateHeroInfo(roleId, hero.hid, { favour: newExp, favourLv: newLv });
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { curHero: { hid: hero.hid, favour: hero.favour, favourLv: hero.favourLv } });
|
||||
return resResult(STATUS.SUCCESS, { curHero: { hid: hero.hid, favour: hero.favour, favourLv: hero.favourLv, cost: material } });
|
||||
}
|
||||
|
||||
//穿带时装
|
||||
@@ -658,7 +658,7 @@ export class HeroHandler {
|
||||
if (!dicHero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
await addItems(roleId, roleName, sid, [{
|
||||
id: dicHero.pieceId, count: dicHero.pieceCount * HERO_GROW_MAX.STAR * ABI_STAGE.END
|
||||
}]);
|
||||
}], ITEM_CHANGE_REASON.DEBUG);
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
@@ -690,7 +690,7 @@ export class HeroHandler {
|
||||
await RoleModel.updateRoleInfo(roleId, role);
|
||||
}
|
||||
}
|
||||
let result = await addItems(roleId, roleName, sid, items);
|
||||
let result = await addItems(roleId, roleName, sid, items, ITEM_CHANGE_REASON.DEBUG);
|
||||
if (!result) {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { STATUS, CONSUME_TYPE, DEBUG_MAGIC_WORD } from "../../../consts";
|
||||
import { STATUS, CONSUME_TYPE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { RewardInter } from "../../../pubUtils/interface";
|
||||
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
@@ -35,7 +35,7 @@ export class ItemHandler {
|
||||
|
||||
|
||||
if (count > 0) {
|
||||
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }]);
|
||||
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }], ITEM_CHANGE_REASON.USE_GIFT_PACKAGE);
|
||||
if (!consumeResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH);
|
||||
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
@@ -82,7 +82,7 @@ export class ItemHandler {
|
||||
let { isOver } = await getAp(roleId, role.lv);
|
||||
if (isOver) return resResult(STATUS.AP_IS_FULL);
|
||||
|
||||
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }]);
|
||||
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }], ITEM_CHANGE_REASON.USE_MEAT);
|
||||
if (!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let apJson = await setAp(roleId, role.lv, dicGoods.value * count, sid);
|
||||
@@ -125,10 +125,10 @@ export class ItemHandler {
|
||||
if (curCost) cost = cost.concat(curCost);
|
||||
}
|
||||
|
||||
let consumeResult = await handleCost(roleId, sid, cost);
|
||||
let consumeResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.BUY_MEAT);
|
||||
if (!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id, count }]);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id, count }], ITEM_CHANGE_REASON.BUY_MEAT);
|
||||
let apJson = await setApBuyTimes(roleId, role.lv, sid, count);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
@@ -167,7 +167,7 @@ export class ItemHandler {
|
||||
await GiftCodeDetailModel.increaseUsedNum(code);
|
||||
await GiftCodeModel.increaseUsedNum(giftCode.id);
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, giftCode.goods);
|
||||
let goods = await addItems(roleId, roleName, sid, giftCode.goods, ITEM_CHANGE_REASON.USE_GIFT_CODE);
|
||||
return resResult(STATUS.SUCCESS, { goods });
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { MailParam } from '../../../domain/roleField/mail';
|
||||
import { ItemInter, RewardInter } from '../../../pubUtils/interface';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import { ITID, RECEIVE_MAIL_TYPE } from '../../../consts';
|
||||
import { ITEM_CHANGE_REASON, ITID, RECEIVE_MAIL_TYPE } from '../../../consts';
|
||||
import { BAG } from '../../../pubUtils/dicParam';
|
||||
|
||||
export default function(app: Application) {
|
||||
@@ -146,7 +146,7 @@ export class MailHandler {
|
||||
mails.push(mailObj);
|
||||
}
|
||||
|
||||
let resGoods = await addItems(roleId, roleName, sid, mailGoods);
|
||||
let resGoods = await addItems(roleId, roleName, sid, mailGoods, ITEM_CHANGE_REASON.MAIL);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { mails, goods: resGoods });
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { STATUS, RANK_TYPE_TO_KEY, ROLE_SELECT, RANK_TYPE, HERO_SELECT, GUILD_SELECT, RANK_FIRST_REWARD_STATUS } from "../../../consts";
|
||||
import { STATUS, RANK_TYPE_TO_KEY, ROLE_SELECT, RANK_TYPE, HERO_SELECT, GUILD_SELECT, RANK_FIRST_REWARD_STATUS, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { RoleModel } from "../../../db/Role";
|
||||
import { UserGuildModel } from "../../../db/UserGuild";
|
||||
import { GuildModel } from "../../../db/Guild";
|
||||
@@ -190,7 +190,7 @@ export class RoleHandler {
|
||||
return { id, type, status: RANK_FIRST_REWARD_STATUS.RECEIVED }
|
||||
})
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, rewards);
|
||||
let goods = await addItems(roleId, roleName, sid, rewards, ITEM_CHANGE_REASON.RANK_REWARD);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
rewards: rewardStatus,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
|
||||
import { SchoolModel } from '../../../db/School';
|
||||
import { getTeraphStrengthenResult, getSchoolList } from '../../../services/roleService'
|
||||
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
||||
import { HERO_SYSTEM_TYPE, LINEUP_NUM, ROLE_SELECT, REDIS_KEY, TASK_TYPE, DEFAULT_HEROES, DEFAULT_HERO_LV, DEFAULT_ITEMS, DEFAULT_EQUIPS, DEFAULT_GOLD, DEFAULT_COIN, DEBUG_MAGIC_WORD, COUNTER, DEFAULT_LV } from '../../../consts';
|
||||
import { HERO_SYSTEM_TYPE, LINEUP_NUM, ROLE_SELECT, REDIS_KEY, TASK_TYPE, DEFAULT_HEROES, DEFAULT_HERO_LV, DEFAULT_ITEMS, DEFAULT_EQUIPS, DEFAULT_GOLD, DEFAULT_COIN, DEBUG_MAGIC_WORD, COUNTER, DEFAULT_LV, ITEM_CHANGE_REASON } from '../../../consts';
|
||||
import { checkBattleHeroesByHid, roleLevelup } from '../../../services/normalBattleService';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { updateUserInfo } from '../../../services/redisService';
|
||||
@@ -70,7 +70,7 @@ export class RoleHandler {
|
||||
session.push('roleName', () => { });
|
||||
|
||||
let items = [].concat(DEFAULT_ITEMS, DEFAULT_EQUIPS, [getGoldObject(DEFAULT_GOLD)], [getCoinObject(DEFAULT_COIN)]);
|
||||
await addItems(roleId, roleName, sid, items);
|
||||
await addItems(roleId, roleName, sid, items, ITEM_CHANGE_REASON.DEFAULT_ITEMS);
|
||||
|
||||
let battleId = SCRIPT.SCRIPT_BATTLE_ID;
|
||||
let warInfo = gameData.war.get(battleId);
|
||||
@@ -104,7 +104,7 @@ export class RoleHandler {
|
||||
if (titleInfo.lvLimited > role.lv)
|
||||
return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH)
|
||||
let consumes = titleInfo.material;
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.TITLE_LEVEL_UP);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
@@ -140,7 +140,7 @@ export class RoleHandler {
|
||||
if (times == 0)
|
||||
return resResult(STATUS.ROLE_TERAPH_NOT_STRENGTHEN);
|
||||
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.TERAPH_STRENGTHEN);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
@@ -184,7 +184,7 @@ export class RoleHandler {
|
||||
return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let consumes = teraphInfo.upGradeMaterial;
|
||||
let result = await handleCost(roleId, sid, consumes);
|
||||
let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.TERAPH_QUALITY_UP);
|
||||
if (!result)
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
@@ -284,7 +284,7 @@ export class RoleHandler {
|
||||
}
|
||||
|
||||
const cost = parseGoodStr(SCHOOL.SCHOOL_UNLOCK_COIN);
|
||||
const costResult = await handleCost(roleId, sid, cost);
|
||||
const costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.UNLOCK_SCHOOL_POSITION);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
curSchool = await SchoolModel.updateBySclAndPos(roleId, schoolId, positionId, { isOpen: true })
|
||||
@@ -478,7 +478,7 @@ export class RoleHandler {
|
||||
let role = await RoleModel.findByRoleId(roleId, 'renameCnt');
|
||||
let costGold = role.renameCnt >= dicParam.NAMEPLATE.NAMEPLATE_FREECOST? dicParam.NAMEPLATE.NAMEPLATE_FEECOST: 0;
|
||||
if(costGold > 0) {
|
||||
let result = await handleCost(roleId, sid, [getGoldObject(costGold)]);
|
||||
let result = await handleCost(roleId, sid, [getGoldObject(costGold)], ITEM_CHANGE_REASON.RENAME);
|
||||
if(!result) return resResult(STATUS.BATTLE_GOLD_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
import { parseGoodStr, resResult } from "../../../pubUtils/util";
|
||||
import { STATUS, GUILD_STRUCTURE, ITID, CONSUME_TYPE, HERO_QUALITY_TYPE, HERO_GROW_MAX } from "../../../consts";
|
||||
import { STATUS, GUILD_STRUCTURE, ITID, CONSUME_TYPE, HERO_QUALITY_TYPE, HERO_GROW_MAX, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { DicShopListModel } from "../../../db/DicShopList";
|
||||
import { UserShopModel } from "../../../db/UserShop";
|
||||
import { handleCost, addItems } from "../../../services/rewardService";
|
||||
@@ -68,7 +68,7 @@ export class ShopHandler {
|
||||
id: dicShopItem.money,
|
||||
count: Math.round(dicShopItem.price * count)
|
||||
}];
|
||||
let costResult = await handleCost(roleId, sid, cost);
|
||||
let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.SHOP_PURCHASE);
|
||||
if(!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
// 次数
|
||||
@@ -80,7 +80,7 @@ export class ShopHandler {
|
||||
id: dicShopItem.goodid,
|
||||
count
|
||||
}];
|
||||
let goods = await addItems(roleId, roleName, sid, reward);
|
||||
let goods = await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.SHOP_PURCHASE);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
shopItemId, count,
|
||||
@@ -113,7 +113,7 @@ export class ShopHandler {
|
||||
let cost = [{
|
||||
id: goodsId, count
|
||||
}];
|
||||
let costResult = await handleCost(roleId, sid, cost);
|
||||
let costResult = await handleCost(roleId, sid, cost, ITEM_CHANGE_REASON.RECYCLE_SOUL);
|
||||
if(!costResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let reward: RewardInter[] = [];
|
||||
@@ -126,7 +126,7 @@ export class ShopHandler {
|
||||
reward = parseGoodStr(SHOP.HERO_SOUL_GOLDEN); break;
|
||||
}
|
||||
// 增加货币
|
||||
let goods = await addItems(roleId, roleName, sid, reward.map(cur => { return {id: cur.id, count: cur.count * count} }));
|
||||
let goods = await addItems(roleId, roleName, sid, reward.map(cur => { return {id: cur.id, count: cur.count * count} }), ITEM_CHANGE_REASON.RECYCLE_SOUL);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
goodsId, count,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, pinus, HandlerService, } from "pinus";
|
||||
import { resResult, parseGoodStr, getRandSingleEelm } from "../../../pubUtils/util";
|
||||
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, KING_EXP_RATIO_TYPE, DEBUG_MAGIC_WORD } from "../../../consts";
|
||||
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, KING_EXP_RATIO_TYPE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
import { UserTaskRecModel } from "../../../db/UserTaskRec";
|
||||
import { addItems } from "../../../services/rewardService";
|
||||
@@ -86,7 +86,7 @@ export class ShopHandler {
|
||||
this.app.get('channelService').pushMessageByUids('addPoint', resResult(STATUS.SUCCESS, { activityId: obj.activityId, addPoint: point }), uids);
|
||||
}
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, taskReward);
|
||||
let goods = await addItems(roleId, roleName, sid, taskReward, ITEM_CHANGE_REASON.TASK_REWARD);
|
||||
if (expItem && expItem.count > 0) {
|
||||
await roleLevelup(KING_EXP_RATIO_TYPE.TASK, roleId, expItem.count, session);
|
||||
goods.push(expItem);
|
||||
@@ -123,7 +123,7 @@ export class ShopHandler {
|
||||
// 更新数据
|
||||
userTask = await UserTaskModel.incInfo(roleId, { mainTaskStage: 1 });
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, dicMainStage.reward);
|
||||
let goods = await addItems(roleId, roleName, sid, dicMainStage.reward, ITEM_CHANGE_REASON.TASK_STAGE_REWARD);
|
||||
let mainTask = await getMainTask(roleId, userTask);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
@@ -151,7 +151,7 @@ export class ShopHandler {
|
||||
if (!userTask) return resResult(STATUS.TASK_ACTIVE_NOT_ENOUGH);
|
||||
|
||||
let reward = parseGoodStr(TASK.DAILYTASK_POINT_REWARD);
|
||||
let goods = await addItems(roleId, roleName, sid, reward);
|
||||
let goods = await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.TASK_ACTIVE_REWARD);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
type: TASK_FUN_TYPE.DAILY,
|
||||
@@ -205,7 +205,7 @@ export class ShopHandler {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, dicTaskBox.reward);
|
||||
let goods = await addItems(roleId, roleName, sid, dicTaskBox.reward, ITEM_CHANGE_REASON.TASK_BOX_REWARD);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
type,
|
||||
|
||||
Reference in New Issue
Block a user