working on economy graph

This commit is contained in:
cnachtigall1991
2021-10-19 07:24:16 +02:00
parent 5f96a72e76
commit 482008c77b
8 changed files with 152 additions and 10 deletions

View File

@@ -0,0 +1,108 @@
<template>
<table v-if="data.rounds">
<thead>
<tr>
<th>p1</th>
<th>p2</th>
</tr>
</thead>
<tbody v-if="data.eq_teams">
<tr v-for="(round, i) in data.eq_teams[0][0]" :key="data.eq_teams[0][i]">
<td>{{i + ' - ' + round}}</td>
</tr>
</tbody>
</table>
</template>
<script>
import {getPlayerValue} from "../utils";
import {useStore} from "vuex";
import {onMounted, reactive} from "vue";
export default {
name: "EqValueGraph",
setup() {
const store = useStore()
const data = reactive({
rounds: {},
team: [],
eq_team_1: [],
eq_team_2: [],
eq_team_player_1: [],
eq_team_player_2: [],
eq_teams: []
})
const getTeamPlayer = (stats, team) => {
let arr = []
for (let i = (team - 1) * 5; i < team * 5; i++) {
arr.push(stats[i].player.steamid64)
}
return arr
}
const parseObject = async () => {
data.rounds = await getPlayerValue(store.state.matchDetails.match_id)
let eq_1 = []
let eq_2 = []
for (const round in data.rounds) {
for (const player in data.rounds[round]) {
for (let p in data.team[0]) {
if (data.team[0][p] === player) {
eq_1.push({
round: round,
player: player,
eq: (data.rounds[round][player][0] + data.rounds[round][player][2])
})
}
}
for (let p in data.team[1]) {
if (data.team[1][p] === player) {
eq_2.push({
round: round,
player: player,
eq: (data.rounds[round][player][0] + data.rounds[round][player][2])
})
}
}
}
}
data.eq_team_player_1.push(eq_1)
data.eq_team_player_2.push(eq_2)
data.eq_team_1.push(sumArr(eq_1))
data.eq_team_2.push(sumArr(eq_2))
}
const sumArr = (arr) => {
return arr.reduce((acc, current) => ({
...acc,
[current.round]: (acc[current.round] || 0) + current.eq
}), {})
}
onMounted(() => {
data.team.push(getTeamPlayer(store.state.matchDetails.stats, 1))
data.team.push(getTeamPlayer(store.state.matchDetails.stats, 2))
parseObject()
data.eq_teams.push(data.eq_team_1, data.eq_team_2)
// console.log(data.eq_team)
})
return {data}
}
}
</script>
<style scoped>
</style>

View File

@@ -9,3 +9,12 @@ export const HITGROUPS = {
7: 'HitGroupRightLeg',
10: 'HitGroupGear'
}
export const GRENADES = {
501: 'EqDecoy', // eqElementToName[EqDecoy] = "Decoy Grenade"
502: 'EqMolotov', // eqElementToName[EqMolotov] = "Molotov"
503: 'EqIncendiary', // eqElementToName[EqIncendiary] = "Incendiary Grenade"
504: 'EqFlash', // eqElementToName[EqFlash] = "Flashbang"
505: 'EqSmoke', // eqElementToName[EqSmoke] = "Smoke Grenade"
506: 'EqHE', // eqElementToName[EqHE] = "HE Grenade"
}

View File

@@ -46,6 +46,12 @@ const routes = [
score: lazyLoadComponent('ScoreTeam')
}
},
{
path: 'Economy',
components: {
score: lazyLoadComponent('EqValueGraph')
}
},
{
path: 'details',
components: {

View File

@@ -54,3 +54,15 @@ export const TrackMe = async (id64, authcode, sharecode) => {
return [status, statusError]
}
export const getPlayerValue = async (match_id) => {
try {
const res = await axios.get(`${API_URL}/match/${match_id}/rounds`)
if (res.status === 200) {
return res.data
}
} catch (err) {
console.log(err.response.status, err.response.statusText)
}
}

View File

@@ -3,7 +3,7 @@ import {GoToLink, GoToMatch, GoToPlayer} from "./GoTo";
import {SaveLastVisitedToLocalStorage} from "./LocalStorage";
import {GetHLTV_1} from "./HLTV";
import {DisplayRank, LoadImage} from "./Display";
import {GetUser, TrackMe} from "./ApiRequests";
import {GetUser, TrackMe, getPlayerValue} from "./ApiRequests";
import {setTitle, GetWinLoss, truncate, checkStatEmpty, getPlayerArr, constructAvatarUrl, GetAvgRank} from "./Utils";
export {
@@ -12,6 +12,6 @@ export {
SaveLastVisitedToLocalStorage,
GetHLTV_1,
DisplayRank, LoadImage,
GetUser, TrackMe,
GetUser, TrackMe, getPlayerValue,
setTitle, GetWinLoss, truncate, checkStatEmpty, getPlayerArr, constructAvatarUrl, GetAvgRank
}

View File

@@ -41,6 +41,13 @@
replace>Scoreboard
</router-link>
</li>
<li :title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''"
class="list-item nav-item">
<router-link :class="!data.matchDetails.parsed ? 'disabled' : ''" :disabled="!data.matchDetails.parsed"
:to="'/match/' + data.matchDetails.match_id + '/economy'" class="nav-link"
replace>Economy
</router-link>
</li>
<li :title="!data.matchDetails.parsed ? 'This demo has not been parsed' : ''"
class="list-item nav-item">
<router-link :class="!data.matchDetails.parsed ? 'disabled' : ''" :disabled="!data.matchDetails.parsed"