✨ feat(gvg): 修改战力相关读取方案
This commit is contained in:
@@ -3,14 +3,14 @@ import { GVGConfigModel, GVGConfigType } from "../../db/GVGConfig";
|
||||
import { getTimeFun, getZeroPoint, getZeroPointOfTime, nowSeconds, WEEK_TO_SECOND } from "../../pubUtils/timeUtil";
|
||||
import { getAllServerCreateTime, getServerCreateTime } from "../redisService";
|
||||
import { GVG_PERIOD, GVG_SERVER_TYPE, SHOP_REFRESH_TYPE } from "../../consts";
|
||||
import { GVGLeagueModel } from "../../db/GVGLeague";
|
||||
import { GVGLeagueModel, GVGLeagueType } from "../../db/GVGLeague";
|
||||
import { GVGLeaguePrepareModel } from "../../db/GVGLeaguePrepare";
|
||||
import { GVGServerGroupModel } from "../../db/GVGServerGroup";
|
||||
import { gameData } from "../../pubUtils/data";
|
||||
import { getRandSingleEelm } from "../../pubUtils/util";
|
||||
import { GVG } from "../../pubUtils/dicParam";
|
||||
import { ServerlistModel } from "../../db/Serverlist";
|
||||
import { GuildType } from "../../db/Guild";
|
||||
import { GuildModel, GuildType } from "../../db/Guild";
|
||||
|
||||
// 定时器相关
|
||||
export async function createNewGVGConfig() {
|
||||
@@ -190,4 +190,10 @@ export async function getGVGInfoInGuild(guild: GuildType) {
|
||||
configId, period, countdownTime,
|
||||
type
|
||||
}
|
||||
}
|
||||
|
||||
export async function calLeagueCe(league: GVGLeagueType) {
|
||||
const guildCodes = league?.guildCodes||[];
|
||||
const guilds = await GuildModel.findByCodes(guildCodes);
|
||||
return guilds.reduce((pre, guild) => pre + guild.guildCe, 0);
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import { GVG } from "../../pubUtils/dicParam";
|
||||
import { getZeroPointD } from "../../pubUtils/timeUtil";
|
||||
import { resResult } from "../../pubUtils/util";
|
||||
import { sendMessageToUserWithSuc } from "../pushService";
|
||||
import { getCurPeriod, getGVGConfig, getGVGPeriodData, getGVGServerType } from "./gvgService";
|
||||
import { calLeagueCe, getCurPeriod, getGVGConfig, getGVGPeriodData, getGVGServerType } from "./gvgService";
|
||||
|
||||
/**
|
||||
* 自动创建联军
|
||||
@@ -101,10 +101,11 @@ export function getLeagueApplyData(apply: GVGLeagueApplyType, serverNames: any,
|
||||
* @param applies 本军团向其他联军发出的申请
|
||||
* @returns
|
||||
*/
|
||||
export function getLeagueInviteData(invite: GVGLeagueApplyType, serverNames: any, applies: GVGLeagueApplyType[]) {
|
||||
export async function getLeagueInviteData(invite: GVGLeagueApplyType, serverNames: any, applies: GVGLeagueApplyType[]) {
|
||||
let data = new LeagueListInfo(<GVGLeagueType>invite.league, serverNames);
|
||||
let hasApply = !!applies.find(cur => cur.leagueCode == invite.guildCode);
|
||||
data.setHasApply(hasApply);
|
||||
data.setLeagueCe(await calLeagueCe(<GVGLeagueType>invite.league))
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -455,7 +455,6 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
|
||||
roleCe = await RoleCeModel.updateRoleCe(roleId, roleCeUpdate);
|
||||
let role = await RoleModel.incRoleInfo(roleId, { ...roleIncUpdate, ce: roleInc }, { ...roleUpdate, topLineup, topLineupCe });
|
||||
let guild = await GuildModel.updateCe(roleId, roleInc); // 公会更新战力
|
||||
let league = await GVGLeagueModel.updateCe(roleId, roleInc); // 联军更新战力
|
||||
|
||||
saveCeChangeLog(role, roleInc, role.ce, type, ceChangeTxt);
|
||||
updateRank(roleId, serverId, topLineupCe, role, pushHeros, guild);
|
||||
@@ -463,9 +462,6 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
|
||||
if(hasTopCeChange) await updateRoleOnlineInfo(roleId, { topLineupCe });
|
||||
if(guild) {
|
||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }]);
|
||||
}
|
||||
if(league) { // TODO 联军排行榜需要更新数据
|
||||
|
||||
}
|
||||
return { heroes, curRole: role }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user