From cd87b9e74c82f07a71262babcf32be03c662082b Mon Sep 17 00:00:00 2001 From: luying Date: Sun, 8 Oct 2023 20:10:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BC=A0=E6=89=BF):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BC=A0=E6=89=BF=E4=B9=8B=E5=90=8E=E5=A4=A9=E6=99=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=94=99=E4=B9=B1=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E7=99=BB=E5=BD=95=E6=97=B6=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/role/handler/heroHandler.ts | 4 +-- game-server/app/services/connectorService.ts | 35 +++++++++++++++---- game-server/app/services/redisService.ts | 11 ++++++ shared/consts/constModules/sysConst.ts | 2 +- shared/db/Role.ts | 3 ++ 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/game-server/app/servers/role/handler/heroHandler.ts b/game-server/app/servers/role/handler/heroHandler.ts index fc1818a0e..2e14b6e42 100644 --- a/game-server/app/servers/role/handler/heroHandler.ts +++ b/game-server/app/servers/role/handler/heroHandler.ts @@ -847,6 +847,8 @@ export class HeroHandler { if (originHero.ePlace || targetHero.ePlace.length > 0) tempOriginEPlace = getHeroNewEplace(originHero, targetHero?.ePlace || []); if (targetHero.ePlace || originHero.ePlace.length > 0) tempTargetEPlace = getHeroNewEplace(targetHero, originHero?.ePlace || []); + originHero.ePlace = tempOriginEPlace; + targetHero.ePlace = tempTargetEPlace; // 天晶地玉 let jewels: JewelType[] = []; let curJewels: jewelUpdate[] = []; @@ -864,8 +866,6 @@ export class HeroHandler { jewels.push(result); curJewels.push({ seqId:result.seqId, hid:result.hid}); } - originHero.ePlace = tempOriginEPlace; - targetHero.ePlace = tempTargetEPlace; // 消耗 let originalConsumes = originHero.consumes||[]; diff --git a/game-server/app/services/connectorService.ts b/game-server/app/services/connectorService.ts index 5c73eb246..e15e3fd85 100644 --- a/game-server/app/services/connectorService.ts +++ b/game-server/app/services/connectorService.ts @@ -8,7 +8,7 @@ import { getCurTask, getPvpTask } from './task/taskService'; import { RoleModel, RoleType } from '../db/Role'; import { Application, BackendSession, FrontendOrBackendSession, pinus, RpcClient } from 'pinus'; import { compareVersion, getRandEelmWithWeight, resResult } from '../pubUtils/util'; -import { STATUS, PUSH_BATCH, PUSH_INTERVAL, CONSUME_TYPE, HERO_SELECT, ENTERY_ROLE_PICK, JEWEL_SELECT, ITEM_SELECT, SKIN_SELECT, PUSH_ROUTE, ARTIFACT_SELECT, ACTIVITYITEM_SELECT, SNS_LINK_TYPE, VESTIGE_STATUS } from '../consts'; +import { STATUS, PUSH_BATCH, PUSH_INTERVAL, CONSUME_TYPE, HERO_SELECT, ENTERY_ROLE_PICK, JEWEL_SELECT, ITEM_SELECT, SKIN_SELECT, PUSH_ROUTE, ARTIFACT_SELECT, ACTIVITYITEM_SELECT, SNS_LINK_TYPE, VESTIGE_STATUS, HERO_SYSTEM_TYPE } from '../consts'; import { getAllShopList } from './shopService'; import { getGeneralRank, getRankFirstReward } from './rankService'; import { getFriendList, getApplyList } from './friendService'; @@ -30,14 +30,14 @@ import { getBattleListOfMain, getMainChapter } from './normalBattleService'; import { GuildModel, GuildType } from '../db/Guild'; import UserGuild, { UserGuildType } from '../db/UserGuild'; import { getAllGuildActivityStatus } from './guildActivity/guildActivityService'; -import { getAllOnlineRoles, getAllServers, incConnectorNum, redisClient } from './redisService'; +import { checkRecalJewelOpen, getAllOnlineRoles, getAllServers, incConnectorNum, redisClient } from './redisService'; import Item, { ItemModel } from '../db/Item'; import { PvpDefenseModel } from '../db/PvpDefense'; import { getDonation } from './donateService'; import { refChallengeCnt, sendLastSeasonRewardIfNotSent } from './pvpService'; -import { HeroModel } from '../db/Hero'; -import { JewelModel } from '../db/Jewel'; -import { SkinModel } from '../db/Skin'; +import { HeroModel, HeroType } from '../db/Hero'; +import { JewelModel, JewelType } from '../db/Jewel'; +import { SkinModel, SkinType } from '../db/Skin'; import { getAp } from './actionPointService'; import { HeroParam } from '../domain/roleField/hero'; import { pick } from 'underscore'; @@ -48,7 +48,7 @@ import { INFO_WINDOW } from '../pubUtils/dicParam'; import { getLadderData } from './ladderService'; import { dispatch } from '../pubUtils/dispatcher'; import { PvpDataReturn } from '../domain/battleField/pvp'; -import { ArtifactModel } from '../db/Artifact'; +import { ArtifactModel, ArtifactModelType } from '../db/Artifact'; import { ActivityItemModel } from '../db/ActivityItem'; import { LinkModel } from '../db/Link'; import { getHiddenData } from './memoryCache/hiddenData'; @@ -59,6 +59,8 @@ import { LadderMatchRecModel } from '../db/LadderMatchRec'; import { GVGVestigeRecModel, GVGVestigeRecUpdate } from '../db/GVGVestigeRec'; import { getVestigeRecStatus } from './gvg/gvgFightService'; import { getRemoteRplPrefix } from '../pubUtils/battleUtils'; +import { calculateCeWithRole } from './playerCeService'; +import { SchoolModel } from '../db/School'; /** * init: 初始的时候是否推送 true-推 false-不推 @@ -138,6 +140,7 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio let artifacts = await ArtifactModel.findbyRole(role.roleId, ARTIFACT_SELECT.ENTRY); let activityItems = await ActivityItemModel.findbyRole(role.roleId, ACTIVITYITEM_SELECT.ENTRY); let link = await LinkModel.findByType(SNS_LINK_TYPE.CUSTOMER); + await reCalJewel(role, heros, jewels, skins, artifacts); role['heros'] = heros.map(hero => new HeroParam(hero)); role['jewels'] = jewels; role['consumeGoods'] = items; @@ -479,4 +482,24 @@ async function getIconShow(roleId: string, session:FrontendOrBackendSession) { export async function pushIconShow(roleId: string, ladderIconShow?: boolean, gvgFightRecs?) { if (!roleId) return; sendMessageToUserWithSuc(roleId, PUSH_ROUTE.LADDER_OR_GVG_ICON_SHOW, { ladderIconShow, gvgFightRecs }); +} + +export async function reCalJewel(role: RoleType, heroes: HeroType[], jewels: JewelType[], skins: SkinType[], artifacts: ArtifactModelType[]) { + if (role.hasTreat || !await checkRecalJewelOpen()) return + role = await RoleModel.updateRoleInfo(role.roleId, { hasTreat: true }); + for (let jewel of jewels) { + let hero = heroes.find(hero => { + let ePlace = hero.ePlace.find(e => e.jewel == jewel.seqId); + return !!ePlace; + }); + if (hero && hero.hid != jewel.hid) { + let ePlace = hero.ePlace.find(e => e.jewel == jewel.seqId); + if (ePlace) { + await JewelModel.updateInfo(jewel.seqId, { hid: hero.hid, ePlaceId: ePlace.id }); + jewel.hid = hero.hid; jewel.ePlaceId = ePlace.id; + } + } + } + let schools = await SchoolModel.findByRoleId(role.roleId); + await calculateCeWithRole(HERO_SYSTEM_TYPE.RE_CAL, role.roleId, role.serverId, null, {}, { role, schools, jewels, heroes, skins, artifacts }); } \ No newline at end of file diff --git a/game-server/app/services/redisService.ts b/game-server/app/services/redisService.ts index 847ffc85e..369807fee 100644 --- a/game-server/app/services/redisService.ts +++ b/game-server/app/services/redisService.ts @@ -783,3 +783,14 @@ export async function resetMaxOnlineUsers() { const res = await redisClient().setAsync(REDIS_KEY.MAX_ONLINE_USERS, `${MAX_ONLINE_USER_COUNT}`); return res; } + +export async function checkRecalJewelOpen() { + // 设置redis开关 + let isCheckBlock = await redisClient().getAsync(REDIS_KEY.RE_CAL_JEWEL); + if (!isCheckBlock || isCheckBlock == undefined) { + //首次写入 默认是关 + await redisClient().setAsync(REDIS_KEY.RE_CAL_JEWEL, 'false'); + return false + } + return isCheckBlock == 'true' +} \ No newline at end of file diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index dc0a9dfd8..606fa63ac 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -289,7 +289,7 @@ export enum REDIS_KEY { SEND_GIFT_CODE = 'sendGiftCodeChannel', // 礼包码频道 MAX_ONLINE_USERS = 'maxOnlineUsers', // 最高在线人数限制 IS_CHECT_BLOCK = 'isCheckBlock', // 防破解检测封号开关,0-开,1-关 - + RE_CAL_JEWEL = 'reCalJewel', // 重算天晶开关 true开 其他关 } diff --git a/shared/db/Role.ts b/shared/db/Role.ts index 391aa4d3e..157956b4b 100644 --- a/shared/db/Role.ts +++ b/shared/db/Role.ts @@ -364,6 +364,9 @@ export default class Role extends BaseModel { @prop({ required: true }) needCount: boolean; + + @prop({ required: true }) + hasTreat: boolean; public static async findAllByUid(uid: number, getters = false, virtuals = true) { const role: RoleType[] = await RoleModel.find({ 'userInfo.uid': uid }).select('roleId roleName serverId head frame spine heads frames spines lv updatedAt createTime +closeTime').lean({ getters, virtuals });