Skip to content

Commit

Permalink
Adding a bunch of sorting and display methods
Browse files Browse the repository at this point in the history
(future me should update the wiki)
  • Loading branch information
slmnio committed Jan 7, 2024
1 parent 09ee522 commit e49ae0f
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 4 deletions.
35 changes: 34 additions & 1 deletion website/src/components/broadcast/Standings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ export default {
"Maps": { header: "Maps", title: "Maps won and lost" },
"MapDiff": { header: "Map Diff", title: "Maps won - maps lost" },
"ValorantRounds": { header: "RW-RL", title: "Rounds won - rounds lost" },
"ValorantRoundDiff": { header: "ΔR", title: "Round diff" }
"ValorantRoundDiff": { header: "ΔR", title: "Round diff" },
"Points": { header: "Points", title: "Team points" },
"MatchWins": { header: "Wins", title: "Match wins" },
"MatchLosses": { header: "Losses", title: "Match losses" },
"MatchDiffPoints": { header: "Match diff", title: "Matches won and lost (+ team points)" },
"MatchWinsPoints": { header: "Points", title: "Match wins + team points" },
"MatchesPoints": { header: "Summit Sorting", title: "Matches won - matches lost + team points" },
"Played": { header: "Played", title: "Matches played" },
"OPoints": { header: "Opp Pts", title: "Opponent points" },
"OMatchWinsPoints": { header: "Opp Pts", title: "Opponent points + match wins" }
})[col] || {
header: "-", title: col
};
Expand Down Expand Up @@ -277,6 +286,30 @@ export default {
return team;
});
}
console.log("preparing standings sort", this.standingsSort);
if (["OMatchWinsPoints", "OPoints"].some(s => this.standingsSort.includes(s))) {
console.log("preparing opponent points");
teams.map(team => {
team.standings.opponentPoints = [];
team.standings.opponentPointsMatchWins = [];
this.stageMatches.forEach(match => {
if (!(match.teams || []).some(t => t.code === team.code)) return;
const scores = [match.score_1, match.score_2];
if (!scores.some(score => score === match.first_to)) return; // not finished
const opponent = match.teams.find(t => t.code !== team.code);
if (!opponent) return null;
const localOpponent = teams.find(t => t.code === opponent.code);
team.standings.opponentPoints.push(localOpponent.extra_points || 0);
team.standings.opponentPointsMatchWins.push(localOpponent.standings.wins + (localOpponent.extra_points || 0));
});
// console.log(team.standings.opponentWinrates, avg(team.standings.opponentWinrates));
team.standings.opponent_points = team.standings.opponentPoints.reduce((c, v) => c + v, 0);
team.standings.opponent_points_wins = team.standings.opponentPointsMatchWins.reduce((c, v) => c + v, 0);
return team;
});
}
const sortFunction = (a, b) => {
if (a.standings.points > b.standings.points) return -1;
Expand Down
36 changes: 34 additions & 2 deletions website/src/components/broadcast/StandingsTeam.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ export default {
case "OMapWinrate":
stats.push("o_map_winrate_text");
break;
case "Points":
stats.push("points");
break;
case "MatchWins":
stats.push("wins");
break;
case "MatchDiffPoints":
stats.push("diff_points");
break;
case "MatchWinsPoints":
stats.push("wins_points");
break;
case "MatchesPoints":
stats.push("matches_points");
break;
case "Played":
stats.push("played");
break;
case "OPoints":
stats.push("opponent_points");
break;
case "OMatchWinsPoints":
stats.push("opponent_points_wins");
break;
default:
stats.push("empty");
}
Expand All @@ -81,11 +105,17 @@ export default {
},
teamStats() {
return {
wins: this.team.standings.wins,
losses: this.team.standings.losses,
played: this.team.standings.wins + this.team.standings.losses,
matches: `${this.team.standings.wins}-${this.team.standings.losses}`,
diff: diffString(this.team.standings.wins - this.team.standings.losses),
maps: `${this.team.standings.map_wins}-${this.team.standings.map_losses}`,
map_diff: diffString(this.team.standings.map_wins - this.team.standings.map_losses),
// points: this.team.standings.points,
points: this.team.extra_points,
wins_points: this.team.standings.wins + (this.team.extra_points || 0),
diff_points: diffString(this.team.standings.wins - this.team.standings.losses + (this.team.extra_points || 0)),
matches_points: `${this.team.standings.wins + (this.team.extra_points > 0 ? this.team.extra_points : 0)}-${this.team.standings.losses + (this.team.extra_points < 0 ? this.team.extra_points : 0)}`,
rank: this.team.standings.rank,
tie_show_number: this.team.standings.tie_show_number,
winrate: this.team.standings.winrate,
Expand All @@ -97,7 +127,9 @@ export default {
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}`,
map_rounds_diff: diffString(this.team.standings.map_round_wins - this.team.standings.map_round_losses)
map_rounds_diff: diffString(this.team.standings.map_round_wins - this.team.standings.map_round_losses),
opponent_points: this.team.standings.opponent_points,
opponent_points_wins: this.team.standings.opponent_points_wins
};
}
},
Expand Down
46 changes: 45 additions & 1 deletion website/src/utils/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,45 @@ export function sortByMatchDiff(a, b) {
return 0;
}

export function sortByMatchWins(a, b) {
const [aMatchDiff, bMatchDiff] = [a, b].map(x => (x.wins || x.standings.wins));

if (aMatchDiff < bMatchDiff) return 1;
if (aMatchDiff > bMatchDiff) return -1;
return 0;
}

export function sortByMatchWinsAndPoints(a, b) {
const [aNum, bNum] = [a, b].map(x => (x.wins || x.standings.wins) + (x.extra_points || 0));

if (aNum < bNum) return 1;
if (aNum > bNum) return -1;
return 0;
}

export function sortByMatchDiffAndPoints(a, b) {
const [aNum, bNum] = [a, b].map(x => (x.wins || x.standings.wins) - (x.losses || x.standings.losses) + (x.extra_points || 0));

if (aNum < bNum) return 1;
if (aNum > bNum) return -1;
return 0;
}
export function sortByOPoints(a, b) {
const [aNum, bNum] = [a, b].map(x => x.standings.opponent_points);

if (aNum < bNum) return 1;
if (aNum > bNum) return -1;
return 0;
}

export function sortByOMatchWinsPoints(a, b) {
const [aNum, bNum] = [a, b].map(x => x.standings.opponent_points_wins);

if (aNum < bNum) return 1;
if (aNum > bNum) return -1;
return 0;
}

export function miniLeagueMatchDiff(a, b) {
const [aMatchDiff, bMatchDiff] = [a, b].map(x => x.standings.minileague.wins - x.standings.minileague.losses);
if (aMatchDiff < bMatchDiff) return 1;
Expand Down Expand Up @@ -127,7 +166,7 @@ export function sortByOMapWinrate(a, b) {
}

export function sortByExtraPoints(a, b) {
const [aPoints, bPoints] = [a, b].map(x => (x.extra_points));
const [aPoints, bPoints] = [a, b].map(x => (x.extra_points || 0));
if (aPoints !== bPoints) {
if (aPoints > bPoints) return -1;
if (aPoints < bPoints) return 1;
Expand Down Expand Up @@ -397,6 +436,11 @@ function getSortMethod(stringMethod) {
if (stringMethod === "MapRoundsDiff") return { method: mapRoundsDiff, max: null };
if (stringMethod === "MapRoundWins") return { method: mapRoundWins, max: null };
if (stringMethod === "Points") return { method: sortByExtraPoints, max: null };
if (stringMethod === "MatchWins") return { method: sortByMatchWins, max: null };
if (stringMethod === "MatchWinsPoints") return { method: sortByMatchWinsAndPoints, max: null };
if (stringMethod === "MatchDiffPoints") return { method: sortByMatchDiffAndPoints, max: null };
if (stringMethod === "OPoints") return { method: sortByOPoints, max: null };
if (stringMethod === "OMatchWinsPoints") return { method: sortByOMatchWinsPoints, max: null };
return null;
}

Expand Down

0 comments on commit e49ae0f

Please sign in to comment.