战斗:参数改为使用系统参数表
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { DailyRecordModel } from '../../../db/DailyRecord';
|
||||
import { GOLD_COST_RATIO } from '../../../consts';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult, calculateNum } from '../../../pubUtils/util';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { getDailyNum, getDailyBattleList } from '../../../services/dailyBattleService';
|
||||
import { getDailyNum, getDailyBattleList, getDailyBuyCountCost } from '../../../services/dailyBattleService';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
@@ -48,7 +47,7 @@ export class DailyBattleHandler {
|
||||
let buyCost = 0;
|
||||
for(let i = 1; i <= count; i++) {
|
||||
let num = buyCount + i;
|
||||
buyCost += calculateNum(GOLD_COST_RATIO.DAILY_REF_NUM, {num}, 50);
|
||||
buyCost += getDailyBuyCountCost(num);
|
||||
}
|
||||
let {gold} = await RoleModel.findByRoleId(roleId);
|
||||
if(buyCost > gold) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { GOLD_COST_RATIO, DUNGEON_CONST } from '../../../consts';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult, calculateNum, shouldRefresh } from '../../../pubUtils/util';
|
||||
import { resResult, shouldRefresh } from '../../../pubUtils/util';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { getDungeonData } from '../../../services/dungeonService';
|
||||
import { getDungeonData, getDungeonBuyCountCost } from '../../../services/dungeonService';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new DungeonBattleHandler(app);
|
||||
@@ -37,7 +37,7 @@ export class DungeonBattleHandler {
|
||||
dungeonCnt = 0; dungeonBuyCnt = 0;
|
||||
}
|
||||
|
||||
let timesCanBuy = DUNGEON_CONST.MAX_BUY_CNT;
|
||||
let timesCanBuy = dicParam.DUNGEON_CONST.DUNGEON_CONST_BUY;
|
||||
let { vLv } = await RoleModel.findByRoleId(roleId);
|
||||
if(vLv > 0) {
|
||||
timesCanBuy += 0; // 暂留,用于处理vip等级增加最大购买次数
|
||||
@@ -47,8 +47,7 @@ export class DungeonBattleHandler {
|
||||
}
|
||||
let buyCost = 0;
|
||||
for(let i = 1; i <= count; i++) {
|
||||
let num = dungeonBuyCnt + i;
|
||||
buyCost += calculateNum(GOLD_COST_RATIO.DUNGRON_BUY_NUM, {num}, 50);
|
||||
buyCost += getDungeonBuyCountCost(dungeonBuyCnt + i);
|
||||
}
|
||||
let {gold} = await RoleModel.findByRoleId(roleId);
|
||||
if(buyCost > gold) {
|
||||
@@ -57,12 +56,12 @@ export class DungeonBattleHandler {
|
||||
await handleCost(roleId, sid, [getGoldObject(buyCost)]);
|
||||
await RoleModel.buyCnt(roleId, needRefresh, count, curTime);
|
||||
|
||||
let nextCostGold = calculateNum(GOLD_COST_RATIO.DUNGRON_BUY_NUM, {num: dungeonBuyCnt + count + 1 }, 50);
|
||||
let nextCostGold = getDungeonBuyCountCost(dungeonBuyCnt + count + 1);
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
costGold: buyCost,
|
||||
nextCostGold,
|
||||
battleCount: DUNGEON_CONST.MAX_CNT + dungeonBuyCnt + count - dungeonCnt,
|
||||
buyCount: DUNGEON_CONST.MAX_BUY_CNT - dungeonBuyCnt - count
|
||||
battleCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt + count - dungeonCnt,
|
||||
buyCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_BUY - dungeonBuyCnt - count
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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, KING_EXP_RATIO_TYPE, LINEUP_NUM, TASK_TYPE } from '../../../consts';
|
||||
import { 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';
|
||||
@@ -15,6 +15,7 @@ import { resResult } from '../../../pubUtils/util';
|
||||
import { checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
|
||||
import { checkActivityTask, checkTask, checkTaskInBattleEnd } from '../../../services/taskService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -226,7 +227,7 @@ export class ExpeditionBattleHandler {
|
||||
$set: { status: isSuccess ? 1 : 2, star }
|
||||
}, true);
|
||||
// 更新点数
|
||||
role = await RoleModel.increaseExpeditionPoint(roleId, isSuccess ? EXPEDITION_CONST.INCREASE_POINT : 0);
|
||||
role = await RoleModel.increaseExpeditionPoint(roleId, isSuccess ? dicParam.EXPEDITION_CONST.EXPEDITION_CONST_POINTS : 0);
|
||||
let { expeditionPoint = 0 } = role;
|
||||
|
||||
// 关卡奖励
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { STATUS } from './../../../consts/statusCode';
|
||||
import { HANG_UP_CONSTS, GOLD_COST_RATIO, REDIS_KEY } from './../../../consts';
|
||||
import { HANG_UP_CONSTS, REDIS_KEY } from './../../../consts';
|
||||
import { TowerTaskRecModel, TowerTaskRecType } from './../../../db/TowerTaskRec';
|
||||
import { HangUpSpdUpRecModel } from './../../../db/HangUpSpdUpRec';
|
||||
import { HangUpRecordModel } from './../../../db/HangUpRecord';
|
||||
import { RoleModel } from './../../../db/Role';
|
||||
import { TowerRecordModel } from './../../../db/TowerRecord';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult, shouldRefresh, calculateNum, genCode } from '../../../pubUtils/util';
|
||||
import { resResult, shouldRefresh, genCode } from '../../../pubUtils/util';
|
||||
import { calcuHangUpReward, checkTaskConditions, checkHangUpSpdUpCnt, refreshTasks, treatTask, getRemainTime, getDoingOrWaitingTasks, getTowerStatus, getHungupRewards, getTasks, checkTaskRewards, getTowerTaskCostGold, getHangSpdUpCostGold, getManyHangSpdUpCostGold } from '../../../services/battleService';
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
import { checkBattleHeroes } from '../../../services/normalBattleService';
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { HeroModel } from './../db/Hero';
|
||||
import { HangUpRecordModel } from './../db/HangUpRecord';
|
||||
import { pinus } from 'pinus';
|
||||
import { HANG_UP_CONSTS, REDIS_KEY, TASK_TYPE, TOWER_FORBIDDEN_CHARA_TYPE, TOWER_TASK_STATUS, MAIL_TYPE } from './../consts';
|
||||
import { BattleRecordModel } from './../db/BattleRecord';
|
||||
import { TowerRecordModel } from './../db/TowerRecord';
|
||||
import { RoleModel, RoleType } from './../db/Role';
|
||||
import { shouldRefresh, resResult, cal, getRandEelmWithWeight, calculateNum, genCode, getRandEelm } from '../pubUtils/util';
|
||||
import { shouldRefresh, resResult, cal, getRandEelmWithWeight, genCode, } from '../pubUtils/util';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { HangUpSpdUpRecModel } from '../db/HangUpSpdUpRec';
|
||||
import { TowerTaskRecModel, TowerTaskRecType } from '../db/TowerTaskRec';
|
||||
@@ -212,7 +211,7 @@ export async function towerBattleEnd(sid: string, funcs: number[], roleId: strin
|
||||
|
||||
let { towerLv, roleName } = await RoleModel.findByRoleId(roleId);
|
||||
let { warStatus, heroes: recHeroes } = await TowerRecordModel.getRecordByLv(roleId, towerLv);
|
||||
console.log('*******', towerLv, heroes.join(), recHeroes.join())
|
||||
// console.log('*******', towerLv, heroes.join(), recHeroes.join())
|
||||
for (let hid of heroes) {
|
||||
if (recHeroes.indexOf(hid) !== -1) {
|
||||
return { status: -1, resResult: resResult(STATUS.TOWER_DUPLICATE_HERO) };
|
||||
|
||||
@@ -9,6 +9,7 @@ import { RoleModel, RoleType } from '../db/Role';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { DicWar } from '../pubUtils/dictionary/DicWar';
|
||||
import { WarStar } from '../domain/dbGeneral';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
|
||||
/**
|
||||
* 获取全部每日关卡列表
|
||||
@@ -121,4 +122,17 @@ export async function getDailyNum(dailyRecord: DailyRecord, timesPerDay?: number
|
||||
timesCanBuy += 0; // 暂留,用于处理vip等级增加最大购买次数
|
||||
}
|
||||
return {count: timesPerDay - count + buyCount, buyCount: timesCanBuy - buyCount}
|
||||
}
|
||||
|
||||
/**
|
||||
* 每日购买次数的花费
|
||||
* @param num 如果没有买过次数,那么这里算第一次,传1
|
||||
* @returns
|
||||
*/
|
||||
export function getDailyBuyCountCost(num: number) {
|
||||
let cost = ( num - 1 ) * dicParam.DAILY_CONST.DAILY_CONST_UP + dicParam.DAILY_CONST.DAILY_CONST_BASE;
|
||||
if(cost > dicParam.DAILY_CONST.DAILY_CONST_TOP) {
|
||||
cost = dicParam.DAILY_CONST.DAILY_CONST_TOP;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
* 每日本相关
|
||||
*/
|
||||
|
||||
import { resResult, shouldRefresh, calculateNum } from '../pubUtils/util';
|
||||
import { resResult, shouldRefresh, } from '../pubUtils/util';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { RoleModel, RoleType } from '../db/Role';
|
||||
import { DUNGEON_CONST, GOLD_COST_RATIO } from '../consts';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
|
||||
/**
|
||||
* 获取秘境本数据
|
||||
@@ -18,12 +18,12 @@ export async function getDungeonData(role: RoleType) {
|
||||
dungeonCnt = 0; dungeonBuyCnt = 0;
|
||||
}
|
||||
|
||||
let nextCostGold = calculateNum(GOLD_COST_RATIO.DUNGRON_BUY_NUM, {num: dungeonBuyCnt + 1 }, 50);
|
||||
let nextCostGold = getDungeonBuyCountCost(dungeonBuyCnt + 1);
|
||||
return {
|
||||
nextCostGold,
|
||||
dungeonHeroes,
|
||||
battleCount: DUNGEON_CONST.MAX_CNT + dungeonBuyCnt - dungeonCnt,
|
||||
buyCount: DUNGEON_CONST.MAX_BUY_CNT - dungeonBuyCnt
|
||||
battleCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt - dungeonCnt,
|
||||
buyCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_BUY - dungeonBuyCnt
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,14 @@ export async function checkDungeonNum(roleId: string, inc: number) {
|
||||
if(needRefresh) {
|
||||
dungeonCnt = 0; dungeonBuyCnt = 0;
|
||||
}
|
||||
if(dungeonCnt + inc > DUNGEON_CONST.MAX_CNT + dungeonBuyCnt) {
|
||||
if(dungeonCnt + inc > dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt) {
|
||||
return {status: -1, resResult: resResult(STATUS.DUNGEON_TIMES_LACK)}
|
||||
}
|
||||
await RoleModel.increaseDungeonCnt(roleId, needRefresh, 0, curTime);
|
||||
|
||||
return { status: 0, data: {
|
||||
battleCount: DUNGEON_CONST.MAX_CNT + dungeonBuyCnt - dungeonCnt,
|
||||
buyCount: DUNGEON_CONST.MAX_BUY_CNT - dungeonBuyCnt
|
||||
battleCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt - dungeonCnt,
|
||||
buyCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_BUY - dungeonBuyCnt
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -63,13 +63,26 @@ export async function checkDungeonAndIncrease(roleId: string, inc: number, isRef
|
||||
dungeonCnt = 0; dungeonBuyCnt = 0;
|
||||
}
|
||||
|
||||
if(dungeonCnt + inc > DUNGEON_CONST.MAX_CNT + dungeonBuyCnt ) {
|
||||
if(dungeonCnt + inc > dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt ) {
|
||||
return { status: -1, resResult: resResult(STATUS.DUNGEON_TIMES_LACK) }
|
||||
}
|
||||
// console.log('needRefresh', needRefresh);
|
||||
await RoleModel.increaseDungeonCnt(roleId, needRefresh, inc, curTime);
|
||||
return {status: 1, data: {
|
||||
battleCount: DUNGEON_CONST.MAX_CNT + dungeonBuyCnt - dungeonCnt - inc,
|
||||
buyCount: DUNGEON_CONST.MAX_BUY_CNT - dungeonBuyCnt
|
||||
battleCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_FREE + dungeonBuyCnt - dungeonCnt - inc,
|
||||
buyCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_BUY - dungeonBuyCnt
|
||||
}};
|
||||
}
|
||||
|
||||
/**
|
||||
* 秘境购买次数的花费
|
||||
* @param num 如果没有买过次数,那么这里算第一次,传1
|
||||
* @returns
|
||||
*/
|
||||
export function getDungeonBuyCountCost(num:number) {
|
||||
let cost = (num - 1) * dicParam.DUNGEON_CONST.DUNGEON_CONST_UP + dicParam.DUNGEON_CONST.DUNGEON_CONST_BASE;
|
||||
if(cost > dicParam.DUNGEON_CONST.DUNGEON_CONST_TOP) {
|
||||
cost = dicParam.DUNGEON_CONST.DUNGEON_CONST_TOP;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import Role, { RoleModel, RoleType } from '../db/Role';
|
||||
import { PvpDefenseModel } from '../db/PvpDefense';
|
||||
|
||||
import { shouldRefresh, calculateSumCE, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { EXPEDITION_CONST, LINEUP_NUM, EXPEDITION_WAR_RECORD_STATUS, ABI_TYPE } from '../consts';
|
||||
import { LINEUP_NUM, EXPEDITION_WAR_RECORD_STATUS, ABI_TYPE } from '../consts';
|
||||
import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord';
|
||||
import { HeroType } from '../db/Hero';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
@@ -12,6 +12,7 @@ import { getPlayerAttribute, getRobotAttribute } from './pvpService';
|
||||
import { getTimeFunD } from '../pubUtils/timeUtil';
|
||||
import { ExpeditionRecordModel } from '../db/ExpeditionRecord';
|
||||
import { Attribute } from '../domain/roleField/attribute';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
|
||||
/**
|
||||
* 获取远征关卡列表
|
||||
@@ -260,7 +261,7 @@ export async function getResetRemainCnt(curTime: Date, roleId: string, role?: Ro
|
||||
expeditionResetCnt = 0; expeditionResetRefTime = curTime;
|
||||
}
|
||||
|
||||
let maxCnt = EXPEDITION_CONST.RESET_CNT;
|
||||
let maxCnt = dicParam.EXPEDITION_CONST.EXPEDITION_CONST_TIMES;
|
||||
|
||||
return {
|
||||
resetCnt: maxCnt - expeditionResetCnt,
|
||||
|
||||
Reference in New Issue
Block a user