战斗:参数改为使用系统参数表
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user