Revert "✨ feat(db): 修改role表数据库操作方式"
This reverts commit e39af3649288cc5802739cfe862c818fe56e194e.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
import { HeroModel, HeroType } from '../db/Hero';
|
||||
import Role, { RoleType, WarCount } from '../db/Role'
|
||||
import Role, { RoleModel, RoleType, WarCount } from '../db/Role'
|
||||
import { getLvByExp, getExpByLv, gameData, getDicApByLv } from '../pubUtils/data';
|
||||
import { updateRoleOnlineInfo, updateUserInfo } from './redisService';
|
||||
// import { switchOnFunc } from './funcSwitchService';
|
||||
@@ -27,14 +27,14 @@ export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kin
|
||||
const sid = session.get('sid');
|
||||
const ip = session.get('ip');
|
||||
|
||||
let role = await Role.findByRoleId(roleId);
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let { lv = 1, exp = 0 } = role;
|
||||
let canGetExp = lv < gameData.maxPlayerLv.max; // 当主公超过最大级后,挑战结算不再获得经验值
|
||||
let ratio = gameData.kingExpRaio.get(lv)?.get(type)||0;
|
||||
let newExp = canGetExp ? exp + Math.floor(kingExp * ratio) : exp;
|
||||
let newLv = getLvByExp(newExp);
|
||||
|
||||
role = await Role.levelup(roleId, newLv, newExp);
|
||||
role = await RoleModel.levelup(roleId, newLv, newExp);
|
||||
if (newLv > lv) { // 升级
|
||||
// await switchOnFunc(roleId, FUNC_OPT_TYPE.LEVEL_UP, newLv, session);
|
||||
await updateUserInfo(REDIS_KEY.USER_INFO, roleId, [{ field: 'lv', value: newLv }]);
|
||||
@@ -211,7 +211,7 @@ export async function checkWarCountAndInc(warId: number, inc: number, role: Role
|
||||
let dicWar = gameData.war.get(warId);
|
||||
let max = dicWar.warType == WAR_TYPE.NORMAL? GK_MAIN.GK_MAIN_SWEEP_TIMES: GK_MAINELITE.GK_MAINELITE_SWEEP_TIMES;
|
||||
if(needRefresh && shouldRefresh(refWarCount, new Date())) {
|
||||
let role = await Role.updateRoleInfo(roleId, { refWarCount: new Date(), warCount: [] });
|
||||
let role = await RoleModel.updateRoleInfo(roleId, { refWarCount: new Date(), warCount: [] });
|
||||
warCount = role.warCount;
|
||||
}
|
||||
let curWarCount = warCount.find(cur => cur.warId == warId);
|
||||
@@ -227,7 +227,7 @@ export async function checkWarCountAndInc(warId: number, inc: number, role: Role
|
||||
} else {
|
||||
warCount.push({ warId, count: inc });
|
||||
}
|
||||
await Role.updateRoleInfo(roleId, { warCount });
|
||||
await RoleModel.updateRoleInfo(roleId, { warCount });
|
||||
}
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user