✨ feat(军团): 修改boss和城门血条逻辑
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { ServerlistModel, ServerlistType } from "../../db/Serverlist";
|
||||
import { RoleModel } from "../../db/Role";
|
||||
import { GUILDACTIVITY } from "../../pubUtils/dicParam";
|
||||
import { gameData, getCityActivityRewards } from "../../pubUtils/data";
|
||||
import { getCurDay, nowSeconds, getTimeFun, getZeroPoint } from "../../pubUtils/timeUtil";
|
||||
import { GUILD_ACTIVITY_STATUS, GET_POINT_WAYS, GUILD_ACTIVITY_TYPE, REDIS_KEY, AUCTION_SOURCE, MAIL_TYPE, CITY_STATUS, DEBUG_MAGIC_WORD, GUILD_POINT_WAYS, TASK_TYPE, AUCTION_TIME, CITY_ACTIVITY_DOOR, ABI_TYPE, PUSH_ROUTE, RACE_ACTIVITY_STATUS, SHOP_REFRESH_TYPE, COUNTER, RACE_EVENT_TYPE } from "../../consts";
|
||||
import { gameData, getBossHpRatio, getCityActivityRewards } from "../../pubUtils/data";
|
||||
import { getCurDay, nowSeconds, getTimeFun, getZeroPoint, getZeroPointOfTime } from "../../pubUtils/timeUtil";
|
||||
import { GUILD_ACTIVITY_STATUS, GET_POINT_WAYS, GUILD_ACTIVITY_TYPE, REDIS_KEY, AUCTION_SOURCE, MAIL_TYPE, CITY_STATUS, DEBUG_MAGIC_WORD, GUILD_POINT_WAYS, TASK_TYPE, AUCTION_TIME, CITY_ACTIVITY_DOOR, ABI_TYPE, PUSH_ROUTE, RACE_ACTIVITY_STATUS, SHOP_REFRESH_TYPE, COUNTER, RACE_EVENT_TYPE, BOSS_HP_RATIO_TYPE } from "../../consts";
|
||||
import { Record, UserGuildActivityRecModel } from "../../db/UserGuildActivityRec";
|
||||
import { GateMembersRec, CityParam, WoodenHorse, RaceActivityRankParam } from "../../domain/battleField/guildActivity";
|
||||
import { DicGuildActivity } from "../../pubUtils/dictionary/DicGuildActivity";
|
||||
import { getAllServers, getRoleOnlineInfo, redisClient } from "../redisService";
|
||||
import { getAllServers, getRoleOnlineInfo, getServerCreateTime, redisClient } from "../redisService";
|
||||
import { SimpleGuildRankParam, SimpleRoleRankParam, GuildRankInfo, RoleRankInfo } from "../../domain/rank";
|
||||
import { pinus } from "pinus";
|
||||
import { GuildActivityRecordModel } from "../../db/GuildActivityRec";
|
||||
@@ -30,6 +30,8 @@ import { setInterval } from "timers";
|
||||
import { dispatch } from "../../pubUtils/dispatcher";
|
||||
import { GuildModel } from "../../db/Guild";
|
||||
import { getCityActivityObj, getGateActivityObj, getRaceActivityObj } from "../memoryCache/guildActivityData";
|
||||
import { getBossHpRatioByServer } from "../guildBossService";
|
||||
import { getHeroesAttributes } from "../playerCeService";
|
||||
|
||||
|
||||
/**
|
||||
@@ -730,49 +732,89 @@ function formatTime(date: Date) {
|
||||
}
|
||||
|
||||
export async function getCityActivityGateHp(serverId: number, cityId: number) {
|
||||
console.log(`getCityActivityGateHp: serverId ${serverId}, cityId ${cityId}`);
|
||||
let dicCityActivity = gameData.cityActivity.get(cityId);
|
||||
let playerResult = await getPlayerCnt(serverId);
|
||||
if (!playerResult) return dicCityActivity.hp
|
||||
let { activePlayerCnt, activeGuildCnt, activePlayerCe, activeTopPlayerCnt, activePlayers } = playerResult;
|
||||
|
||||
// 倍数按开服天数变化
|
||||
let ratio = await getBossHpRatioByServer(BOSS_HP_RATIO_TYPE.CITY_RATIO, serverId);
|
||||
// 单个玩家的平均攻击力
|
||||
let playerAtkResult = await getPlayerAtkAvg(activePlayers);
|
||||
if (!playerAtkResult) return dicCityActivity.hp;
|
||||
let { playerAtkAvg } = playerAtkResult;
|
||||
|
||||
// *单个玩家5回合造成的总伤害=单个玩家的平均攻击力*倍数*5(综合技能次级属性算出的倍数)
|
||||
let player5Damage = playerAtkAvg * ratio * 5;
|
||||
|
||||
// *平均一个军团的玩家人数=前一天参与军团活动的玩家/前一天参与军团活动的军团数量,
|
||||
let guildPlayerCntAvg = await getGuildPlayerCntAvg(serverId, activePlayerCnt, activeGuildCnt);
|
||||
|
||||
// 城池倍数
|
||||
let cityRatio = Math.max(Math.floor(activeGuildCnt/6), dicCityActivity.hpN);
|
||||
|
||||
// 城门血量=单个玩家5回合造成的总伤害*平均一个军团的玩家人数*城池倍数
|
||||
let gateHp = Math.floor(player5Damage * guildPlayerCntAvg * cityRatio);
|
||||
if(gateHp <= dicCityActivity.hp) {
|
||||
gateHp = dicCityActivity.hp;
|
||||
}
|
||||
|
||||
saveGuildGateHpLog(serverId, cityId, { activePlayerCnt, activePlayerCe, activeTopPlayerCnt, activeGuildCnt, ratio, playerAtkAvg, player5Damage, guildPlayerCntAvg, cityRatio, gateHp });
|
||||
|
||||
return gateHp;
|
||||
}
|
||||
|
||||
// *单个玩家的平均攻击力=本服活跃玩家中最强6人排名前10的玩家的最强6人的攻击之和/10
|
||||
async function getPlayerAtkAvg(activePlayers: ActivePlayer[]) {
|
||||
if (!activePlayers || activePlayers.length <= 0) return false;
|
||||
let playerAtkSum = 0, playerCnt = 0;
|
||||
activePlayers.sort((a, b) => b.ce - a.ce);
|
||||
for (let i = 0; i < 10; i++) {
|
||||
if (!activePlayers[i]) break;
|
||||
let onePlayerAtkSum = 0, heroCnt = 0;
|
||||
let { roleId, topLineup = [] } = activePlayers[i];
|
||||
let attrByHid = await getHeroesAttributes(roleId);
|
||||
for (let { hid } of topLineup) {
|
||||
let atk = attrByHid.get(hid)?.getAtk() || 0;
|
||||
onePlayerAtkSum += atk;
|
||||
heroCnt++;
|
||||
}
|
||||
if (heroCnt == 0) continue; // 基本不可能,但是以防NaN
|
||||
playerAtkSum += onePlayerAtkSum / heroCnt * 6;
|
||||
playerCnt++;
|
||||
}
|
||||
if (playerCnt == 0) return false;
|
||||
let playerAtkAvg = playerAtkSum / playerCnt * 10;
|
||||
return { playerAtkAvg, playerCnt };
|
||||
}
|
||||
|
||||
async function getGuildPlayerCntAvg (serverId: number, activePlayerCnt: number, activeGuildCnt: number) {
|
||||
let minRatio = await getBossHpRatioByServer(BOSS_HP_RATIO_TYPE.CITY_PLAYER_RATIO, serverId);
|
||||
let guildPlayerCntAvg = Math.floor(activePlayerCnt / activeGuildCnt);
|
||||
if (guildPlayerCntAvg < minRatio) return minRatio;
|
||||
return guildPlayerCntAvg
|
||||
}
|
||||
|
||||
async function getPlayerCnt(serverId: number) {
|
||||
|
||||
let serverRecord = await ServerRecordModel.findTodayData(serverId);
|
||||
if(!serverRecord) return dicCityActivity.hp;
|
||||
if(!serverRecord) return false;
|
||||
|
||||
let activePlayerCnt = 50; // 前一天参与军团活动的玩家
|
||||
let activeGuildCnt = 5; // 前一天参与军团活动的军团
|
||||
let activePlayerCe = 0; // 前一天前十玩家的最强战力和
|
||||
let activeTopPlayerCnt = 1; // 前一天最强玩家数量
|
||||
let activePlayers: ActivePlayer[] = [];
|
||||
if(serverRecord) {
|
||||
if(serverRecord.activePlayerCe > 0) activePlayerCe = serverRecord.activePlayerCe;
|
||||
if(serverRecord.activePlayers?.length > 0) activeTopPlayerCnt = serverRecord.activePlayers?.length;
|
||||
if(serverRecord.activePlayers?.length > 0) {
|
||||
activeTopPlayerCnt = serverRecord.activePlayers?.length;
|
||||
activePlayers = serverRecord.activePlayers||[];
|
||||
}
|
||||
if(serverRecord.activeGuildCodes?.length > 0) activeGuildCnt = serverRecord.activeGuildCodes?.length;
|
||||
if(serverRecord.activeGuildMembers?.length > 0) activePlayerCnt = serverRecord.activeGuildMembers?.length;
|
||||
}
|
||||
console.log(`getCityActivityGateHp: activePlayerCnt ${activePlayerCnt}, activePlayerCe ${activePlayerCe}, activeTopPlayerCnt ${activeTopPlayerCnt} activeGuildCnt ${activeGuildCnt}`);
|
||||
|
||||
let atk = dicCityActivity.atkTemplate||0;
|
||||
console.log(`getCityActivityGateHp: atk ${atk}`);
|
||||
|
||||
let A = activePlayerCe/activeTopPlayerCnt/6/GUILDACTIVITY.GATEACTIVITY_ENEMYCE;
|
||||
if(A < 1) A = 1;
|
||||
console.log(`getCityActivityGateHp: A ${A}`);
|
||||
|
||||
let gateHpBase = A * atk;
|
||||
let N = dicCityActivity.hpN;
|
||||
|
||||
console.log(`getCityActivityGateHp: gateHpBase ${gateHpBase}, N ${N}`);
|
||||
|
||||
let playerGuildRatio = activePlayerCnt/activeGuildCnt;
|
||||
if(playerGuildRatio < dicCityActivity.playerCount) playerGuildRatio = dicCityActivity.playerCount;
|
||||
|
||||
let gateHp = Math.floor(gateHpBase * playerGuildRatio * N);
|
||||
console.log(`getCityActivityGateHp: gateHp ${gateHp}`);
|
||||
|
||||
|
||||
saveGuildGateHpLog(serverId, cityId, { activePlayerCnt, activePlayerCe, activeTopPlayerCnt, activeGuildCnt, atk, A, hpBase: gateHpBase, N, gateHp, playerGuildRatio });
|
||||
|
||||
if(gateHp <= dicCityActivity.hp) {
|
||||
gateHp = dicCityActivity.hp;
|
||||
}
|
||||
return gateHp;
|
||||
return { activePlayerCnt, activeGuildCnt, activePlayerCe, activeTopPlayerCnt, activePlayers }
|
||||
}
|
||||
|
||||
export async function declareCity(serverId: number, roleId: string, guildCode: string, cityId: number, isAutoDeclare: boolean, declareIndex: number) {
|
||||
|
||||
Reference in New Issue
Block a user