fix(传承): 修复传承之后天晶数据错乱的问题,玩家登录时修复

This commit is contained in:
luying
2023-10-08 20:10:26 +08:00
parent 144181f2e1
commit cd87b9e74c
5 changed files with 46 additions and 9 deletions

View File

@@ -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||[];

View File

@@ -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 });
}

View File

@@ -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'
}

View File

@@ -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开 其他关
}

View File

@@ -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 });