From bae1d3d83d114ae2931805b278c035ef958dc05a Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 22 Oct 2020 16:55:56 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=8D=87=E7=BA=A7=E7=BB=8F=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/services/normalBattleService.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/game-server/app/services/normalBattleService.ts b/game-server/app/services/normalBattleService.ts index 01a58b340..79923fd5a 100644 --- a/game-server/app/services/normalBattleService.ts +++ b/game-server/app/services/normalBattleService.ts @@ -6,19 +6,23 @@ import { getLvByExp, getExpByLv } from '../pubUtils/gamedata'; export async function roleLevelup(roleId: string, kingExp: number) { let role = await RoleModel.findByRoleId(roleId); let {lv = 1, exp = 0} = role; - exp += kingExp; - let newLv = getLvByExp(exp); - await RoleModel.levelup(roleId, newLv, exp); + let newExp = exp + kingExp; + let newLv = getLvByExp(newExp); + await RoleModel.levelup(roleId, newLv, newExp); let actordata = []; for(let i = lv; i <= newLv; i++) { let {sum, cur} = getExpByLv(i); - let getExp = sum > exp? sum - exp: 0; + let lastSum = sum - cur; + console.log(sum, cur, lastSum, exp, newExp); + + let startExp = exp > lastSum? exp - lastSum: 0; + let getExp = newExp > sum? cur - startExp: newExp - lastSum - startExp; actordata.push({ lv : i, - exp : cur - getExp, - getExp : getExp, + exp : startExp, // 升级前经验 + getExp : getExp, // 获得的经验 mostExp : cur - }) + }); } return {actordata, lv, exp, kingExp}; }