关卡:主公经验和等级挂钩

This commit is contained in:
luying
2021-08-27 14:40:38 +08:00
parent cbc4087a5b
commit d71767dfca
9 changed files with 49 additions and 38 deletions

View File

@@ -4,7 +4,7 @@ import Role, { RoleModel, RoleType } from '../db/Role'
import { getLvByExp, getExpByLv, gameData, getDicApByLv } from '../pubUtils/data';
import { updateUserInfo } from './redisService';
import { switchOnFunc } from './funcSwitchService';
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS } from '../consts';
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS, KING_EXP_RATIO_TYPE } from '../consts';
import { BackendSession, pinus } from 'pinus';
import { REDIS_KEY } from '../consts';
import { Rank } from './rankService';
@@ -14,14 +14,15 @@ import { RScriptRecordModel } from '../db/RScriptRecord';
import { setAp } from './actionPointService';
import { resResult } from '../pubUtils/util';
export async function roleLevelup(roleId: string, kingExp: number = 0, session: BackendSession) {
export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kingExp: number = 0, session: BackendSession) {
const serverId = session.get('serverId');
const sid = session.get('sid');
const funcs = session.get('funcs');
let role = await RoleModel.findByRoleId(roleId);
let { lv = 1, exp = 0 } = role;
let canGetExp = lv < gameData.maxPlayerLv.max; // 当主公超过最大级后,挑战结算不再获得经验值
let newExp = canGetExp ? exp + kingExp : exp;
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);