关卡:主公经验和等级挂钩
This commit is contained in:
@@ -6,7 +6,7 @@ import { difference } from 'underscore';
|
||||
* @Last Modified by: 梁桐川
|
||||
* @Last Modified time: 2021-03-10 20:15:30
|
||||
*/
|
||||
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, COM_BTL_QUALITY, MSG_SOURCE, QUALITY_TYPE, ROLE_SELECT, TASK_TYPE } from './../../../consts';
|
||||
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, COM_BTL_QUALITY, MSG_SOURCE, QUALITY_TYPE, ROLE_SELECT, TASK_TYPE, KING_EXP_RATIO_TYPE } from './../../../consts';
|
||||
import Role, { RoleModel } from '../../../db/Role';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
@@ -593,7 +593,7 @@ export class ComBattleHandler {
|
||||
|
||||
await ComBattleTeamModel.updateRewardSt(teamCode, roleId, true);
|
||||
const goods = await addItems(roleId, roleName, sid, roleSt.fixReward);
|
||||
let actordata = await roleLevelup(roleId, warInfo.kingExp, session);// 主公升级经验
|
||||
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, warInfo.kingExp, session);// 主公升级经验
|
||||
// 任务
|
||||
await checkTaskWithGoods(roleId, sid, funcs, TASK_TYPE.COM_BATTLE_DROP, goods);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ExpeditionPointModel } from '../../../db/ExpeditionPoint';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { calculateSumCE, genCode } from '../../../pubUtils/util';
|
||||
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies, getExpeditionStatus } from '../../../services/expeditionService';
|
||||
import { EXPEDITION_CONST, EXPEDITION_WAR_RECORD_STATUS, LINEUP_NUM, TASK_TYPE } from '../../../consts';
|
||||
import { EXPEDITION_CONST, EXPEDITION_WAR_RECORD_STATUS, KING_EXP_RATIO_TYPE, LINEUP_NUM, TASK_TYPE } from '../../../consts';
|
||||
import { WarReward } from '../../../services/warRewardService';
|
||||
import { addItems } from '../../../services/rewardService';
|
||||
import { getAp, setAp } from '../../../services/actionPointService';
|
||||
@@ -233,7 +233,7 @@ export class ExpeditionBattleHandler {
|
||||
let warReward = new WarReward(roleId, roleName, sid, battleId, isSuccess);
|
||||
let reward = await warReward.saveReward(1);
|
||||
|
||||
let actordata = await roleLevelup(roleId, isSuccess ? warInfo.kingExp : 0, session);// 主公升级经验
|
||||
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, isSuccess ? warInfo.kingExp : 0, session);// 主公升级经验
|
||||
if (isSuccess) {
|
||||
// 更新下一关状态
|
||||
await ExpeditionWarRecordModel.updateStatus(expeditionCode, expeditionId + 1, EXPEDITION_WAR_RECORD_STATUS.WAITING);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { BattleSweepRecordModel } from '../../../db/BattleSweepRecord';
|
||||
import { genCode } from '../../../pubUtils/util';
|
||||
import { WAR_TYPE, EVENT_STATUS, FUNC_OPT_TYPE, MSG_SOURCE, REDIS_KEY, TASK_TYPE } from '../../../consts';
|
||||
import { WAR_TYPE, EVENT_STATUS, FUNC_OPT_TYPE, MSG_SOURCE, REDIS_KEY, TASK_TYPE, KING_EXP_RATIO_TYPE } from '../../../consts';
|
||||
import { checkDaily, checkDailyAndIncrease } from '../../../services/dailyBattleService';
|
||||
import { checkTowerWar, towerBattleEnd } from '../../../services/battleService';
|
||||
import { WarReward } from '../../../services/warRewardService';
|
||||
@@ -257,7 +257,7 @@ export class NormalBattleHandler {
|
||||
}, true);
|
||||
let { status } = updateResult;
|
||||
|
||||
let actordata = await roleLevelup(roleId, isSuccess ? warInfo.kingExp : 0, session);// 主公升级经验
|
||||
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, isSuccess ? warInfo.kingExp : 0, session);// 主公升级经验
|
||||
|
||||
await checkTaskInBattleEnd(serverId, roleId, sid, funcs, battleId, dbHeroes, star);
|
||||
// 返回值:
|
||||
@@ -317,7 +317,7 @@ export class NormalBattleHandler {
|
||||
let warReward = new WarReward(roleId, roleName, sid, battleId, true);
|
||||
let result = await warReward.saveReward(count);
|
||||
|
||||
let actordata = await roleLevelup(roleId, warInfo.kingExp * count, session)// 主公升级经验
|
||||
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, warInfo.kingExp * count, session)// 主公升级经验
|
||||
|
||||
// 扫荡记录
|
||||
await BattleSweepRecordModel.saveBattleSweepRecordById(roleId, battleId, {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, pinus, HandlerService, } from "pinus";
|
||||
import { resResult, parseGoodStr, getRandSingleEelm } from "../../../pubUtils/util";
|
||||
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE } from "../../../consts";
|
||||
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, KING_EXP_RATIO_TYPE } from "../../../consts";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
import { UserTaskRecModel } from "../../../db/UserTaskRec";
|
||||
import { addItems } from "../../../services/rewardService";
|
||||
@@ -63,8 +63,7 @@ export class ShopHandler {
|
||||
}
|
||||
point = userTask.dailyTaskPoint;
|
||||
weeklyPoint = userTask.dailyTaskPointWeekly;
|
||||
let { lv } = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
expItem = { id: dic.exp.id, count: dic.exp.count * gameData.taskExp.get(lv) };
|
||||
expItem = { id: dic.exp.id, count: dic.exp.count };
|
||||
} else if (type == TASK_FUN_TYPE.ACHIEVEMENT) {
|
||||
let dic = <DicAchievement>dicTask;
|
||||
let userTask = await UserTaskModel.incInfo(roleId, { achievementPoint: dic.point });
|
||||
@@ -81,7 +80,7 @@ export class ShopHandler {
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, taskReward);
|
||||
if (expItem && expItem.count > 0) {
|
||||
await roleLevelup(roleId, expItem.count, session);
|
||||
await roleLevelup(KING_EXP_RATIO_TYPE.TASK, roleId, expItem.count, session);
|
||||
goods.push(expItem);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import Role, { RoleModel, RoleType } from '../db/Role'
|
||||
import { getLvByExp, getExpByLv, gameData, getDicApByLv } from '../pubUtils/data';
|
||||
import { updateUserInfo } from './redisService';
|
||||
import { switchOnFunc } from './funcSwitchService';
|
||||
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS } from '../consts';
|
||||
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS, KING_EXP_RATIO_TYPE } from '../consts';
|
||||
import { BackendSession, pinus } from 'pinus';
|
||||
import { REDIS_KEY } from '../consts';
|
||||
import { Rank } from './rankService';
|
||||
@@ -14,14 +14,15 @@ import { RScriptRecordModel } from '../db/RScriptRecord';
|
||||
import { setAp } from './actionPointService';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
|
||||
export async function roleLevelup(roleId: string, kingExp: number = 0, session: BackendSession) {
|
||||
export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kingExp: number = 0, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
const funcs = session.get('funcs');
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let { lv = 1, exp = 0 } = role;
|
||||
let canGetExp = lv < gameData.maxPlayerLv.max; // 当主公超过最大级后,挑战结算不再获得经验值
|
||||
let newExp = canGetExp ? exp + kingExp : exp;
|
||||
let ratio = gameData.kingExpRaio.get(lv)?.get(type)||0;
|
||||
let newExp = canGetExp ? exp + Math.floor(kingExp * ratio) : exp;
|
||||
let newLv = getLvByExp(newExp);
|
||||
// 等级超过最高级之后,经验依然可以稍微溢出一些,以备下一次提升等级
|
||||
// let nextExpObj = getExpByLv(newLv + 1);
|
||||
|
||||
Reference in New Issue
Block a user