秘境本挑战次数

This commit is contained in:
luying
2020-11-13 18:06:53 +08:00
parent 9574bada4f
commit ada3cfe849
18 changed files with 439 additions and 82 deletions

View File

@@ -77,7 +77,7 @@ export class DailyBattleHandler {
if(vLv > 0) {
timesCanBuy += 0; // 暂留用于处理vip等级增加最大购买次数
}
if(buyCount + 1 > curDaily.timesCanBuy ) {
if(buyCount + count > timesCanBuy ) {
return resResult(STATUS.DAILY_REFRESH_TIMES_LACK)
}
let buyCost = 0;

View File

@@ -0,0 +1,71 @@
import { Application, BackendSession } from 'pinus';
import { GOLD_COST_RATIO, DUNGEON_CONST } from '../../../consts/consts';
import { STATUS } from '../../../consts/statusCode';
import { resResult, calculateNum, shouldRefresh } from '../../../pubUtils/util';
import { RoleModel } from '../../../db/Role';
export default function(app: Application) {
return new DungeonBattleHandler(app);
}
export class DungeonBattleHandler {
constructor(private app: Application) {
}
// 获取关卡列表
async getData(msg: { }, session: BackendSession) {
let roleId = session.get('roleId');
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId);
let curTime = new Date();
if(shouldRefresh(dungeonRefTime, curTime, DUNGEON_CONST.REFRESH_TIME)) {
dungeonCnt = 0; dungeonBuyCnt = 0;
}
let nextCostGold = calculateNum(GOLD_COST_RATIO.DUNGRON_BUY_NUM, {num: dungeonBuyCnt + 1 }, 50);
return resResult(STATUS.SUCCESS, {
nextCostGold,
battleCount: DUNGEON_CONST.MAX_CNT + dungeonBuyCnt - dungeonCnt,
buyCount: DUNGEON_CONST.MAX_BUY_CNT - dungeonBuyCnt
});
}
// 购买每日次数
async buyNum(msg: { count: number }, session: BackendSession) {
let { count } = msg;
const roleId = session.get('roleId');
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId);
let curTime = new Date();
let needRefresh = shouldRefresh(dungeonRefTime, curTime, DUNGEON_CONST.REFRESH_TIME);
if(needRefresh) {
dungeonCnt = 0; dungeonBuyCnt = 0;
}
let timesCanBuy = DUNGEON_CONST.MAX_BUY_CNT;
let { vLv } = await RoleModel.findByRoleId(roleId);
if(vLv > 0) {
timesCanBuy += 0; // 暂留用于处理vip等级增加最大购买次数
}
if(dungeonBuyCnt + count > timesCanBuy ) {
return resResult(STATUS.DUNGEON_REFRESH_TIMES_LACK)
}
let buyCost = 0;
for(let i = 1; i <= count; i++) {
let num = dungeonBuyCnt + i;
buyCost += calculateNum(GOLD_COST_RATIO.DUNGRON_BUY_NUM, {num}, 50);
}
let {gold} = await RoleModel.findByRoleId(roleId);
if(buyCost > gold) {
return resResult(STATUS.DAILY_REFRESH_GOLD_LACK);
}
await RoleModel.costGold(roleId, buyCost);
await RoleModel.buyCnt(roleId, needRefresh, count, curTime);
let nextCostGold = calculateNum(GOLD_COST_RATIO.DUNGRON_BUY_NUM, {num: dungeonBuyCnt + count + 1 }, 50);
return resResult(STATUS.SUCCESS, {
costGold: buyCost,
nextCostGold,
battleCount: DUNGEON_CONST.MAX_CNT + dungeonBuyCnt + count - dungeonCnt,
buyCount: DUNGEON_CONST.MAX_BUY_CNT - dungeonBuyCnt - count
});
}
}

View File

