体力:等级体力接口

This commit is contained in:
luying
2022-05-18 15:08:37 +08:00
parent 464f8175ce
commit 2d8e252a4a
3 changed files with 40 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ import { uniq } from 'underscore';
import { checkPopUpCondition } from './activity/popUpShopService';
import { calculateCeWithRole } from './playerCeService';
import { sendMessageToUserWithSuc } from './pushService';
import { ActionPointModel } from '../db/ActionPoint';
export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kingExp: number = 0, session: BackendSession) {
const serverId = session.get('serverId');
@@ -30,12 +31,6 @@ export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kin
let ratio = gameData.kingExpRaio.get(lv)?.get(type)||0;
let newExp = canGetExp ? exp + Math.floor(kingExp * ratio) : exp;
let newLv = getLvByExp(newExp);
// 等级超过最高级之后,经验依然可以稍微溢出一些,以备下一次提升等级
// let nextExpObj = getExpByLv(newLv + 1);
// let curExpObj = getExpByLv(newLv);
// if(curExpObj && !nextExpObj && newExp > curExpObj.sum) {
// newExp = curExpObj.sum;
// }
role = await RoleModel.levelup(roleId, newLv, newExp);
if (newLv > lv) { // 升级
@@ -74,7 +69,8 @@ export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kin
});
if(i != lv) { // 升级加体力
let dicAp = getDicApByLv(i);
await setAp(serverId, roleId, ip, i, dicAp.restoreAp, sid, ITEM_CHANGE_REASON.LV_UP);
let { ap, apBefore } = await setAp(serverId, roleId, ip, i, dicAp.restoreAp, sid, ITEM_CHANGE_REASON.LV_UP);
await ActionPointModel.setLvRecord(roleId, i, ap, apBefore);
}
}
// 推送