Beispiel #1
0
                $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $new_time);
                if ($allocated_count <= $match_per_day) {
                    $allocate_time = $new_time;
                }
            }
        }
        shuffle($courts);
        //$t- default bye for round 1
        Scheduling::saveEventMatch($event_id, $tour_id, $value, $t, $courts[0], $allocate_time, $winner_bracket);
    }
}
//BYE CASE
//n - no of rounds in the tournament
$n = Scheduling::getRounds($tour_id);
for ($y = 2; $y <= $n; $y++) {
    $last_allocated_time = Scheduling::getLastTimeAllocation($tour_id, $y - 1);
    $matches = Scheduling::getMatchesWithBye($tour_id, $y - 1);
    $match_per_day = Scheduling::getMatchCount($tour_id);
    $day_count = Scheduling::getDayGap($tour_id);
    $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $last_allocated_time);
    if ($allocated_count <= $match_per_day) {
        $allocate_time1 = $last_allocated_time;
    } else {
        for ($m = 1; $m < $day_count; $m++) {
            $new_time1 = date('Y-m-d H:i:s', strtotime(date("Y-m-d 10:00:00", strtotime($last_allocated_time)) . " +1 day"));
            $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $new_time1);
            if ($allocated_count <= $match_per_day) {
                $allocate_time1 = $new_time1;
            }
        }
    }
Beispiel #2
0
 public static function PhaseSeparation($event_id, $tour_id, $match_array, $courts, $round)
 {
     global $conn;
     $p3 = array();
     $p4 = array();
     $loser_bracket = 'L';
     $match_per_day = Scheduling::getMatchCount($tour_id);
     $day_count = Scheduling::getDayGap($tour_id);
     $first_loss_phase = 2 * count($match_array) - pow(2, ceil(log(count($match_array), 2)));
     //match_array- matches without bye
     foreach ($match_array as $key => $value) {
         if ($key < $first_loss_phase) {
             array_push($p3, $value);
         } else {
             array_push($p4, $value);
         }
     }
     //Round1 loss case
     if (count($p3)) {
         for ($i = 0; $i < count($p3); $i++) {
             $last_allocated_time = Scheduling::getLastTimeAllocation($tour_id, 1);
             $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $last_allocated_time);
             if ($allocated_count <= $match_per_day) {
                 $allocate_time = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s", strtotime($last_allocated_time)) . " +1 day"));
             } else {
                 for ($j = 1; $j < $day_count; $j++) {
                     $last_allocated_time = Scheduling::getLastTimeAllocation($tour_id, 1);
                     $new_time = date('Y-m-d H:i:s', strtotime(date("Y-m-d 10:00:00", strtotime($last_allocated_time)) . " +1 day"));
                     $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $new_time);
                     if ($allocated_count <= $match_per_day) {
                         $allocate_time = $new_time;
                     } else {
                         $allocate_time = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s", strtotime($last_allocated_time)) . " +1 hour"));
                     }
                 }
             }
             shuffle($courts);
             //$t- default bye for round 1
             Scheduling::nextLevelMatch($event_id, $tour_id, $p3[$i]['id'], $p3[++$i]['id'], $courts[0], $allocate_time, $round, $loser_bracket);
         }
     }
     //Round 1 loss case default bye
     if (count($p4)) {
         foreach ($p4 as $key => $value) {
             $last_allocated_time_1 = Scheduling::getLastTimeAllocation($tour_id, 1);
             $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $last_allocated_time_1);
             if ($allocated_count <= $match_per_day) {
                 $allocate_time = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s", strtotime($last_allocated_time_1)) . " +1 hour"));
             } else {
                 for ($i = 1; $i < $day_count; $i++) {
                     $last_allocated_time_1 = Scheduling::getLastTimeAllocation($tour_id, 1);
                     $new_time = date('Y-m-d H:i:s', strtotime(date("Y-m-d 10:00:00", strtotime($last_allocated_time_1)) . " +1 day"));
                     $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $new_time);
                     if ($allocated_count <= $match_per_day) {
                         $allocate_time = $new_time;
                     } else {
                         $allocate_time = date('Y-m-d H:i:s', strtotime(date("Y-m-d 10:00:00", strtotime($last_allocated_time)) . " +1 hour"));
                     }
                 }
             }
             shuffle($courts);
             //$t- default bye for round 1
             Scheduling::nextLevelMatch($event_id, $tour_id, $value['id'], $t, $courts[0], $allocate_time, $round, $loser_bracket);
         }
     }
 }