热更新:handler监听热更新
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
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, DEBUG_MAGIC_WORD } from "../../../consts";
|
||||
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
|
||||
|
||||
@@ -24,6 +24,7 @@ import { GiftCodeType, GiftCodeModel } from "../../../db/GiftCode";
|
||||
import UserGiftCode, { UserGiftCodeModel } from "../../../db/UserGiftCode";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ItemHandler(app);
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ export class ItemHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let { isOver } = await getAp(roleId, role.lv);
|
||||
if(isOver) return resResult(STATUS.AP_IS_FULL);
|
||||
if (isOver) return resResult(STATUS.AP_IS_FULL);
|
||||
|
||||
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }]);
|
||||
if (!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
@@ -111,7 +112,7 @@ export class ItemHandler {
|
||||
const roleName: string = session.get('roleName');
|
||||
const sid: string = session.get('sid');
|
||||
|
||||
if(count <= 0) return resResult(STATUS.WRONG_PARMS);
|
||||
if (count <= 0) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
if (!dicGoods) {
|
||||
@@ -125,18 +126,18 @@ export class ItemHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let { buyTimes = 0 } = await getAp(roleId, role.lv);
|
||||
if(buyTimes + count > gameData.apMaxBuyTimes.max) return resResult(STATUS.AP_BUY_TIMES_LACK);
|
||||
if (buyTimes + count > gameData.apMaxBuyTimes.max) return resResult(STATUS.AP_BUY_TIMES_LACK);
|
||||
|
||||
let cost: RewardInter[] = [];
|
||||
for(let i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
let curCost = gameData.apBuy.get(++buyTimes);
|
||||
if(curCost) cost = cost.concat(curCost);
|
||||
if (curCost) cost = cost.concat(curCost);
|
||||
}
|
||||
|
||||
let consumeResult = await handleCost(roleId, sid, cost);
|
||||
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 }]);
|
||||
let apJson = await setApBuyTimes(roleId, role.lv, sid, count);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
@@ -153,15 +154,15 @@ export class ItemHandler {
|
||||
|
||||
let giftCodeDetail = await GiftCodeDetailModel.findByCode(code);
|
||||
let giftCode = <GiftCodeType>giftCodeDetail.giftCode;
|
||||
|
||||
if(giftCode.isLimit && giftCodeDetail.usedNum >= giftCode.count) {
|
||||
|
||||
if (giftCode.isLimit && giftCodeDetail.usedNum >= giftCode.count) {
|
||||
return resResult(STATUS.GIFT_CODE_USED_NUM_MAX);
|
||||
}
|
||||
if(giftCode.beginTime > new Date()) return resResult(STATUS.GIFT_CODE_NOT_START);
|
||||
if(giftCode.endTime < new Date()) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED);
|
||||
if (giftCode.beginTime > new Date()) return resResult(STATUS.GIFT_CODE_NOT_START);
|
||||
if (giftCode.endTime < new Date()) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED);
|
||||
|
||||
let userGiftCode = await UserGiftCodeModel.findByCode(roleId, code);
|
||||
if(userGiftCode) {
|
||||
if (userGiftCode) {
|
||||
return resResult(STATUS.YOU_HAVE_USED_THIS_CODE);
|
||||
}
|
||||
|
||||
@@ -185,7 +186,7 @@ export class ItemHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let apJson = await setAp(roleId, role.lv, msg.ap, sid, funcs);
|
||||
if(!apJson) return resResult(STATUS.BATTLE_ACTION_POINT_LACK)
|
||||
if (!apJson) return resResult(STATUS.BATTLE_ACTION_POINT_LACK)
|
||||
return resResult(STATUS.SUCCESS, { apJson });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user