添加主角等级升级逻辑

This commit is contained in:
luying
2020-10-20 20:18:15 +08:00
parent 3332d16cc6
commit 7b65c1856b
6 changed files with 71 additions and 24 deletions
+22 -1
View File
@@ -5,7 +5,7 @@ import { HANG_UP_CONSTS } from './../consts/consts';
import { BattleRecordModel } from './../db/BattleRecord';
import { TowerRecordModel } from './../db/TowerRecord';
import { RoleModel } from './../db/Role';
import { getHeroInfoById, getJobInfoById, getTowerDataByLv } from "../pubUtils/gamedata"
import { getHeroInfoById, getJobInfoById, getTowerDataByLv, getLvByExp, getExpByLv } from "../pubUtils/gamedata"
import { decodeArrayStr, shouldRefresh } from '../pubUtils/util';
import { handleFixedReward } from './rewardService';
import { resResult } from '../pubUtils/util';
@@ -180,4 +180,25 @@ export async function checkTaskConditions(roleId: string, heroes: Array<number>,
}
}
return res;
}
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 actordata = [];
for(let i = lv; i <= newLv; i++) {
let {sum, cur} = getExpByLv(i);
let getExp = sum > exp? sum - exp: 0;
actordata.push({
lv : i,
exp : cur - getExp,
getExp : getExp,
mostExp : cur
})
}
return {actordata, lv, exp};
}