Skip to content

Commit

Permalink
Removed some logging, expanded h2h maps for broadcast, clickable things
Browse files Browse the repository at this point in the history
  • Loading branch information
slmnio committed Nov 17, 2021
1 parent 1139704 commit e0751c7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
36 changes: 31 additions & 5 deletions website/src/components/website/EventScenarios2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@

<table class="table-bordered text-light mb-3" v-if="counts && counts[0] && counts[0].positions">
<tr v-if="counts" class="font-weight-bold">
<th class="p-2 border-dark text-right">{{ showCountsAsPercentages ? `% of ${currentScenarioView.length} scenarios` : `/${currentScenarioView.length} scenarios`}}</th>
<th class="p-2 border-dark text-right" style="min-width: 8.5em">{{ showCountsAsPercentages ? `% of ${currentScenarioView.length} scenarios` : `/${currentScenarioView.length} scenarios`}}</th>
<th class="p-2 border-dark" v-for="(x, i) in (counts[0].positions).slice(0, -1)" v-bind:key="i">
#{{ i + 1 }}
</th>
<th class="p-2 border-dark" v-b-tooltip:top="'Standings haven\'t converged into separate groups'">Incomplete</th>
</tr>
<tr v-for="team in counts" v-bind:key="team.code">
<td class="p-2 border-dark text-right font-weight-bold">{{ team.code }}</td>
<td class="p-2 border-dark" v-for="(pos, posi) in team.positions" v-bind:key="posi">
<td class="p-2 border-dark cell-num" v-for="(pos, posi) in team.positions" v-bind:key="posi"
@click="() => showWhen(team.code, posi)"
v-bind:class="{ 'bg-info': manualScenarioFilters.find((f) => f.team === team.code && f.position === posi ) }"
>
<span v-if="showCountsAsPercentages">{{ (pos / currentScenarioView.length) | perc }}</span>
<span v-else>{{ pos }}</span>
</td>
Expand Down Expand Up @@ -105,7 +108,8 @@ export default {
activeScenarioView: "all",
showCountsAsPercentages: true,
showOnlyPossible: true,
showOnlyIncomplete: false
showOnlyIncomplete: false,
manualScenarioFilters: []
}),
computed: {
blocks() {
Expand All @@ -127,6 +131,12 @@ export default {
if (!scenarios) return [];
if (this.showOnlyIncomplete) scenarios = scenarios.filter(s => s.standings.length !== s.teams.length);
if (this.showOnlyPossible) scenarios = scenarios.filter(s => !s.impossible);
if (this.manualScenarioFilters?.length) {
scenarios = scenarios.filter(s => this.manualScenarioFilters.some(({ team, position }) => {
return s.standings[position].some(t => t.code === team);
}));
}
return scenarios;
},
matchGroups() {
Expand Down Expand Up @@ -429,15 +439,15 @@ export default {
// // quick default sort
// scenario.teams.sort(sortFunction);
console.log("sort", i + 1, this.blocks.standingsSort);
// console.log("sort", i + 1, this.blocks.standingsSort);
if (this.sortingMethods) {
scenario.standings = sortTeamsIntoStandings(scenario.teams, {
sort: this.sortingMethods
});
} else {
scenario.standings = sortTeamsIntoStandings(scenario.teams);
}
console.log(scenario.standings);
// console.log(scenario.standings);
//
// scenario.standings = sortIntoGroups2(sortByMapWins, [scenario.teams]);
// if (i === 4050) console.log(i, scenario.standings);
Expand Down Expand Up @@ -494,6 +504,18 @@ export default {
return (x * 100).toFixed(1) + "%";
// console.log(x, this.currentScenarioView.length);
}
},
methods: {
showWhen(team, position) {
if (this.filterHas(team, position)) return this.manualScenarioFilters.splice(this.filterIndex(team, position), 1);
this.manualScenarioFilters.push({ team, position });
},
filterIndex(team, position) {
return this.manualScenarioFilters.findIndex((f) => f.team === team && f.position === position);
},
filterHas(team, position) {
return this.filterIndex(team, position) !== -1;
}
}
};
</script>
Expand All @@ -502,4 +524,8 @@ export default {
td {
border-bottom: 1px solid #555;
}
.cell-num {
min-width: 3em;
text-align: center;
}
</style>
18 changes: 9 additions & 9 deletions website/src/utils/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ export function sortWithinGroups(sortFunction, standings) {
function miniLeaguePrep(standings) {
for (const group of standings) {
if (group.length <= 1) continue;
console.log("minileagueprep", group);
if (group.length === 2) console.log("minileague h2h", group);
// console.log("minileagueprep", group);
// if (group.length === 2) console.log("minileague h2h", group);

const groupIDs = group.map(g => g.id);

group.forEach(team => {
console.log("minileague setup", team.id, groupIDs, team.standings.h2h);
// console.log("minileague setup", team.id, groupIDs, team.standings.h2h);
team.standings.minileague = {
wins: 0,
losses: 0,
Expand All @@ -307,10 +307,10 @@ function miniLeaguePrep(standings) {
});
});

console.log(group);
console.log(group.sort(miniLeagueMatchDiff).map(t => `|${t.code.padStart(6, " ")} ${t.standings.minileague.wins}-${t.standings.minileague.losses} (${t.standings.minileague.map_diff})`).join("\n"));
// console.log(group);
// console.log(group.sort(miniLeagueMatchDiff).map(t => `|${t.code.padStart(6, " ")} ${t.standings.minileague.wins}-${t.standings.minileague.losses} (${t.standings.minileague.map_diff})`).join("\n"));

if (group.length === 2) console.log("minileague h2h", standings);
// if (group.length === 2) console.log("minileague h2h", standings);
/*
* Set up a minileague
* - Take all the head to heads from all the teams in the tied group
Expand All @@ -332,12 +332,12 @@ function getSortMethod(stringMethod) {
}

export function sortTeamsIntoStandings(teams, settings = {}) {
const log = true;
const log = false;
if (log) console.log("[standings]", "starting sort", teams, settings);

if (settings.sort) {
// Custom sort
console.log("[standings]", `Sorting in custom order: ${settings.sort}`);
if (log) console.log("[standings]", `Sorting in custom order: ${settings.sort}`);
let standings = [teams];
for (const mode of settings.sort) {
const _method = getSortMethod(mode);
Expand All @@ -351,7 +351,7 @@ export function sortTeamsIntoStandings(teams, settings = {}) {
} else {
standings = sortIntoGroups2(method, standings);
}
console.log("[standings]", `[${mode}]`, standings);
if (log) console.log("[standings]", `[${mode}]`, standings);
}
return standings;
}
Expand Down

0 comments on commit e0751c7

Please sign in to comment.