]> git.sesse.net Git - ultimatescore/blobdiff - update_sheets.js
Make the roster scripts executable.
[ultimatescore] / update_sheets.js
index b6e842648bfd083a73e0323f695fc79e4d5ef9e5..24381358ed52713cca0f129ef5ac424cccede69e 100644 (file)
@@ -248,7 +248,9 @@ function montecarlo(all_teams, groups, games, groups_to_calc) {
                                third_groups = ranked;
                        } else {
                                for (let i = 0; i < groups_to_calc.length; ++i) {
-                                       if (third_groups[i].group_idx !== ranked[i].group_idx) {
+                                       if (third_groups[i].group_idx !== ranked[i].group_idx ||  // Different from a previous simulation.
+                                           (i < (third_groups.length - 1) && ranked[i].rank === ranked[i + 1].rank) ||  // Disallow ties.
+                                           (i > 0 && ranked[i].rank === ranked[i - 1].rank)) {  // Disallow ties.
                                                third_groups[i].group_idx = null;
                                        }
                                }
@@ -316,7 +318,7 @@ function do_replacements(str, replacements) {
        return str;
 }
 
-function fill_playoff(all_teams, groups, replacements, teams) {
+function fill_playoff(all_teams, groups, replacements) {
        let team_expansions = {};
        for (const team of all_teams) {
                team_expansions[team.name] = team_expansions[team.mediumname] = team_expansions[team.shortname] =
@@ -392,6 +394,8 @@ function fill_playoff(all_teams, groups, replacements, teams) {
                                        get_all_group_games(all_teams, groups, function(group_games) {
                                                // NOTE: filter_teams_by_group will be delayed by one cycle
                                                // after W P1 etc. becomes determined for the first time.
+                                               // Note that this requires the Groups sheet to pick out
+                                               // the right teams from the group matches in the Results sheet!
                                                let teams_l1 = filter_teams_by_group(all_teams, groups, 'Playoffs 9th–11th');
                                                let teams_l2 = filter_teams_by_group(all_teams, groups, 'Playoffs 12th–14th');
                                                publish_group_rank(teams_l1, group_games, 'Playoffs 9th–11th');
@@ -428,7 +432,7 @@ function publish_group_ranks() {
                                publish_group_rank(teams_c, games, 'Group C');
 
                                let replacements = montecarlo(teams, groups, games, ['Group A', 'Group B', 'Group C']);
-                               fill_playoff(teams, groups, replacements, [teams_a, teams_b, teams_c]);
+                               fill_playoff(teams, groups, replacements);
                        });
                });
        });
@@ -436,6 +440,7 @@ function publish_group_ranks() {
 
 function get_all_playoff_games(teams, groups, group_games, cb) {
        let replacements = montecarlo(teams, groups, group_games, ['Group A', 'Group B', 'Group C']);
+       fill_playoff(teams, groups, replacements);  // To get the replacements.
        let games = ultimateconfig['playoff_games'];
        get_results('Results', function(response) {
                let playoff_games = [];