@@ -15,6 +15,7 @@ import { HeroModel } from '../../../db/Hero';
import { RoleModel } from '../../../db/Role';
import { RScriptRecordModel } from '../../../db/RScriptRecord';
import { updateWarStar, checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
import { checkDungeonNum, checkDungeonAndIncrease } from '../../../services/dungeonService';
export default function(app: Application) {
return new NormalBattleHandler(app);
@@ -46,8 +47,9 @@ export class NormalBattleHandler {
// 前置关卡是否挑战过
let previousGk = warInfo.previousGk;
if(previousGk) {
let preBattle = await BattleRecordModel.getBattleRecordByIdAndStatus(roleId, previousGk, 1);
if(!preBattle) return resResult(STATUS.BATTLE_NEED_PREVIOUS_GK);
let {warStar} = await RoleModel.findByRoleId(roleId);
let preBattle = warStar.findIndex(cur => cur.id == previousGk);
if(preBattle == -1) return resResult(STATUS.BATTLE_NEED_PREVIOUS_GK);
}
let checkHeroes = await checkBattleHeroes(roleId, heroes);
@@ -56,6 +58,7 @@ export class NormalBattleHandler {
const battleCode = genCode(8); // 关卡唯一值
let dailyNum = {};
let towerData = {};
let dungeonNum = {};
if(warInfo.warType == WAR_TYPE.DAILY) {
let checkResult = await checkDaily(roleId, battleId, 1);
if(checkResult.status == -1) {
@@ -75,6 +78,12 @@ export class NormalBattleHandler {
if(checkResult.status == -1) {
return checkResult.resResult
}
} else if (warInfo.warType == WAR_TYPE.MYSTERY || warInfo.warType == WAR_TYPE.MYSTERY_ELITE) {
let checkResult = await checkDungeonNum(roleId, 1);
if(checkResult.status == -1) {
return checkResult.resResult
}
dungeonNum = Object.assign(dungeonNum, checkResult.data);
}
const BattleRecord = await BattleRecordModel.updateBattleRecordByCode(battleCode, {
@@ -91,7 +100,7 @@ export class NormalBattleHandler {
return resResult(STATUS.SUCCESS, {
battleId, battleCode, status, apJson, dailyNum, towerData
battleId, battleCode, status, apJson, dailyNum, towerData, dungeonNum
});
}
@@ -176,10 +185,12 @@ export class NormalBattleHandler {
let channelService = this.app.get('channelService');
let warReward = new WarReward(roleId, roleName, battleId, isSuccess);
let dailyNum = {};
let towerRec = null;
let towerStatus = null;
let towerReward = null;
let dungeonNum = {};
if(warInfo.warType == WAR_TYPE.DAILY) {
let checkResult = await checkDailyAndIncrease(roleId, battleId, 1, false);
if(checkResult.status == -1) {
@@ -195,24 +206,27 @@ export class NormalBattleHandler {
if(towerEndResult.status == -1) {
return towerEndResult.resResult;
}
towerRec = towerEndResult.data.newRec;
towerStatus = towerEndResult.data.towerStatus;
towerReward = towerEndResult.data.towerReward;
if(towerEndResult.data.towerReward)
warReward.setFixReward(towerEndResult.data.towerReward)
}
} else if (warInfo.warType == WAR_TYPE.MYSTERY || warInfo.warType == WAR_TYPE.MYSTERY_ELITE) {
let checkResult = await checkDungeonAndIncrease(roleId, 1, false);
if(checkResult.status == -1) {
return checkResult.resResult;
}
dungeonNum = Object.assign(dungeonNum, checkResult.data)
}
let warReward = new WarReward(roleId, roleName, battleId, isSuccess);
if(isSuccess) { // 挑战胜利
// 是否首通
let condition1 = await BattleRecordModel.getBattleRecordByIdAndStatus(roleId, battleId, 1);
let {warStar} = await RoleModel.findByRoleId(roleId);
let condition1 = warStar.find(cur => cur.id == battleId);
if(!condition1) warReward.setCondition(0, true);
// 是否首次3星
if(star == 3) {
let condition2 = await BattleRecordModel.getBattleRecordByIdAndStar(roleId, battleId, 3);
if(!condition2) warReward.setCondition(1, true);
if(star == 3 && (!condition1 || condition1.star != 3)) {
warReward.setCondition(1, true);
}
if(towerReward) warReward.setFixReward(towerReward);
await updateWarStar(roleId, battleId, warInfo.warType, star);
}
@@ -226,20 +240,13 @@ export class NormalBattleHandler {
let actordata = await roleLevelup(roleId, isSuccess?warInfo.kingExp:0);// 主公升级经验
let curHeroes = [];
for(let hid of heroes) {
let hero = await HeroModel.findByHidAndRole(hid, roleId);
curHeroes.push(hero);
}
// 返回值:
// towerStatus: false-本层未通过, true-本层已通过
return resResult(STATUS.SUCCESS, {
battleCode, battleId, status, towerStatus,
battleCode, battleId, status,
...reward,
apJson,
dailyNum,
heroes: curHeroes,
towerStatus, dailyNum, dungeonNum,
...actordata
});
}
@@ -254,8 +261,9 @@ export class NormalBattleHandler {
return resResult(STATUS.BATTLE_MISS_INFO);
}
// 校验是否三星通关过
let condition1 = await BattleRecordModel.getBattleRecordByIdAndStar(roleId, battleId, 3);
if(!condition1) {
let { warStar } = await RoleModel.findByRoleId(roleId);
let curWar = warStar.find(cur => cur.id == battleId);
if(!curWar || curWar.star != 3) {
return resResult(STATUS.BATTLE_SWEEP_CONDITION_STAR);
}
@@ -271,12 +279,19 @@ export class NormalBattleHandler {
// 扫荡次数
let dailyNum = {};
let dungeonNum = {};
if(warInfo.warType == WAR_TYPE.DAILY) {
let checkResult = await checkDailyAndIncrease(roleId, battleId, count, true);
if(checkResult.status == -1) {
return checkResult.resResult
}
dailyNum = Object.assign(dailyNum, checkResult.data)
} else if(warInfo.warType == WAR_TYPE.MYSTERY|| warInfo.warType == WAR_TYPE.MYSTERY_ELITE) {
let checkResult = await checkDungeonAndIncrease(roleId, count, true);
if(checkResult.status == -1) {
return checkResult.resResult
}
dungeonNum = Object.assign(dungeonNum, checkResult.data)
}
// 发奖励
@@ -299,7 +314,7 @@ export class NormalBattleHandler {
battleId, count,
...result,
apJson,
dailyNum,
dailyNum, dungeonNum,
...actordata
});
}

View File

@@ -72,5 +72,5 @@ export async function getDailyNum(dailyRecord: DailyRecord, timesPerDay?: number
if(vLv > 0) {
timesCanBuy += 0; // 暂留用于处理vip等级增加最大购买次数
}
return {count: timesPerDay - count + buyCount, buyCount: timesCanBuy - buyCount}
return {battleCount: timesPerDay - count + buyCount, buyCount: timesCanBuy - buyCount}
}

View File

@@ -0,0 +1,55 @@
/**
* 每日本相关
*/
import { resResult, shouldRefresh } from '../pubUtils/util';
import { STATUS } from '../consts/statusCode';
import { RoleModel } from '../db/Role';
import { DUNGEON_CONST } from '../consts/consts';
// 检查秘境本次数checkBattle使用
export async function checkDungeonNum(roleId: string, inc: number) {
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId);
let curTime = new Date();
let needRefresh = shouldRefresh(dungeonRefTime, curTime, DUNGEON_CONST.REFRESH_TIME);
if(needRefresh) {
dungeonCnt = 0; dungeonBuyCnt = 0;
}
if(dungeonCnt + inc > DUNGEON_CONST.MAX_CNT + 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
}};
}
/**
* 检查秘境本次数并添加warEnd和warSweep使用
* @param roleId
* @param inc 增加的次数
* @param isRef 在计算之前是否检查每日的刷新
*/
export async function checkDungeonAndIncrease(roleId: string, inc: number, isRef: boolean) {
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId);
let curTime = new Date();
let needRefresh = isRef && shouldRefresh(dungeonRefTime, curTime, DUNGEON_CONST.REFRESH_TIME);
if(needRefresh) {
dungeonCnt = 0; dungeonBuyCnt = 0;
}
if(dungeonCnt + inc > DUNGEON_CONST.MAX_CNT + 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
}};
}

View File

@@ -41,29 +41,35 @@ export class WarReward {
}
public setFixReward(reward: string) {
let last = this.fixReward.substr(this.fixReward.length - 1, 1);
if(this.fixReward.length && last == '&') {
let str = this.fixReward;
let last = str.substr(str.length-1, 1);
if(last == '&') str = str.substr(0, str.length - 1);
if(str.length) {
this.fixReward += reward;
} else {
this.fixReward += '&' + reward;
this.fixReward += '|' + reward;
}
}
public setConditionReward(reward: string) {
let last = this.conditionReward.substr(this.fixReward.length - 1, 1);
if(last == '&') {
let str = this.conditionReward;
let last = str.substr(str.length-1, 1);
if(last == '&') str = str.substr(0, str.length - 1);
if(str.length) {
this.conditionReward += reward;
} else {
this.conditionReward += '&' + reward;
this.conditionReward += '|' + reward;
}
}
public setRandomReward(reward: string) {
let last = this.randomReward.substr(this.fixReward.length - 1, 1);
if(last == '&') {
let str = this.randomReward;
let last = str.substr(str.length-1, 1);
if(last == '&') str = str.substr(0, str.length - 1);
if(str.length) {
this.randomReward += reward;
} else {
this.randomReward += '&' + reward;
this.randomReward += '|' + reward;
}
}

View File

@@ -93,7 +93,8 @@ export const WAR_TYPE = {
PVP: 9, // PVP
GUILD_TIMER: 10, // 军团定时副本
GUILD_WEEKLY: 11, // 军团周副本
MAIN_ELITE: 12 // 主线精英
MAIN_ELITE: 12, // 主线精英
MYSTERY_ELITE: 13 // 秘境精英
};
// 事件,是否开启保存随机记录方式
@@ -144,15 +145,21 @@ export const HANG_UP_CONSTS = {
}
export const TOWER_TASK_CONST = {
REFRESH_TIME: 5,
RAND_CNT: 8,
MAX_TASK_REF_CNT: 8, // 完成的派遣数最多
MAX_HEROES_NUM: 3,
COST_GOLD: 50
REFRESH_TIME: 5, // 每天几点刷新
RAND_CNT: 8, // 每次刷新多少个任务
MAX_TASK_REF_CNT: 8, // 完成的派遣任务数最多多少个
MAX_HEROES_NUM: 3, // 每个任务最大派遣武将数
COST_GOLD: 50 // 每次刷新花费的元宝
}
export const DAILY_CONST = {
REFRESH_TIME: 5
REFRESH_TIME: 5 // 每天加点刷新
}
export const DUNGEON_CONST = {
REFRESH_TIME: 5, // 每天加点刷新
MAX_CNT: 10, // 最大挑战次数
MAX_BUY_CNT: 10 // 最大购买次数
}
export const EXPEDITION_CONST = {
@@ -198,7 +205,8 @@ export const GONGSHI = {
* 公式: A * num + B
*/
export const GOLD_COST_RATIO = {
"TOWER_HANG_SPDUP": { "A": 0, "B": 50 },
"TPWER_TASK_REF": { "A": 0, "B": 200 },
"DAILY_REF_NUM": { "A": 50, "B": 0 }
"TOWER_HANG_SPDUP": { "A": 0, "B": 50 }, // 天梯挂机加速花费
"TPWER_TASK_REF": { "A": 0, "B": 200 }, // 天梯派遣刷新花费
"DAILY_REF_NUM": { "A": 50, "B": 0 }, // 每日购买次数花费
"DUNGRON_BUY_NUM": { "A": 0, "B": 50 } // 秘境购买次数花费
}

View File

@@ -28,7 +28,7 @@ export const STATUS = {
DAILY_WAR_NOT_FOUND: { code: 20201, simStr: '未找到该关卡' },
DAILY_TYPE_NOT_FOUND: { code: 20202, simStr: '未找到该类型' },
DAILY_TIMES_LACK: { code: 20203, simStr: '次数不足' },
DAILY_REFRESH_TIMES_LACK: { code: 20203, simStr: '刷新次数不足' },
DAILY_REFRESH_TIMES_LACK: { code: 20203, simStr: '购买次数不足' },
DAILY_REFRESH_GOLD_LACK: { code: 20204, simStr: '元宝不足' },
// 奇遇 20300 - 20399
EVENT_RECORD_NOT_FOUND: { code: 20301, simStr: '未找到记录' },
@@ -71,6 +71,9 @@ export const STATUS = {
TOWER_REF_CNT_NOT_ENOUGH: { code: 20518, simStr: '派遣次数不足' },
// 共斗 20600 - 20699
COM_BATTLE_DUP_ENTER: { code: 20601, simStr: '不能重复加入' },
// 秘境 20700 - 20799
DUNGEON_REFRESH_TIMES_LACK: { code: 20701, simStr: '购买次数不足' },
DUNGEON_TIMES_LACK: { code: 20701, simStr: '挑战次数不足' },
// 养成相关状态 30000 - 39999
// 社交相关状态 40000 - 49999
// 运营模块相关状态 50000 - 59999

View File

@@ -110,6 +110,13 @@ export default class Hero extends BaseModel {
return heroes;
}
public static async updateCe(roleId: string, hid: number, ce: number, oldCe: number, historyCe: number, lean = true) {
let distance = ce - oldCe;
let historyDistance = ce > historyCe ?ce - historyCe: 0;
let result = await HeroModel.findOneAndUpdate({roleId, hid}, {$inc:{ce: distance, historyCe: historyDistance}}).lean(lean);
return result||{};
}
public static async deleteAccount(roleId: string, lean = true) {
let result = await HeroModel.deleteMany({roleId}).lean(lean);
return result||{};

View File

@@ -71,6 +71,12 @@ export default class PvpDefense extends BaseModel {
}
public static async updateCe(roleId: string, hid: number, ce: number, oldCe: number, lean = true) {
let distance = ce - oldCe;
const rec = await PvpDefenseModel.findOneAndUpdate({roleId, 'heroes.actorId': hid}, {$inc: {ce: distance}}).lean(lean);
return rec
}
public static async deleteAccount(roleId: string, lean = true) {
let result = await PvpDefenseModel.deleteMany({roleId}).lean(lean);
return result||{};

View File

@@ -3,6 +3,7 @@ import BaseModel from './BaseModel';
import { index, getModelForClass, prop } from '@typegoose/typegoose';
import User from './User';
import { shouldRefresh } from '../pubUtils/util';
import { HeroModel } from './Hero';
class TopHero {
@prop({ required: true })
@@ -137,6 +138,13 @@ export default class Role extends BaseModel {
@prop({ required: true, default: new Date() })
expeditionResetRefTime: Date; // 远征重置次数刷新时间
// 秘境相关
@prop({ required: true, default: 0 })
dungeonCnt: number; // 秘境挑战次数
@prop({ required: true, default: 0 })
dungeonBuyCnt: number; // 秘境购买次数
@prop({ required: true, default: new Date() })
dungeonRefTime: Date; // 秘境刷新时间
public static async findByUid(uid: number, serverId: number, lean = true) {
const role = await RoleModel.findOne({ 'userInfo.uid': uid, serverId }).lean(lean);
@@ -285,6 +293,30 @@ export default class Role extends BaseModel {
return role;
}
// 购买次数
public static async buyCnt(roleId: string, needRefresh: boolean, inc: number, curTime: Date, lean = true) { console.log('&*&*&*&*&')
let role = null;
if (needRefresh) {
role = await RoleModel.findOneAndUpdate({roleId}, {dungeonCnt: 0, dungeonRefTime: curTime, dungeonBuyCnt: inc}, {new: true}).lean(lean);
} else {
role = await RoleModel.findOneAndUpdate({roleId}, {$inc: {dungeonBuyCnt: inc}}, {new: true}).lean(lean);
}
return role;
}
// 增加次数
public static async increaseDungeonCnt(roleId: string, needRefresh: boolean, inc: number, curTime: Date, lean = true) {
let role = null;
if (needRefresh) {
role = await RoleModel.findOneAndUpdate({roleId}, {dungeonCnt: inc, dungeonRefTime: curTime, dungeonBuyCnt: 0}, {new: true}).lean(lean);
} else {
role = await RoleModel.findOneAndUpdate({roleId}, {$inc: {dungeonCnt: inc}}, {new: true}).lean(lean);
}
return role;
}
// 获取排行榜
public static async getRank(type: string, fields: Array<string>, page = 1, limit = 100, lean = true) {
let sortBy = {};
@@ -295,6 +327,42 @@ export default class Role extends BaseModel {
const ranks = await RoleModel.find().select(fields.join(' ')).sort(sortBy).limit(limit).skip((page - 1) * limit).lean(lean);
return ranks;
}
public static async updateSumCe(roleId: string, hid: number, ce: number, oldCe: number, lean = true) {
let role = await RoleModel.findByRoleId(roleId);
let topFive = role?.topFive||new Array();
let distance = ce - oldCe;
topFive.sort((a, b) => {return b.ce - a.ce}); // 0-5最大-最小
let index = topFive.findIndex(cur => cur.hid == hid);
if(index == -1) { // 不在最强列表
if(topFive.length < 5) { // 不满5人
topFive.push({hid, ce});
} else if(topFive.length == 5){
if(ce > topFive[topFive.length - 1].ce) { // 跻身最强6人
topFive.pop();
topFive.push({hid, ce});
} else {
topFive[index].ce = ce;
}
} else {
topFive.splice(5, topFive.length - 5);
}
} else { // 原来就是最强5人
if(ce < topFive[topFive.length - 1].ce) { // 滑出最强
let heroes = await HeroModel.getTopHero(roleId, 5);
topFive = heroes.map(cur => {return {hid: cur.hid, ce: cur.ce}});
} else {
topFive[index].ce = ce;
}
}
let topFiveCe = topFive.reduce((pre, cur) => {
return pre + cur.ce
}, 0);
await RoleModel.findOneAndUpdate({roleId}, { topFive, topFiveCe, $inc: {ce: distance} }).lean(lean);
}
}
export const RoleModel = getModelForClass(Role);

View File

@@ -3,7 +3,7 @@ import path = require('path');
import { ABI_TYPE } from '../consts/abilityConst';
let gamedata = {};
const wars = ['dic_zyz_gk_main', 'dic_zyz_gk_mainElite', 'dic_zyz_gk_daily', 'dic_zyz_gk_event', 'dic_zyz_gk_tower', 'dic_zyz_gk_expedition']; // 关卡相关的表
const wars = ['dic_zyz_gk_main', 'dic_zyz_gk_mainElite', 'dic_zyz_gk_daily', 'dic_zyz_gk_event', 'dic_zyz_gk_tower', 'dic_zyz_gk_expedition', 'dic_zyz_gk_dungeon','dic_zyz_gk_dungeonElite']; // 关卡相关的表
const allWarInfos = new Map<number, any>();
const towerInfos = new Map<number, any>();
const towerTaskInfos = new Map<number, any>();

View File

@@ -333,38 +333,10 @@ export async function updateCe(roleId: string, hero: any ) {
let ce = actor.calculateCE();
if(ce != oldCe) {
// 更新总战力&最强五人战力
let role = await RoleModel.findByRoleId(roleId);
let distance = ce - oldCe;
let historyDistance = ce > historyCe ?ce - historyCe: 0;
let topFive = role?.topFive||new Array();
topFive.sort((a, b) => {return b.ce - a.ce}); // 0-5最大-最小
let index = topFive.findIndex(cur => cur.hid == hid);
if(index == -1) { // 不在最强列表
if(topFive.length < 5) { // 不满5人
topFive.push({hid, ce});
} else if(topFive.length == 5){
if(ce > topFive[topFive.length - 1].ce) { // 跻身最强6人
topFive.pop();
topFive.push({hid, ce});
} else {
topFive[index].ce = ce;
}
} else {
topFive.splice(5, topFive.length - 5);
}
} else { // 原来就是最强5人
if(ce < topFive[topFive.length - 1].ce) { // 滑出最强
let heroes = await HeroModel.getTopHero(roleId, 5);
topFive = heroes.map(cur => {return {hid: cur.hid, ce: cur.ce}});
} else {
topFive[index].ce = ce;
}
}
let topFiveCe = topFive.reduce((pre, cur) => {
return pre + cur.ce
}, 0);
await RoleModel.findOneAndUpdate({roleId}, { topFive, topFiveCe, $inc: {ce: distance} });
await PvpDefenseModel.findOneAndUpdate({roleId, 'heroes.actorId': hid}, {$inc: {ce: distance}});
await HeroModel.findOneAndUpdate({roleId, hid}, {$inc:{ce: distance, historyCe: historyDistance}})
await RoleModel.updateSumCe(roleId, hid, ce, oldCe);
// 更新pvp防守阵容战力
await PvpDefenseModel.updateCe(roleId, hid, ce, oldCe);
// 更新武将战力,历史最高战力
await HeroModel.updateCe(roleId, hid, ce, oldCe, historyCe);
}
}

View File

@@ -0,0 +1,40 @@
[
{
"war_id": 3001,
"dispatchJsonId": 3001,
"bg_img_id": 501,
"script_id": 0,
"fixReward": "10205&1|17001&10|17005&2|17006&3",
"warType": 6,
"gk_name": "秘境&怒狼洞穴1",
"kingExp": 100,
"turnLimted": 20,
"forcedCharactor": "&",
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"cost": 0,
"recommendedPower": 10008,
"previousGk": 127
},
{
"war_id": 3002,
"dispatchJsonId": 3002,
"bg_img_id": 501,
"script_id": 0,
"fixReward": "10005&1|17002&10|17007&2|17008&3",
"warType": 6,
"gk_name": "秘境&怒狼洞穴2",
"kingExp": 100,
"turnLimted": 20,
"forcedCharactor": "&",
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"cost": 0,
"recommendedPower": 10008,
"previousGk": 3001
}
]

View File

@@ -0,0 +1,40 @@
[
{
"war_id": 3010,
"dispatchJsonId": 3010,
"bg_img_id": 501,
"script_id": 0,
"fixReward": "10205&1|17001&10|17005&2|17006&3",
"warType": 13,
"gk_name": "秘境&怒狼洞穴1",
"kingExp": 100,
"lvLimted": 10,
"forcedCharactor": "&",
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"cost": 0,
"recommendedPower": 10008,
"previousGk": 3001
},
{
"war_id": 3011,
"dispatchJsonId": 3011,
"bg_img_id": 501,
"script_id": 0,
"fixReward": "10005&1|17002&10|17007&2|17008&3",
"warType": 13,
"gk_name": "秘境&怒狼洞穴2",
"kingExp": 100,
"lvLimted": 10,
"forcedCharactor": "&",
"fobiddenCharactor": "&",
"victoryInfoInUI": "消灭所有敌军",
"loseInfoInUI": "我方全部阵亡",
"starInfoInUI": "1.我方无人阵亡;\r\n2.在5回合内获得胜利",
"cost": 0,
"recommendedPower": 10008,
"previousGk": 3002
}
]

6
web-server/typings/app/index.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
// This file is created by egg-ts-helper@1.25.8
// Do not modify this file!!!!!!!!!
import 'egg';
export * from 'egg';
export as namespace Egg;

View File

@@ -0,0 +1,21 @@
// This file is created by egg-ts-helper@1.25.8
// Do not modify this file!!!!!!!!!
import 'egg';
type AnyClass = new (...args: any[]) => any;
type AnyFunc<T = any> = (...args: any[]) => T;
type CanExportFunc = AnyFunc<Promise<any>> | AnyFunc<IterableIterator<any>>;
type AutoInstanceType<T, U = T extends CanExportFunc ? T : T extends AnyFunc ? ReturnType<T> : T> = U extends AnyClass ? InstanceType<U> : U;
import ExportAuth from '../../../app/service/Auth';
import ExportTest from '../../../app/service/Test';
import ExportTurboCore from '../../../app/service/TurboCore';
import ExportUtils from '../../../app/service/Utils';
declare module 'egg' {
interface IService {
auth: AutoInstanceType<typeof ExportAuth>;
test: AutoInstanceType<typeof ExportTest>;
turboCore: AutoInstanceType<typeof ExportTurboCore>;
utils: AutoInstanceType<typeof ExportUtils>;
}
}

39
web-server/typings/config/plugin.d.ts vendored Normal file
View File

@@ -0,0 +1,39 @@
// This file is created by egg-ts-helper@1.25.8
// Do not modify this file!!!!!!!!!
import 'egg';
import 'egg-onerror';
import 'egg-session';
import 'egg-i18n';
import 'egg-watcher';
import 'egg-multipart';
import 'egg-security';
import 'egg-development';
import 'egg-logrotator';
import 'egg-schedule';
import 'egg-static';
import 'egg-jsonp';
import 'egg-view';
import 'egg-view-nunjucks';
import 'egg-cors';
import 'egg-alinode';
import { EggPluginItem } from 'egg';
declare module 'egg' {
interface EggPlugin {
onerror?: EggPluginItem;
session?: EggPluginItem;
i18n?: EggPluginItem;
watcher?: EggPluginItem;
multipart?: EggPluginItem;
security?: EggPluginItem;
development?: EggPluginItem;
logrotator?: EggPluginItem;
schedule?: EggPluginItem;
static?: EggPluginItem;
jsonp?: EggPluginItem;
view?: EggPluginItem;
nunjucks?: EggPluginItem;
cors?: EggPluginItem;
alinode?: EggPluginItem;
}
}