添加主角等级升级逻辑
This commit is contained in:
@@ -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};
|
||||
}
|
||||
Reference in New Issue
Block a user