演武台:boss血量修改

This commit is contained in:
luying
2022-02-25 17:23:58 +08:00
parent 153633b9f1
commit de0b74e0cd
10 changed files with 96 additions and 34 deletions

View File

@@ -25,6 +25,9 @@ import { getExpByLv } from '../../../pubUtils/data';
import { reportTAUserSet } from '../../../services/sdkService';
import { saveLoginAndOutLog } from '../../../pubUtils/logUtil';
import { JewelModel } from '../../../db/Jewel';
import { GuildModel } from '../../../db/Guild';
import { GuildRecModel } from '../../../db/GuildRec';
import { ServerRecordModel } from '../../../db/ServerRecords';
export default function (app: Application) {
new HandlerService(app, {});

View File

@@ -4,7 +4,7 @@ import { AUCTION_SOURCE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON, MAIL_TYPE, STATUS
import { BossInstanceModel } from '../../../db/BossInstance';
import { BattleRecordModel } from '../../../db/BattleRecord';
import { nowSeconds, getZeroPoint, getSeconds } from '../../../pubUtils/timeUtil';
import { getBossInstanceInfo, checkBossBattleMemberExists, pushBossHpMessage, addBossInstance, refreshUserGuildOfBoss, refreshGuildOfBoss, getRanks, getBossInstanceInfoByData } from '../../../services/guildBossService';
import { getBossInstanceInfo, checkBossBattleMemberExists, pushBossHpMessage, addBossInstance, refreshUserGuildOfBoss, refreshGuildOfBoss, getBossHp, getBossInstanceInfoByData } from '../../../services/guildBossService';
import { findWhere } from 'underscore'
import { GUILD_STRUCTURE, GUILD_BOSS_STATUS, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
import { DATA_NAME } from '../../../consts/dataName';
@@ -62,13 +62,10 @@ export class GuildHandler {
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
}
let bossBase = getBossByLv(curStructure.lv);
let { bossHp: minBossHp, warId } = getRandSingleEelm(bossBase.wars);
let medianCe = await getPreDayActiveData(serverId);
let dicBossBaseWar = getRandSingleEelm(bossBase.wars);
// let bossHp = Math.ceil(medianCe * bossBase.ratio);
let bossHp = 10000;
let bossHp = await getBossHp(serverId, code, dicBossBaseWar);
console.log('******* openBossInstance', medianCe, bossHp, minBossHp)
if(bossHp < minBossHp) bossHp = minBossHp;
let resGuild = await GuildModel.costFund(code, bossBase.opencost);
if (!resGuild) {
res.releaseCallback();
@@ -87,7 +84,7 @@ export class GuildHandler {
}
await refreshGuildOfBoss(guild, 1);
bossInstance = await BossInstanceModel.openBossInstance(code, bossHp, warId, bossBase.bossLevel);
bossInstance = await BossInstanceModel.openBossInstance(code, bossHp, dicBossBaseWar.warId, bossBase.bossLevel);
res.releaseCallback();
let result = await getBossInstanceInfoByData(bossInstance, userGuild, guild);

View File

@@ -27,7 +27,7 @@ import { UserGuildModel } from "../../db/UserGuild";
import { raceActivityEnd } from "../timeTaskService";
import { addActive } from "../guildService";
import { checkTask, checkActivityTask } from "../taskService";
import { ActivePlayer, ServerRecordModel } from "../../db/ServerRecords";
import { ActivePlayer, GuildRecord, ServerRecordModel } from "../../db/ServerRecords";
import { Attack } from "../../domain/battleField/pvp";
let gateActivityObj: GateActivityObject;
@@ -63,13 +63,27 @@ export async function setPreDayActiveData() {
for (let server of servers) {
let roles = await RoleModel.getActivePlayers(server.id);
let activePlayerCnt = roles.length;
let activePlayerCe = 0, activePlayers: ActivePlayer[] = []
for(let i = 0; i < 10; i++) {
if(!roles[i]) break;
activePlayerCe += roles[i].topLineupCe;
activePlayers.push(new ActivePlayer(roles[i]));
}
await ServerRecordModel.updateData(server.id, { activePlayerCnt, activePlayerCe: reduceCe(activePlayerCe), activePlayers });
let activePlayerCe = 0, activePlayers: ActivePlayer[] = [];
let activeGuilds: GuildRecord[] = [];
for(let i = 0; i < roles.length; i++) {
let role = roles[i];
let activePlayer = new ActivePlayer(role);
if(i < 10) {
activePlayerCe += role.topLineupCe;
activePlayers.push(activePlayer);
}
if(role.hasGuild) {
let guildRecord = activeGuilds.find(cur => cur.guildCode == role.guildCode);
if(!guildRecord) {
activeGuilds.push({ guildCode: role.guildCode, players: [activePlayer] });
} else {
guildRecord.players.push(activePlayer);
}
}
}
await ServerRecordModel.updateData(server.id, { activePlayerCnt, activePlayerCe: reduceCe(activePlayerCe), activePlayers, activeGuilds });
}
return servers;
}

View File

@@ -4,16 +4,18 @@ import { findIndex } from 'underscore';
import { sismemberAsync, smembersAsync, saddAsync, delAsync, getRoleOnlineInfo } from '../services/redisService';
import { pinus } from 'pinus';
import { STATUS } from '../consts/statusCode';
import { resResult, shouldRefresh } from '../pubUtils/util';
import { reduceCe, resResult, shouldRefresh } from '../pubUtils/util';
import { BattleRecordModel } from '../db/BattleRecord';
import { getArmyBossRank, gameData, getAuctionRewardByPoolId } from '../pubUtils/data';
import { sendMailToGuildByContent } from '../services/mailService';
import { MAIL_TYPE, AUCTION_SOURCE } from '../consts';
import { MAIL_TYPE, AUCTION_SOURCE, ABI_TYPE } from '../consts';
import { GUILD_BOSS_STATUS } from '../consts/constModules/guildConst';
import { genAuction } from './auctionService';
import { GuildModel, GuildType } from '../db/Guild';
import { UserGuildModel, UserGuildType } from '../db/UserGuild';
import { nowSeconds } from '../pubUtils/timeUtil';
import { GUILDACTIVITY } from '../pubUtils/dicParam';
import { ServerRecordModel } from '../db/ServerRecords';
/**
* 获得boss界面
@@ -170,3 +172,34 @@ export async function checkBossBattleMemberExists(code: string, serverId:number,
export async function removeBossRank(guildCode: string, roleId: string) {
await BossInstanceModel.removeBossRank(guildCode, roleId);
}
export async function getBossHp(serverId: number, guildCode: string, dicBossBaseWar: {warId: number, bossHp: number, bossHpRatio: number }) {
let { warId, bossHp: minBossHp, bossHpRatio } = dicBossBaseWar;
let serverRecord = await ServerRecordModel.findTodayData(serverId);
if(!serverRecord) return minBossHp;
let dicWarJson = gameData.warJson.get(warId);
let actorId = gameData.heroIdByWar.get(warId);
let dicBoss = dicWarJson.find(cur => cur.bossStage == actorId);
let attribute = dicBoss?.attribute||[];
let hp = attribute.find(cur => cur.id == ABI_TYPE.ABI_HP)?.val||0;
let activeGuilds = serverRecord.activeGuilds||[];
let myGuild = activeGuilds.find(cur => cur.guildCode == guildCode);
let activeCe = 0;
if(myGuild) {
let activePlayers = myGuild.players||[];
activePlayers.sort((a, b) => b.ce - a.ce);
for(let i = 0; i < 10; i++) {
if(!activePlayers[i]) break;
activeCe += activePlayers[i].topLineupCe;
}
}
activeCe = reduceCe(activeCe);
let B = activeCe/6/GUILDACTIVITY.GATEACTIVITY_ENEMYCE;
let bossBaseHp = B * hp;
let bossHp = Math.floor(bossBaseHp * bossHpRatio);
return bossHp;
}

View File

@@ -699,7 +699,7 @@ export default class Role extends BaseModel {
public static async getActivePlayers(serverId: number) {
let yesterday = <Date>getTimeFunD().getBeforeDayWithHour(1);
const roles: RoleType[] = await RoleModel.find({ serverId, updatedAt: { $gte: yesterday } })
.select('topLineup topLineupCe')
.select('roleId ce topLineup topLineupCe guildCode hasGuild')
.sort({ ce: -1 }).lean();
return roles
}

View File

@@ -7,17 +7,26 @@ export class ActivePlayer {
@prop({ required: true })
roleId: string;
@prop({ required: true })
ce: number;
@prop({ required: true })
topLineupCe: number;
@prop({ required: true, type: TopHero, default: [], _id: false })
topLineup: Array<TopHero>; // 总战力
constructor(role: RoleType) {
this.roleId = role.roleId;
this.ce = role.ce;
this.topLineupCe = role.topLineupCe;
this.topLineup = role.topLineup;
}
}
export class GuildRecord {
@prop({ required: true })
guildCode: string;
@prop({ required: true, type: ActivePlayer, _id: false })
players: ActivePlayer[];
}
/**
* 游戏字段接口
@@ -44,16 +53,18 @@ export default class ServerRecord extends BaseModel {
@prop({ required: true, type: String, default: [] })
activeGuildCodes: string[]; // 前一天参与军团活动的军团
@prop({ required: true, type: GuildRecord, _id: false })
activeGuilds: GuildRecord[];
public static async updateData(serverId: number, update: ServerRecordUpdate) {
let today = getZeroPoint();
const doc = new ServerRecordModel();
let rec: ServerRecordType = await ServerRecordModel.findOneAndUpdate({ serverId, today }, { $set: { ...doc.toJSON(), ...update } }, { new: true, upsert: true }).lean();
let rec: ServerRecordType = await ServerRecordModel.findOneAndUpdate({ serverId, today }, { $set: update }, { new: true, upsert: true }).lean();
return rec;
}
public static async addActiveGuild(serverId: number, guildCode: string) {
let tomorrow = getZeroPoint() + 86400;
let rec: ServerRecordType = await ServerRecordModel.findOneAndUpdate({ serverId, today: tomorrow }, { $addToSet: [guildCode] }, { new: true, upsert: true }).lean();
let rec: ServerRecordType = await ServerRecordModel.findOneAndUpdate({ serverId, today: tomorrow }, { $addToSet: { activeGuildCodes: guildCode } }, { new: true, upsert: true }).lean();
return rec;
}

View File

@@ -12,7 +12,7 @@ import { dicQuestion, loadQuestion } from "./dictionary/DicQuestion";
import { dicSe, loadSe } from "./dictionary/DicSe";
import { dicTower, loadTower } from "./dictionary/DicTower";
import { dicTowerTask, loadTowerTask } from "./dictionary/DicTowerTask";
import { dicWar, dicWarPvp, dicDailyWarByType, loadWar } from "./dictionary/DicWar";
import { dicWar, dicWarPvp, dicDailyWarByType, loadWar, dicHeroIdByWar } from "./dictionary/DicWar";
import { dicWarJson, loadWarJson } from "./dictionary/DicWarJson";
import { dicXunbao, loadXunbao } from "./dictionary/DicXunbao";
import { AUCTION_TIME } from "../consts";
@@ -247,6 +247,7 @@ export const gameData = {
jewelCondition: dicJewelCondition,
blueprt: dicBlueprt,
blueprtByLv: dicBlueprtByLv,
heroIdByWar: dicHeroIdByWar,
};
// 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据

View File

@@ -49,7 +49,7 @@ export interface DicBossBase {
// boss等级
readonly bossLevel: number;
// 关卡id
readonly wars: Array<{warId:number, bossHp:number}>;
readonly wars: Array<{warId:number, bossHp: number, bossHpRatio:number}>;
// 掉落的拍卖行奖励
readonly rewards: number;
//
@@ -204,7 +204,7 @@ export function loadStructure() {
return;
}
let warArr = warStrs.split('&');
return { warId: parseInt(warArr[0]), bossHp: parseInt(warArr[1])}
return { warId: parseInt(warArr[0]), bossHp: parseInt(warArr[1]), bossHpRatio: parseInt(warArr[2])}
});
o.killReward = parseGoodStr(o.killReward);
o.basicReward = parseGoodStr(o.basicReward);

View File

@@ -54,10 +54,12 @@ export interface DicWar {
export const dicWar = new Map<number, DicWar>();
export const dicWarPvp = new Array<DicWar>();
export const dicDailyWarByType = new Map<number, DicWar[]>();
export const dicHeroIdByWar = new Map<number, number>();
export function loadWar() {
dicWar.clear();
dicDailyWarByType.clear();
dicWarPvp.splice(0, dicWarPvp.length);
dicHeroIdByWar.clear();
for(let filename of WAR_RELATE_TABLES) {
let arr = readFileAndParse(filename);
@@ -93,6 +95,7 @@ export function loadWar() {
o.failReward = parseTrainReward(o.failReward);
}
dicWar.set(o.war_id, o);
if(!!o.heroId) dicHeroIdByWar.set(o.war_id, o.heroId);
});
}
}

View File

@@ -4,7 +4,7 @@
"structureId": 3,
"level": 1,
"bossLevel": 10,
"warIdHP": "8001&10000000|8002&10000000",
"warIdHP": "8001&10000000&10|8002&10000000&10",
"rewards": 1,
"consume": 50000,
"buildWords": "&",
@@ -22,7 +22,7 @@
"structureId": 3,
"level": 2,
"bossLevel": 20,
"warIdHP": "8005&20000000|8006&20000000",
"warIdHP": "8005&20000000&20|8006&20000000&20",
"rewards": 1,
"consume": 125000,
"buildWords": "&",
@@ -40,7 +40,7 @@
"structureId": 3,
"level": 3,
"bossLevel": 30,
"warIdHP": "8009&30000000|8010&30000000",
"warIdHP": "8009&30000000&30|8010&30000000&30",
"rewards": 2,
"consume": 350000,
"buildWords": "&",
@@ -58,7 +58,7 @@
"structureId": 3,
"level": 4,
"bossLevel": 40,
"warIdHP": "8013&40000000|8014&40000000",
"warIdHP": "8013&40000000&40|8014&40000000&40",
"rewards": 2,
"consume": 800000,
"buildWords": "&",
@@ -76,7 +76,7 @@
"structureId": 3,
"level": 5,
"bossLevel": 50,
"warIdHP": "8017&50000000|8018&50000000",
"warIdHP": "8017&50000000&50|8018&50000000&50",
"rewards": 2,
"consume": 1700000,
"buildWords": "&",
@@ -94,7 +94,7 @@
"structureId": 3,
"level": 6,
"bossLevel": 60,
"warIdHP": "8021&60000000|8022&60000000",
"warIdHP": "8021&60000000&60|8022&60000000&60",
"rewards": 2,
"consume": 3500000,
"buildWords": "&",
@@ -112,7 +112,7 @@
"structureId": 3,
"level": 7,
"bossLevel": 70,
"warIdHP": "8025&70000000|8026&70000000",
"warIdHP": "8025&70000000&65|8026&70000000&65",
"rewards": 3,
"consume": 6125000,
"buildWords": "&",
@@ -130,7 +130,7 @@
"structureId": 3,
"level": 8,
"bossLevel": 80,
"warIdHP": "8029&80000000|8030&80000000",
"warIdHP": "8029&80000000&70|8030&80000000&70",
"rewards": 3,
"consume": 9125000,
"buildWords": "&",
@@ -148,7 +148,7 @@
"structureId": 3,
"level": 9,
"bossLevel": 90,
"warIdHP": "8033&90000000|8034&90000000",
"warIdHP": "8033&90000000&75|8034&90000000&75",
"rewards": 3,
"consume": 13625000,
"buildWords": "&",
@@ -166,7 +166,7 @@
"structureId": 3,
"level": 10,
"bossLevel": 100,
"warIdHP": "8037&100000000|8038&100000000",
"warIdHP": "8037&100000000&80|8038&100000000&80",
"rewards": 3,
"consume": 99999999,
"buildWords": "&",