体力:等级体力接口
This commit is contained in:
@@ -214,6 +214,25 @@ export class ItemHandler {
|
||||
return resResult(STATUS.SUCCESS, { apJson });
|
||||
}
|
||||
|
||||
public async getApByLv(msg: { lv: number }, session: BackendSession) {
|
||||
const { lv } = msg;
|
||||
let roleId = session.get('roleId');
|
||||
let ip = session.get('ip');
|
||||
|
||||
let { lvRecords = [] } = await ActionPointModel.getAp(roleId);
|
||||
let lvRecord = lvRecords.find(cur => cur.lv == lv);
|
||||
let ap = 0, apBefore = 0;
|
||||
if(!lvRecord) {
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let apJson = await getAp(roleId, ip, role.lv);
|
||||
ap = apJson.ap;
|
||||
apBefore = apJson.ap;
|
||||
} else {
|
||||
({ ap, apBefore } = lvRecord);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { ap, apBefore });
|
||||
}
|
||||
|
||||
public async debugResetBuyTimes(msg: { magicWord: string }, session: BackendSession) {
|
||||
const { magicWord } = msg;
|
||||
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
// 推送
|
||||
|
||||
Reference in New Issue
Block a user