fix 升级经验
This commit is contained in:
@@ -6,19 +6,23 @@ import { getLvByExp, getExpByLv } from '../pubUtils/gamedata';
|
|||||||
export async function roleLevelup(roleId: string, kingExp: number) {
|
export async function roleLevelup(roleId: string, kingExp: number) {
|
||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
let {lv = 1, exp = 0} = role;
|
let {lv = 1, exp = 0} = role;
|
||||||
exp += kingExp;
|
let newExp = exp + kingExp;
|
||||||
let newLv = getLvByExp(exp);
|
let newLv = getLvByExp(newExp);
|
||||||
await RoleModel.levelup(roleId, newLv, exp);
|
await RoleModel.levelup(roleId, newLv, newExp);
|
||||||
let actordata = [];
|
let actordata = [];
|
||||||
for(let i = lv; i <= newLv; i++) {
|
for(let i = lv; i <= newLv; i++) {
|
||||||
let {sum, cur} = getExpByLv(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({
|
actordata.push({
|
||||||
lv : i,
|
lv : i,
|
||||||
exp : cur - getExp,
|
exp : startExp, // 升级前经验
|
||||||
getExp : getExp,
|
getExp : getExp, // 获得的经验
|
||||||
mostExp : cur
|
mostExp : cur
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return {actordata, lv, exp, kingExp};
|
return {actordata, lv, exp, kingExp};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user