Changeset 306 for trunk/leaguerunner
- Timestamp:
- 08/11/05 09:27:17 (5 years ago)
- Location:
- trunk/leaguerunner/src
- Files:
-
- 2 modified
-
classes/league.inc (modified) (7 diffs)
-
includes/common.inc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/leaguerunner/src/classes/league.inc
r303 r306 930 930 931 931 # sort team's so that pyramid scheme can work properly 932 // TODO: MAKE SURE TO TEST THIS....... IT'S NOT FULLY TESTED!!!!!!933 // HACK: ugly... have to call the calculate_standings method to be able to get934 // game info so that the ladder sort can use SOTG as the second criteria...935 // Otherwise, I could just do:936 // $teams = $this->teams;937 // uasort($teams, 'standings_sort_ladder_tony');938 932 $teams = array(); 939 933 list($team_ids, $junk, $morejunk) = $this->calculate_standings(); … … 1088 1082 * This does the actual work of scheduling a one set pyramid set of games. 1089 1083 * However it has some problems where it may not properly schedule all 1090 * the games. If it runs into problems then we use the wrapper 1084 * the games. If it runs into problems then we use the wrapper 1091 1085 * function that calls this one to retry it. 1086 * If any problems are found then this function rolls back it's changes. 1092 1087 */ 1093 function schedule_one_set_pyramid_try( $teams, 1094 $datestamp, 1088 function schedule_one_set_pyramid_try( $teams, 1089 $datestamp, 1095 1090 $games_before_repeat 1096 1091 ) 1097 { 1098 //TODO: use transactions 1099 $rollback_list = array(); 1092 { 1093 $rollback_list = array(); 1100 1094 1101 1095 $versus_team1 = array(); … … 1126 1120 $team = array_shift($teams); 1127 1121 // gotta load this team's games to see who they've played recently... 1128 $past_games = game_load_many( array( 'either_team' => $team->team_id, 1122 $past_games = game_load_many( array( 'either_team' => $team->team_id, 1129 1123 '_order' => 'g.game_date') ); 1130 1124 if ($past_games == null) … … 1200 1194 $versus_team1[] = $team; 1201 1195 $versus_team2[] = $opponent; 1202 1203 //print "Matching " . $team->team_id . " " . $opponent->team_id . "\n";1204 1196 } 1205 1197 … … 1224 1216 list($rc, $message) = $g->select_weighted_gameslot($datestamp); 1225 1217 if( ! $rc ) { 1226 print "$rc: $message"; 1227 // Argh, something failed, so roll back the whole pile of games 1218 // something failed, so roll back the whole pile of games 1228 1219 foreach( $rollback_list as $to_rollback ) { 1229 1220 if( ! $to_rollback->delete() ) { … … 1252 1243 for ($j = 0; $j < $max_retries; $j++) { 1253 1244 /* 1254 * this returns "REPEAT" if it needs to get repeated 1245 * if we get back "REPEAT" then we can try again because it didn't work 1246 * in finding a set of matches for everyone given the paramters we gave it. 1247 * After a while we lower our requirements and try again. The randomizing 1248 * inside this function will make it work sometimes and fail others, but 1249 * eventually we'll get a good matchup. 1255 1250 */ 1256 1251 $ret = $this->schedule_one_set_pyramid_try( $teams, $datestamp, $i); … … 1431 1426 } 1432 1427 1433 function standings_sort_ladder_tony (&$a, &$b)1434 {1435 /* Check Rank */1436 if ($a->rank != $b->rank) {1437 return ($a->rank < $b->rank) ? -1 : 1;1438 }1439 1440 /* Check SOTG */1441 if($a->games > 0 && $b->games > 0) {1442 if( ($a->spirit / $a->games) > ($b->spirit / $b->games)) {1443 return -1;1444 } else if( ($a->spirit / $a->games) < ($b->spirit / $b->games)) {1445 return 1;1446 }1447 }1448 return 0;1449 }1450 1451 1428 ?> -
trunk/leaguerunner/src/includes/common.inc
r279 r306 296 296 297 297 $base_url = $BASE_URL; 298 $cleanURL = variable_get('clean_url', 1);298 $cleanURL = variable_get('clean_url', 0); 299 299 300 300 if (empty($script)) {
