Skip to content

Commit

Permalink
Update standings for opponent calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
slmnio committed Apr 8, 2022
1 parent c83ac34 commit c8f7aa6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
11 changes: 7 additions & 4 deletions website/src/components/broadcast/Standings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,16 @@ export default {
});
team.standings.winrate = team.standings.wins / team.standings.played;
team.standings.map_winrate = team.standings.map_wins / (team.standings.map_losses + team.standings.map_wins);
return team;
});
if (this.useOMW) {
if (this.useOMW || this.standingsSort.includes("OMapWinrate")) {
teams.map(team => {
team.standings.opponentWinrates = [];
team.standings.opponentMapWinrates = [];
this.stageMatches.forEach(match => {
if (!(match.teams || []).some(t => t.code === team.code)) return;
Expand All @@ -251,12 +253,13 @@ export default {
const opponent = match.teams.find(t => t.code !== team.code);
if (!opponent) return null;
const localOpponent = teams.find(t => t.code === opponent.code);
const opponentWinrate = localOpponent.standings.winrate;
team.standings.opponentWinrates.push(opponentWinrate);
team.standings.opponentWinrates.push(localOpponent.standings.winrate);
team.standings.opponentMapWinrates.push(localOpponent.standings.map_winrate);
});
// console.log(team.standings.opponentWinrates, avg(team.standings.opponentWinrates));
team.standings.omw = avg(team.standings.opponentWinrates);
team.standings.opponent_winrate = avg(team.standings.opponentWinrates);
team.standings.opponent_map_winrate = avg(team.standings.opponentMapWinrates);
return team;
});
}
Expand Down
18 changes: 15 additions & 3 deletions website/src/components/broadcast/StandingsTeam.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export default {
case "ValorantRoundDiff":
stats.push("map_rounds_diff");
break;
case "OMatchWinrate":
stats.push("o_match_winrate_text");
break;
case "OMapWinrate":
stats.push("o_map_winrate_text");
break;
default:
stats.push("empty");
}
Expand All @@ -82,8 +88,11 @@ export default {
rank: this.team.standings.rank,
tie_show_number: this.team.standings.tie_show_number,
winrate: this.team.standings.winrate,
winrate_text: isNaN(this.team.standings.winrate) ? "---" : (this.team.standings.winrate * 100).toFixed(0) + "%",
mapwinrate_text: "---",
winrate_text: this.winrateText(this.team.standings.winrate),
mapwinrate: this.team.standings.map_winrate,
mapwinrate_text: this.winrateText(this.team.standings.map_winrate),
o_match_winrate_text: this.winrateText(this.team.standings.opponent_winrate),
o_map_winrate_text: this.winrateText(this.team.standings.opponent_map_winrate),
omw: this.team.standings?.omw !== undefined ? Math.floor(this.team.standings.omw * 100) + "%" : "-",
empty: "-",
map_rounds: `${this.team.standings.map_round_wins}-${this.team.standings.map_round_losses}`,
Expand All @@ -92,7 +101,10 @@ export default {
}
},
methods: {
url
url,
winrateText(num) {
return isNaN(num) ? "-" : (num * 100).toFixed(0) + "%";
}
}
};
</script>
Expand Down
19 changes: 19 additions & 0 deletions website/src/utils/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ export function sortByHeadToHead(a, b) {
return a.h2h[b.id] || 0;
}

export function sortByOMatchWinrate(a, b) {
const [aDiff, bDiff] = [a, b].map(x => x.standings.opponent_winrate);
if (aDiff !== bDiff) {
if (aDiff > bDiff) return -1;
if (aDiff < bDiff) return 1;
}
return 0;
}
export function sortByOMapWinrate(a, b) {
const [aDiff, bDiff] = [a, b].map(x => x.standings.opponent_map_winrate);
if (aDiff !== bDiff) {
if (aDiff > bDiff) return -1;
if (aDiff < bDiff) return 1;
}
return 0;
}

export function sortByMapDiff(a, b) {
// if (a.map_wins > b.map_wins) return -1;
// if (a.map_wins < b.map_wins) return 1;
Expand Down Expand Up @@ -335,6 +352,8 @@ function getSortMethod(stringMethod) {
if (stringMethod === "HeadToHead") return { method: sortByHeadToHead, max: 2 };
if (stringMethod === "MapWins") return { method: sortByMapWins, max: null };
if (stringMethod === "OMW") return { method: sortByOMW, max: null };
if (stringMethod === "OMapWinrate") return { method: sortByOMapWinrate, max: null };
if (stringMethod === "OMatchWinrate") return { method: sortByOMatchWinrate, max: null };
if (stringMethod === "MiniLeague") return { prep: miniLeaguePrep, method: miniLeagueMatchDiff, max: null };
if (stringMethod === "MiniLeagueMaps") return { prep: miniLeaguePrep, method: miniLeagueMapDiff, max: null };
if (stringMethod === "MapRoundsDiff") return { method: mapRoundsDiff, max: null };
Expand Down

0 comments on commit c8f7aa6

Please sign in to comment.