Skip to content

Commit c363461

Browse files
committed
show match history (40%)
1 parent 5fcf7f6 commit c363461

File tree

6 files changed

+321
-86
lines changed

6 files changed

+321
-86
lines changed

src/render/components/matchHistory/index.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
<n-space>
44
<left-card @summonerId="getSummonerId($event)" @backHome="backHome"></left-card>
55
<n-space>
6-
<bar-k-d-a @summonerId="getSummonerId($event)"
7-
v-if="pageCount==1" class="slide-in-right"></bar-k-d-a>
8-
<standing :matchData="matchData"
9-
@changePage="backHome"
10-
@toGameDetailsPage="toGameDetailsPage($event)"
11-
v-else-if="pageCount==2" class="slide-in-right"></standing>
12-
<gameDetails v-else-if="pageCount==3" class="slide-in-right"
13-
@changePageSencond="() => {pageCount=2}"></gameDetails>
6+
<!-- <bar-k-d-a @summonerId="getSummonerId($event)"-->
7+
<!-- v-if="pageCount==1" class="slide-in-right"></bar-k-d-a>-->
8+
<!-- <standing :matchData="matchData"-->
9+
<!-- @changePage="backHome"-->
10+
<!-- @toGameDetailsPage="toGameDetailsPage($event)"-->
11+
<!-- v-else-if="pageCount==2" class="slide-in-right"></standing>-->
12+
<!-- <gameDetails v-else-if="pageCount==3" class="slide-in-right"-->
13+
<!-- @changePageSencond="() => {pageCount=2}"></gameDetails>-->
14+
<recent-game></recent-game>
1415
</n-space>
1516
</n-space>
1617
</div>
@@ -21,6 +22,7 @@ import LeftCard from "@/render/components/matchHistory/leftCard";
2122
import BarKDA from "@/render/components/matchHistory/barKDA";
2223
import Standing from "@/render/components/matchHistory/standing";
2324
import GameDetails from "@/render/components/matchHistory/gameDetails";
25+
import RecentGame from "@/render/components/matchHistory/recentGame";
2426
import {NSpace} from "naive-ui";
2527
import {onBeforeMount, ref} from "vue";
2628
import {useStore} from "@/render/store";

