Skip to content

Commit 7ada18a

Browse files
committed
修复了部分bug,
新增胜率队检测,开黑检测
1 parent b3c054e commit 7ada18a

File tree

12 files changed

+167
-48
lines changed

12 files changed

+167
-48
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
- [x] 发送聊天
1818
- [ ] 游戏对局内发送聊天
1919
- [ ] 小黑屋功能
20+
- [ ] 自动ban pick英雄
21+
- [ ] 大乱斗自动抢英雄
2022
- [x] 对局分析
21-
- [ ] 自动检测大乱斗胜率队
23+
- [x] 自动检测大乱斗胜率队
2224
- [x] 应用检查更新功能
2325

2426
## 截图
@@ -74,6 +76,7 @@ npm run build
7476
## 参考资料
7577

7678
- https://hextechdocs.dev/getting-started-with-the-lcu-api/
79+
- https://www.mingweisamuel.com/lcu-schema/tool/#
7780
- https://github.com/XHXIAIEIN/LeagueCustomLobby
7881
- https://github.com/real-web-world/hh-lol-prophet
7982
- https://github.com/XilyFeAAAA/RIVEN

components.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ declare module 'vue' {
4343
NDropdown: (typeof import("naive-ui"))["NDropdown"];
4444
NGi: (typeof import("naive-ui"))["NGi"];
4545
NGlobalStyle: (typeof import("naive-ui"))["NGlobalStyle"];
46-
NGrid: (typeof import("naive-u"naive-ui"d""NIcon"c;on: (typeof import("naive-ui"))["NIcon"];
46+
NGrid: (typeof import("naive-ui"))["NGrid"];
47+
NIcon: (typeof import("naive-ui"))["NIcon"];
4748
NImage: (typeof import("naive-ui"))["NImage"];
4849
NInput: (typeof import("naive-ui"))["NInput"];
4950
NMessageProvider: (typeof import("naive-ui"))["NMessageProvider"];
@@ -65,6 +66,7 @@ declare module 'vue' {
6566
NTabs: (typeof import("naive-ui"))["NTabs"];
6667
NTag: (typeof import("naive-ui"))["NTag"];
6768
NTooltip: (typeof import("naive-ui"))["NTooltip"];
69+
on: (typeof import("naive-ui"))["NIcon"];
6870
PerkImg: (typeof import("./src/components/img/perkImg.vue"))["default"];
6971
Perks: (typeof import("./src/components/img/Perks.vue"))["default"];
7072
PlayerGameInfo: (typeof import("./src/components/PlayerGameInfo.vue"))["default"];

electron/lcu/connector.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ export function startGuardTask() {
4848
sendToWebContent(Handle.connecting);
4949
try {
5050
await initLeagueWebSocket();
51-
//这里尝试获取当前召唤师信息,获取成功了才算连接成功;因为可能客户端还未完成登录过程
52-
await retryWrapper(getCurrentSummoner)();
51+
//这里尝试获取当前召唤师信息,获取成功了才算连接成功;因为可能客户端还未完成登录过程,比如说一区排队的情况
52+
await retryWrapper(getCurrentSummoner, 60, 5000)();
5353
sendToWebContent(Handle.connected);
5454
logger.info("guardTask", "connected to LeagueClient");
5555
} catch (e) {
56+
ws = null;
5657
logger.error("guardTask", e instanceof Error ? e.message : e);
5758
sendToWebContent(Handle.disconnect);
5859
}

electron/lcu/lcuRequest.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Conversation,
77
GameDetail,
88
GameSessionData,
9+
LobbyMember,
910
MatchHistoryQueryResult,
1011
RPC,
1112
SummonerInfo
@@ -97,7 +98,7 @@ export async function applyRune(data: RuneConfig) {
9798
method: "GET",
9899
url: "lol-perks/v1/pages"
99100
});
100-
const current = currentRuneList.find((i) => i.current && i.isDeletable);
101+
const current = currentRuneList.find((i) => i.name.startsWith("OP.GG")) || currentRuneList.find((i) => i.isDeletable);
101102
if (current != undefined) {
102103
// 删除当前符文页
103104
await httpRequest({
@@ -249,3 +250,17 @@ export const matchmaking = async () => {
249250
url: `/lol-lobby/v2/lobby/matchmaking/search`
250251
});
251252
};
253+
254+
//查询大厅成员
255+
export const getLobbyMembers = async () => {
256+
return await httpRequest<LobbyMember[]>({
257+
method: "GET",
258+
url: "/lol-lobby/v2/lobby/members"
259+
});
260+
};
261+
//检查自己是否房主
262+
export const checkSelfIsLobbyLeader = async () => {
263+
const lobbyMembers = await getLobbyMembers();
264+
const selfPuuid = (await getCurrentSummoner()).puuid;
265+
return lobbyMembers.find((m) => (m.puuid = selfPuuid)).isLeader;
266+
};

electron/lcu/processEvent.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { createHttp1Request } from "../lib/league-connect";
22
import { getCredentials } from "./connector";
3-
import { getCurrentQueue, getGameInfo, listenChampSelect, matchmaking, playAgain } from "./lcuRequest";
3+
import {
4+
checkSelfIsLobbyLeader,
5+
getCurrentQueue,
6+
getGameInfo,
7+
listenChampSelect,
8+
matchmaking,
9+
playAgain
10+
} from "./lcuRequest";
411
import logger from "../lib/logger";
512
import { setting } from "../config/";
613
import { ChampSelectPhaseSession } from "../types/lcuType";
@@ -94,7 +101,7 @@ export async function handelEndOfGame(eventKey: string) {
94101
}
95102
if (setting.model.autoPlayAgain) {
96103
await playAgain();
97-
await matchmaking();
104+
if (await checkSelfIsLobbyLeader()) await matchmaking();
98105
}
99106
}
100107

electron/types/lcuType.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,39 @@ export interface XpDiffPerMinDeltas {}
580580

581581
export interface XpPerMinDeltas {}
582582

583+
export interface LobbyMember {
584+
allowedChangeActivity: boolean;
585+
allowedInviteOthers: boolean;
586+
allowedKickOthers: boolean;
587+
allowedStartActivity: boolean;
588+
allowedToggleInvite: boolean;
589+
autoFillEligible: boolean;
590+
autoFillProtectedForPromos: boolean;
591+
autoFillProtectedForSoloing: boolean;
592+
autoFillProtectedForStreaking: boolean;
593+
botChampionId: number;
594+
botDifficulty: string;
595+
botId: string;
596+
firstPositionPreference: string;
597+
intraSubteamPosition: any;
598+
isBot: boolean;
599+
isLeader: boolean;
600+
isSpectator: boolean;
601+
playerSlots: any[];
602+
puuid: string;
603+
ready: boolean;
604+
secondPositionPreference: string;
605+
showGhostedBanner: boolean;
606+
subteamIndex: any;
607+
summonerIconId: number;
608+
summonerId: number;
609+
summonerInternalName: string;
610+
summonerLevel: number;
611+
summonerName: string;
612+
teamId: number;
613+
tftNPEQueueBypass: boolean;
614+
}
615+
583616
export interface Team {
584617
bans: Ban[];
585618
baronKills: number;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "joi",
3-
"version": "0.5.4",
3+
"version": "0.5.5",
44
"main": "dist-electron/main.js",
55
"repository": {
66
"type": "git",

src/components/gameFlow/gameAnalysis.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@ import TeamAnalysis from "@/components/gameFlow/teamAnalysis.vue";
55
66
const lcuStore = useLCUStore();
77
8-
const { myTeam, queryMyTeamFlag, theirTeam, queryTheirTeamFlag } = storeToRefs(lcuStore);
8+
const { myTeam, queryMyTeamFlag, theirTeam, queryTheirTeamFlag, myTeamUpInfo, theirTeamUpInfo, theirTeamIsSuck } =
9+
storeToRefs(lcuStore);
910
</script>
1011

1112
<template>
1213
<div class="flex flex-1 relative">
1314
<n-tabs animated>
1415
<n-tab-pane tab="我方队伍" name="myTeam">
1516
<n-spin :show="queryMyTeamFlag">
16-
<team-analysis :teams="myTeam" />
17+
<team-analysis :teams="myTeam" :team-up-info="myTeamUpInfo" />
1718
</n-spin>
1819
</n-tab-pane>
1920
<n-tab-pane tab="对方队伍" name="theirTeam">
2021
<div v-if="lcuStore.gameFlowPhase === 'ChampSelect'" class="text-2xl flex h-full items-center justify-center">
2122
等待进入对局
2223
</div>
2324
<n-spin :show="queryTheirTeamFlag" v-else>
24-
<team-analysis :teams="theirTeam" />
25+
<team-analysis :teams="theirTeam" :team-up-info="theirTeamUpInfo" />
2526
</n-spin>
2627
</n-tab-pane>
2728
</n-tabs>

src/components/gameFlow/teamAnalysis.vue

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { ComputedRef } from "vue";
1111
import HistoryList from "@/components/HistoryList.vue";
1212
import { champDict } from "@@/const/lolDataConfig";
1313
14-
const props = defineProps<{ teams: TeamMemberInfo[] }>();
15-
const { teams } = toRefs(props);
14+
const props = defineProps<{ teams: TeamMemberInfo[]; teamUpInfo: Array<Array<string>> }>();
15+
const { teams, teamUpInfo } = toRefs(props);
1616
1717
use([TooltipComponent, GridComponent, BarChart, CanvasRenderer]);
1818
@@ -26,6 +26,8 @@ const teamMap = computed(() => {
2626
);
2727
});
2828
29+
const colorGroup = ["rgba(252,132,80,0.66)", "rgba(123,239,255,0.81)", "rgba(255,255,255,0.8)"];
30+
2931
const championImageUrlMap = computed(() => {
3032
return teams.value.reduce(
3133
(p, c) => {
@@ -78,19 +80,41 @@ const option = computed(() => {
7880
}) || [],
7981
axisLabel: {
8082
interval: 0,
81-
color: "rgba(255,255,255,0.8)",
83+
color: function (value, index) {
84+
const cIndex = teamUpInfo.value.findIndex((group) =>
85+
group.find((puuid) => puuid === teams.value[index!]?.puuid)
86+
);
87+
if (cIndex !== -1) {
88+
return colorGroup[cIndex];
89+
} else {
90+
return colorGroup[2];
91+
}
92+
},
8293
formatter: function (value, index) {
83-
if (teams.value[index].championId) {
84-
return `{${teams.value[index].championId!}|}\n{value|${value}}`;
94+
const member = teams.value[index];
95+
let str;
96+
if (member.championId) {
97+
str = `{${member.championId!}|}\n{value|${value}}`;
8598
} else {
86-
return `{value|${value}}`;
99+
str = `{value|${value}}`;
100+
}
101+
if (member.summonerInfo.privacy === "PRIVATE") {
102+
str += `\n{private|生涯隐藏}}`;
87103
}
104+
return str;
88105
},
89106
rich: {
90107
...championImageUrlMap.value,
91108
value: {
92109
lineHeight: 30,
93110
align: "center"
111+
},
112+
private: {
113+
lineHeight: 30,
114+
align: "center",
115+
borderWidth: 2,
116+
borderColor: "rgba(245,112,45,0.73)",
117+
borderRadius: 2
94118
}
95119
}
96120
},
@@ -144,28 +168,38 @@ function handleClick(event: any) {
144168
</script>
145169

146170
<template>
147-
<v-chart class="w-full h-full" :option="option" @click="handleClick" />
148-
<n-modal
149-
v-model:show="showDetail"
150-
preset="card"
151-
class="team-member-history-modal"
152-
:title="showSummonerName"
153-
style="
154-
margin-top: 10px;
155-
width: 95%;
156-
height: 85vh;
157-
display: flex;
158-
flex-flow: column;
159-
background: rgb(22 27 43 / 95%);
160-
backdrop-filter: blur(4px);
161-
border: 1px solid rgb(122 122 122 / 58%);
162-
border-radius: 8px;
163-
overflow: hidden;
164-
">
165-
<div class="flex flex-1 flex-col h-0" style="font-size: 12px">
166-
<HistoryList :match-history-list="historyListData"></HistoryList>
171+
<div class="flex flex-1 flex-col w-full h-full">
172+
<div class="flex flex-row items-center gap-5 justify-center" v-if="teamUpInfo.length > 0">
173+
<template v-for="(color, i) in colorGroup" :key="i">
174+
<div v-if="i + 1 <= teamUpInfo.length" class="flex flex-row items-center gap-1">
175+
<div :style="{ backgroundColor: color, width: '10px', height: '10px' }"></div>
176+
<span>组队{{ i + 1 }}</span>
177+
</div>
178+
</template>
167179
</div>
168-
</n-modal>
180+
<v-chart class="flex-1" :option="option" @click="handleClick" />
181+
<n-modal
182+
v-model:show="showDetail"
183+
preset="card"
184+
class="team-member-history-modal"
185+
:title="showSummonerName"
186+
style="
187+
margin-top: 10px;
188+
width: 95%;
189+
height: 85vh;
190+
display: flex;
191+
flex-flow: column;
192+
background: rgb(22 27 43 / 95%);
193+
backdrop-filter: blur(4px);
194+
border: 1px solid rgb(122 122 122 / 58%);
195+
border-radius: 8px;
196+
overflow: hidden;
197+
">
198+
<div class="flex flex-1 flex-col h-0" style="font-size: 12px">
199+
<HistoryList :match-history-list="historyListData"></HistoryList>
200+
</div>
201+
</n-modal>
202+
</div>
169203
</template>
170204

171205
<style scoped></style>

src/listener/backgroundListener.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function setupListener() {
4242
window.ipcRenderer.on(Handle.gameSessionMyTeam, async (event: IpcRendererEvent, myTeam: TeamMemberInfo[]) => {
4343
lcuStore.myTeam = myTeam;
4444
lcuStore.theirTeam = [];
45-
setTimeout(lcuStore.analysisMyTeam, 2000);
45+
setTimeout(lcuStore.analysisMyTeam, 4000);
4646
});
4747

4848
window.ipcRenderer.on(Handle.gameSessionRoomId, async (event: IpcRendererEvent, chatRoomId: string) => {

0 commit comments

Comments
 (0)