体力:修改体力逻辑
This commit is contained in:
@@ -6,7 +6,7 @@ import { resResult, parseGoodStr, getRandValueByMinMax, getRandEelm } from "../.
|
||||
import { addItems, handleCost, decreaseItems } from "../../../services/rewardService";
|
||||
import Equip, { EquipModel, EquipType } from "../../../db/Equip";
|
||||
import { HeroModel, EPlace } from "../../../db/Hero";
|
||||
import Role from "../../../db/Role";
|
||||
import Role, { RoleModel } from "../../../db/Role";
|
||||
import { calPlayerCeAndSave } from "../../../services/playerCeService";
|
||||
import { getHeroJob, getGoodById, gameData, getHeroEquipByClassId } from "../../../pubUtils/data";
|
||||
import { EQUIP } from "../../../pubUtils/dicParam";
|
||||
@@ -17,6 +17,7 @@ import { indexOf, findIndex } from 'underscore';
|
||||
import { pushEquipRefineSucMsg, pushNormalEquipMsg, pushNormalItemMsg } from "../../../services/chatService";
|
||||
import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, checkTaskConditionEquipSuitJewelStage, checkActivityTask } from "../../../services/taskService";
|
||||
import { useGiftPackage } from "../../../services/activity/giftPackageService";
|
||||
import { getAp, setAp } from "../../../services/actionPointService";
|
||||
|
||||
export default function (app: Application) {
|
||||
return new ItemHandler(app);
|
||||
@@ -63,4 +64,57 @@ export class ItemHandler {
|
||||
|
||||
}
|
||||
|
||||
// 使用体力道具
|
||||
public async useApItem(msg: { id: number, count: number }, session: BackendSession) {
|
||||
let { id, count } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const sid = session.get('sid');
|
||||
const funcs = session.get('funcs');
|
||||
|
||||
if (count > 0) {
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
if (!dicGoods) {
|
||||
return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
}
|
||||
let dicItid = ITID.get(dicGoods.itid);
|
||||
if (!dicItid) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (dicItid.type != CONSUME_TYPE.AP) {
|
||||
return resResult(STATUS.ROLE_METERIAL_ERROR);
|
||||
}
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
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 }]);
|
||||
if (!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let apJson = await setAp(roleId, role.lv, dicGoods.value * count, sid, funcs);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
apJson
|
||||
});
|
||||
}
|
||||
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
}
|
||||
|
||||
public async debugIncAp(msg: { ap: number }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const sid = session.get('sid');
|
||||
const funcs = session.get('funcs');
|
||||
|
||||
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)
|
||||
return resResult(STATUS.SUCCESS, { apJson });
|
||||
}
|
||||
public async debugGetAp(msg: { }, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let apJson = await getAp(roleId, role.lv);
|
||||
return resResult(STATUS.SUCCESS, { apJson });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user