Example #1
0
        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;
            }
        }
    }
    $matches = array_reverse($matches);
    foreach ($matches as $k => $value) {
        shuffle($courts);
        Scheduling::nextLevelMatch($event_id, $tour_id, $matches[$k]['id'], $matches[$k + 1]['id'], $courts[0], $allocate_time1, $y, $winner_bracket);
    }
}
Example #2
0
<?php

require_once '../php_include/db_connection.php';
require_once '../classes/AllClasses.php';
$event_id = $_REQUEST['event_id'];
$tour_id = $_REQUEST['tour_id'];
$data = array();
if (!($event_id && $tour_id)) {
    $success = "0";
    $msg = "Incomplete Parameters";
    $data = array();
} else {
    $success = '1';
    $msg = "Schedule";
    $data = Scheduling::BracketFormation($tour_id);
}
echo json_encode(array("success" => $success, "msg" => $msg, 'round' => $data));
Example #3
0
        if ($matches[$k + 1]) {
            Scheduling::nextLevelMatch($event_id, $tour_id, $matches[$k]['id'], $matches[$k + 1]['id'], $courts[0], $allocate_time1, $y, $winner_bracket);
        }
    }
    $loss_bracket_matches = array_reverse($loss_bracket_matches);
    $matches_wb_next = array_reverse($matches_wb_next);
    if (count($matches_wb_next) > 1) {
        $match_array = array_merge_recursive($loss_bracket_matches, $matches_wb_next);
    } else {
        $match_array = $loss_bracket_matches;
    }
    Scheduling::PhaseSeparation($event_id, $tour_id, $match_array, $courts, $y);
    // 	foreach ($loss_bracket_matches as $k => $value) {
    // 		shuffle($courts);
    // 		//if($loss_bracket_matches[$k+1])
    // 		Scheduling::nextLevelMatch($event_id,$tour_id,$value['id'],$loss_bracket_matches[$k+1]['id'],$courts[0],$allocate_time1,$y,$loser_bracket);
    // 	}
    // if($y>3){
    // 	$matches_wb_next=array_reverse($matches_wb_next);
    // 	foreach($matches_wb_next as $k => $value){
    // 	shuffle($courts);
    // 		//if($matches_wb[$k+1])
    //  			Scheduling::nextLevelMatch($event_id,$tour_id,$matches_wb_next[$k]['id'],$matches_wb_next[$k+1]['id'],$courts[0],$allocate_time1,$y,$loser_bracket);
    // 			}
    // }
}
$penultimate_game = Scheduling::getFinalGame($tour_id, $event_id);
Scheduling::nextLevelMatch($event_id, $tour_id, $penultimate_game[0]['wid'], $penultimate_game[0]['lid'], $courts[0], $allocate_time1, $n, $loser_bracket);
$final_game = Scheduling::getFinalGame($tour_id, $event_id);
Scheduling::nextLevelMatch($event_id, $tour_id, $final_game[0]['wid'], $final_game[0]['lid'], $courts[0], $allocate_time1, $n, $winner_bracket);
Example #4
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);
         }
     }
 }
Example #5
0
    $last_allocated_time = $start_date;
}
$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;
        }
    }
}
for ($i = count($players); $i > 0; $i--) {
    for ($j = 1; $j < $i; $j++) {
        if ($i != $j) {
            $team[] = $i . ',' . $j;
        }
    }
}
shuffle($team);
foreach ($team as $value) {
    $e = explode(',', $value);
    shuffle($courts);
    //echo $e[0].' ';
    //echo $e[1].'<br>';
    Scheduling::RobinLevelMatch($event_id, $tour_id, $e[0], $e[1], $courts[0], $allocate_time1, 1, $winner_bracket);
}