Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Manwe-777 committed May 5, 2024
1 parent fa411f0 commit f137c91
Showing 1 changed file with 53 additions and 50 deletions.
103 changes: 53 additions & 50 deletions src/background/onLabel/MatchGameRoomStateChangedEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import readMatchManger from "../../reader/readMatchManger";
import readMatchOpponentInfo from "../../reader/readMatchOpponentInfo";
import readMatchPlayerInfo from "../../reader/readMatchPlayerInfo";
import LogEntry from "../../types/logDecoder";
import isElectron from "../../utils/electron/isElectron";
import getLocalSetting from "../../utils/getLocalSetting";
import isLimitedEventId from "../../utils/isLimitedEventId";
import actionLog from "../actionLog";
Expand Down Expand Up @@ -158,57 +159,59 @@ export default function onLabelMatchGameRoomStateChangedEvent(

const isLimited = isLimitedEventId(gameRoom.gameRoomConfig.eventId);

const matchState = readMatchManger();

const oppInfo = readMatchOpponentInfo();
if (
oppInfo &&
matchState &&
matchState["<MatchID>k__BackingField"] ===
gameRoom.gameRoomConfig.matchId &&
oppInfo.RankingClass > 0
) {
const opponent = {
tier: oppInfo.RankingTier,
rank: rankClass[oppInfo.RankingClass],
percentile: oppInfo.MythicPercentile,
leaderboardPlace: oppInfo.MythicPlacement,
};
setOpponent(opponent);
}
if (isElectron()) {
const matchState = readMatchManger();

const playerInfo = readMatchPlayerInfo();
if (
playerInfo &&
matchState &&
matchState["<MatchID>k__BackingField"] ===
gameRoom.gameRoomConfig.matchId &&
playerInfo.RankingClass > 0
) {
const player = {
tier: playerInfo.RankingTier,
rank: rankClass[playerInfo.RankingClass],
percentile: playerInfo.MythicPercentile,
leaderboardPlace: playerInfo.MythicPlacement,
};
setPlayer(player);

if (isLimited) {
postChannelMessage({
type: "UPSERT_DB_RANK",
value: {
limitedClass: rankClass[playerInfo.RankingClass],
limitedLevel: playerInfo.RankingTier,
},
});
} else {
postChannelMessage({
type: "UPSERT_DB_RANK",
value: {
constructedClass: rankClass[playerInfo.RankingClass],
constructedLevel: playerInfo.RankingTier,
},
});
const oppInfo = readMatchOpponentInfo();
if (
oppInfo &&
matchState &&
matchState["<MatchID>k__BackingField"] ===
gameRoom.gameRoomConfig.matchId &&
oppInfo.RankingClass > 0
) {
const opponent = {
tier: oppInfo.RankingTier,
rank: rankClass[oppInfo.RankingClass],
percentile: oppInfo.MythicPercentile,
leaderboardPlace: oppInfo.MythicPlacement,
};
setOpponent(opponent);
}

const playerInfo = readMatchPlayerInfo();
if (
playerInfo &&
matchState &&
matchState["<MatchID>k__BackingField"] ===
gameRoom.gameRoomConfig.matchId &&
playerInfo.RankingClass > 0
) {
const player = {
tier: playerInfo.RankingTier,
rank: rankClass[playerInfo.RankingClass],
percentile: playerInfo.MythicPercentile,
leaderboardPlace: playerInfo.MythicPlacement,
};
setPlayer(player);

if (isLimited) {
postChannelMessage({
type: "UPSERT_DB_RANK",
value: {
limitedClass: rankClass[playerInfo.RankingClass],
limitedLevel: playerInfo.RankingTier,
},
});
} else {
postChannelMessage({
type: "UPSERT_DB_RANK",
value: {
constructedClass: rankClass[playerInfo.RankingClass],
constructedLevel: playerInfo.RankingTier,
},
});
}
}
}

Expand Down

0 comments on commit f137c91

Please sign in to comment.