src/render/components/matchHistory/leftCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const getEnemyInfo = async () => {
111111
enemySummonerInfo.value = await getSummonerNickName(credentials, enemyIdList)
112112
getEnemyChartsData(enemySummonerInfo.value)
113113
}
114-
getEnemyInfo()
114+
// getEnemyInfo()
115115
116116
const getEnemyChartsData = (res) => {
117117
enemyEchartsData.value = {name: [], data: [], kdaHistory: [], horse: [], summonerId: []}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
<template>
2+
<div>
3+
<n-card class="boxShadow mainCard">
4+
<n-grid x-gap="12" :cols="5" style="margin-top: 15px">
5+
<n-gi>
6+
<n-space vertical :size="[10,4]" style="align-items: center">
7+
<n-avatar
8+
round
9+
:bordered="false"
10+
:size="50"
11+
:src="`https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/5430.png`"
12+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
13+
style="display: block"
14+
/>
15+
<n-tag type="success" :bordered="false"
16+
round size="small" style="width: 120px;justify-content: center">多元函数积分学
17+
</n-tag>
18+
<n-tag type="default" :bordered="false"
19+
round size="small">常玩位置: 中单
20+
</n-tag>
21+
<n-tag type="error" :bordered="false"
22+
round size="small">6连败中
23+
</n-tag>
24+
<div style="width: 120px;margin-top: 12px" class="divList">
25+
<n-space justify="space-between" :size="[0]">
26+
<n-avatar
27+
:bordered="false"
28+
:size="28"
29+
:src="`https://opgg-static.akamaized.net/images/lol/champion/Yasuo.png?image=c_crop,h_103,w_103,x_9,y_9/q_auto,f_webp,w_40&v=1662111457535`"
30+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
31+
style="display: block"
32+
/>
33+
<div class="addMargin mid"></div>
34+
<n-tag :bordered="false" type="error"
35+
style="width: 60px;justify-content: center">1/6/4</n-tag>
36+
</n-space>
37+
<n-space justify="space-between" :size="[0]">
38+
<n-avatar
39+
:bordered="false"
40+
:size="28"
41+
:src="`https://opgg-static.akamaized.net/images/lol/champion/Yasuo.png?image=c_crop,h_103,w_103,x_9,y_9/q_auto,f_webp,w_40&v=1662111457535`"
42+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
43+
style="display: block"
44+
/>
45+
<div class="addMargin mid"></div>
46+
<n-tag :bordered="false" type="error"
47+
style="width: 60px;justify-content: center">1/6/4</n-tag>
48+
</n-space>
49+
<n-space justify="space-between" :size="[0]">
50+
<n-avatar
51+
:bordered="false"
52+
:size="28"
53+
:src="`https://opgg-static.akamaized.net/images/lol/champion/Yasuo.png?image=c_crop,h_103,w_103,x_9,y_9/q_auto,f_webp,w_40&v=1662111457535`"
54+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
55+
style="display: block"
56+
/>
57+
<div class="addMargin mid"></div>
58+
<n-tag :bordered="false" type="error"
59+
style="width: 60px;justify-content: center">1/6/4</n-tag>
60+
</n-space>
61+
<n-space justify="space-between" :size="[0]">
62+
<n-avatar
63+
:bordered="false"
64+
:size="28"
65+
:src="`https://opgg-static.akamaized.net/images/lol/champion/Yasuo.png?image=c_crop,h_103,w_103,x_9,y_9/q_auto,f_webp,w_40&v=1662111457535`"
66+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
67+
style="display: block"
68+
/>
69+
<div class="addMargin mid"></div>
70+
<n-tag :bordered="false" type="error"
71+
style="width: 60px;justify-content: center">1/6/4</n-tag>
72+
</n-space>
73+
<n-space justify="space-between" :size="[0]">
74+
<n-avatar
75+
:bordered="false"
76+
:size="28"
77+
:src="`https://opgg-static.akamaized.net/images/lol/champion/Yasuo.png?image=c_crop,h_103,w_103,x_9,y_9/q_auto,f_webp,w_40&v=1662111457535`"
78+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
79+
style="display: block"
80+
/>
81+
<div class="addMargin mid"></div>
82+
<n-tag :bordered="false" type="error"
83+
style="width: 60px;justify-content: center">1/6/4</n-tag>
84+
</n-space>
85+
<n-space justify="space-between" :size="[0]">
86+
<n-avatar
87+
:bordered="false"
88+
:size="28"
89+
:src="`https://opgg-static.akamaized.net/images/lol/champion/Yasuo.png?image=c_crop,h_103,w_103,x_9,y_9/q_auto,f_webp,w_40&v=1662111457535`"
90+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
91+
style="display: block"
92+
/>
93+
<div class="addMargin mid"></div>
94+
<n-tag :bordered="false" type="error"
95+
style="width: 60px;justify-content: center">1/6/4</n-tag>
96+
</n-space>
97+
<n-space justify="space-between" :size="[0]">
98+
<n-avatar
99+
:bordered="false"
100+
:size="28"
101+
:src="`https://opgg-static.akamaized.net/images/lol/champion/Yasuo.png?image=c_crop,h_103,w_103,x_9,y_9/q_auto,f_webp,w_40&v=1662111457535`"
102+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
103+
style="display: block"
104+
/>
105+
<div class="addMargin mid"></div>
106+
<n-tag :bordered="false" type="error"
107+
style="width: 60px;justify-content: center">1/6/4</n-tag>
108+
</n-space>
109+
<n-space justify="space-between" :size="[0]">
110+
<n-avatar
111+
:bordered="false"
112+
:size="28"
113+
:src="`https://opgg-static.akamaized.net/images/lol/champion/Yasuo.png?image=c_crop,h_103,w_103,x_9,y_9/q_auto,f_webp,w_40&v=1662111457535`"
114+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
115+
style="display: block"
116+
/>
117+
<div class="addMargin mid"></div>
118+
<n-tag :bordered="false" type="error"
119+
style="width: 60px;justify-content: center">1/6/4</n-tag>
120+
</n-space>
121+
<n-space justify="space-between" :size="[0]">
122+
<n-avatar
123+
:bordered="false"
124+
:size="28"
125+
:src="`https://opgg-static.akamaized.net/images/lol/champion/Yasuo.png?image=c_crop,h_103,w_103,x_9,y_9/q_auto,f_webp,w_40&v=1662111457535`"
126+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
127+
style="display: block"
128+
/>
129+
<div class="addMargin mid"></div>
130+
<n-tag :bordered="false" type="error"
131+
style="width: 60px;justify-content: center">1/6/4</n-tag>
132+
</n-space>
133+
<n-space justify="space-between" :size="[0]">
134+
<n-avatar
135+
:bordered="false"
136+
:size="28"
137+
:src="`https://opgg-static.akamaized.net/images/lol/champion/Yasuo.png?image=c_crop,h_103,w_103,x_9,y_9/q_auto,f_webp,w_40&v=1662111457535`"
138+
fallback-src="https://wegame.gtimg.com/g.26-r.c2d3c/helper/lol/assis/images/resources/usericon/4027.png"
139+
style="display: block"
140+
/>
141+
<div class="addMargin mid"></div>
142+
<n-tag :bordered="false" type="error"
143+
style="width: 60px;justify-content: center">1/6/4</n-tag>
144+
</n-space>
145+
</div>
146+
</n-space>
147+
</n-gi>
148+
149+
</n-grid>
150+
</n-card>
151+
</div>
152+
</template>
153+
154+
<script>
155+
export default {
156+
name: "recentGame"
157+
}
158+
</script>
159+
160+
<script setup>
161+
import {
162+
NCard, NSpace, NTag, NIcon, NInput, NAvatar, NGrid, NGi,
163+
NButton, NColorPicker, NPopover, NPopconfirm
164+
} from 'naive-ui'
165+
166+
</script>
167+
168+
<style scoped>
169+
170+
.mainCard {
171+
margin: 10px;
172+
border-radius: 10px;
173+
height: 556px;
174+
width: 722px;
175+
}
176+
.mid {
177+
width: 20px;
178+
height: 20px;
179+
margin-top: 3px;
180+
background-image: url('../../assets/tLevel/mid.svg');
181+
background-size:20px;
182+
display: inline-block;
183+
background-repeat: no-repeat;
184+
color: #4098fc;
185+
}
186+
.divList >.n-space {
187+
margin-top: 5px;
188+
}
189+
</style>

src/utils/main/gameScore.js

Lines changed: 85 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,92 @@
1-
import {queryMatchHistory} from "@/utils/main/lcu";
21
import {appConfig} from "@/utils/main/config";
2+
import {createHttp1Request, createHttp2Request, createHttpSession} from "@/utils/league-connect";
33

44

5-
// 获取召唤师游戏评分分数
6-
export const getGameScore = async (credentials,summonerId) => {
7-
let classicModeGames = await queryMatchHistory(credentials,summonerId)
8-
let gameScore = 0
9-
let gameCount = classicModeGames.length
10-
let kdaHistory = ''
11-
for (const modeGame of classicModeGames) {
12-
gameScore += analyseSingleMatch(modeGame.participants[0].stats)
13-
let tempKad = `${modeGame.participants[0].stats.kills}/${modeGame.participants[0].stats.deaths}/${modeGame.participants[0].stats.assists} `
14-
kdaHistory +=tempKad
5+
// 查询当前游戏模式
6+
const queryCurrentGameMode = async (credentials) => {
7+
// 获取当前游戏模式信息
8+
const currentGameInfo = (await createHttp1Request({
9+
method: "GET",
10+
url: '/lol-gameflow/v1/session',
11+
}, credentials)).json()
12+
try {
13+
return currentGameInfo.gameData.queue.id
14+
} catch (e) {
15+
return null
16+
}
17+
}
18+
19+
// 获取最近的比赛记录
20+
const getRencentMatchHistoty = async (credentials,session,summonerId) => {
21+
const matchList = (await createHttp2Request({
22+
method: "GET",
23+
url: `/lol-match-history/v3/matchlist/account/${summonerId}`,
24+
}, session, credentials)).json()['games']['games'].reverse()
25+
return matchList.slice(0,10)
26+
}
27+
28+
// 查询比赛记录 (最近5场排位)
29+
const queryMatchHistory = async (credentials,session,summonerId) => {
30+
const currentGameMode = await queryCurrentGameMode(credentials)
31+
console.log('当前游戏模式:', currentGameMode)
32+
// if (currentGameMode === null){
33+
// return await getRencentMatchHistoty(credentials,session,summonerId)
34+
// }
35+
36+
let classicMode = []
37+
let matchCount = 0
38+
for (let i = 0; i < 100; i += 20) {
39+
console.log(123)
40+
const matchList = (await createHttp2Request({
41+
method: "GET",
42+
url: `/lol-match-history/v3/matchlist/account/${summonerId}?begIndex=${i}&endIndex=${i + 20}`,
43+
}, session, credentials)).json()['games']['games'].reverse()
44+
45+
for (const matchListElement of matchList) {
46+
if (matchListElement.queueId == '450' && matchCount < 10) {
47+
matchCount += 1
48+
classicMode.push(matchListElement)
49+
}
50+
}
51+
if (matchCount === 10) {
52+
break
1553
}
16-
gameScore = parseInt(gameScore/gameCount)
17-
return {score:gameScore,horse:jundgeHorse(gameScore),kdaHistory:kdaHistory}
54+
}
55+
return classicMode
56+
}
57+
58+
// 获取召唤师游戏评分分数
59+
export const getGameScore = async (credentials, summonerId,session) => {
60+
let classicModeGames = await queryMatchHistory(credentials,session, summonerId)
61+
console.log(classicModeGames)
62+
let gameScore = 0
63+
let gameCount = classicModeGames.length
64+
let kdaHistory = ''
65+
for (const modeGame of classicModeGames) {
66+
gameScore += analyseSingleMatch(modeGame.participants[0].stats)
67+
let tempKad = `${modeGame.participants[0].stats.kills}/${modeGame.participants[0].stats.deaths}/${modeGame.participants[0].stats.assists} `
68+
kdaHistory += tempKad
69+
}
70+
gameScore = parseInt(gameScore / gameCount)
71+
return {score: gameScore, horse: jundgeHorse(gameScore), kdaHistory: kdaHistory}
1872
}
1973
// 通过分析单场数据得出单场得分情况
2074
const analyseSingleMatch = (match) => {
2175
let score = 100
22-
if (match['firstBloodKill']){score+=10} // 一血 加10分
23-
if (match['firstBloodAssist']){score+=5}// 一血助攻 加5分
24-
if (match['causedEarlySurrender']){score-=10} // 15投发起者 扣10分
25-
if (match['win']){score+=5} else {score-=5}// 游戏胜利 加5分
76+
if (match['firstBloodKill']) {
77+
score += 10
78+
} // 一血 加10分
79+
if (match['firstBloodAssist']) {
80+
score += 5
81+
}// 一血助攻 加5分
82+
if (match['causedEarlySurrender']) {
83+
score -= 10
84+
} // 15投发起者 扣10分
85+
if (match['win']) {
86+
score += 5
87+
} else {
88+
score -= 5
89+
}// 游戏胜利 加5分
2690
score += match['doubleKills'] * 2 // 一次双杀加2分
2791
score += match['tripleKills'] * 5 // 一次三杀加5分
2892
score += match['quadraKills'] * 10 // 一次四杀加10分
@@ -33,13 +97,13 @@ const analyseSingleMatch = (match) => {
3397
}
3498
// 判断是否为 上等马或者下等马
3599
const jundgeHorse = (score) => {
36-
if (score>=120){
100+
if (score >= 120) {
37101
return appConfig.get('horseType.top')
38-
}else if (score>=110){
102+
} else if (score >= 110) {
39103
return appConfig.get('horseType.mid')
40-
}else if(score>=100){
104+
} else if (score >= 100) {
41105
return appConfig.get('horseType.bot')
42-
}else if (score<100){
106+
} else if (score < 100) {
43107
return appConfig.get('horseType.trash')
44108
}
45109
}

0 commit comments

Comments
 (0)