Location: PHPKode > projects > Online Fantasy Football League > offl-0.2.6/www/playoffseedings.php
<?php
/**
 * Playoff rankings
 *
 * Incomplete
 *
 * @author Stephen Rochelle <hide@address.com>
 * @version OFFL v0.2
 * @copyright Copyright (c) 2004 Stephen Rochelle.  Some rights reserved.
 * @package offl-ui
 */

$pageTitle = "Playoff Seedings (Test only)";
require_once("offlconfig.php");
require_once($DOC_ROOT . "/lib/header.php"); 
if(empty($_GET["year"]))
{
	$_GET["year"] = getThisYear();
}

$game_lookup = new )FFL_Game();
$week = getCurrentWeek($_GET["year"]);
$x = new OFFL_FFLTeam();
$teams = $x->getAllFFLTeams();
$x = new OFFL_Division();
$divisions = $x->getAllDivisions();
$team_array = array();
foreach ($divisions as $division)
{
	$team_array[] = $x->getAllDivisionTeams($division->getDivisionID());
}
$maxtm = 0;
foreach ($team_array as $divisionlist)
{
	if (sizeof($divisionlist) > $maxtm)
		$maxtm = sizeof($divisionlist);
}

/* OK... I want to test the various seeding options 

I need:
League rankings, straight
	by Win Pct, Wins, Points Forced
	(head-to-head as 3rd criterion if avail)

Division Winners
	by Win Pct, Wins, Div Win Pct, Div Wins, PF, DivPF
	(head-to-head as 3rd criterion if avail)

League WCs (league rank sans div winners)
	see league rankings

Division WCs (division rank sans division winner)
	see division winners
*/

function league_rank($tm1, $tm2)
{
	if($tm1->getOverallWinPct($_GET["year"]) > $tm2->getOverallWinPct($_GET["year"]))
		return -1;
	if($tm1->getOverallWinPct($_GET["year"]) < $tm2->getOverallWinPct($_GET["year"]))
		return 1;
	if($tm1->getOverallWins($_GET["year"]) > $tm2->getOverallWins($_GET["year"]))
		return -1;
	if($tm1->getOverallWins($_GET["year"]) < $tm2->getOverallWins($_GET["year"]))
		return 1;
	if($tm1->getOverallPF($_GET["year"]) > $tm2->getOverallPF($_GET["year"]))
		return -1;
	if($tm1->getOverallPF($_GET["year"]) < $tm2->getOverallPF($_GET["year"]))
		return 1;
	return 0; // random tiebreaker
}

function division_rank($tm1, $tm2)
{
	if($tm1->getOverallWinPct($_GET["year"]) > $tm2->getOverallWinPct($_GET["year"]))
		return -1;
	if($tm1->getOverallWinPct($_GET["year"]) < $tm2->getOverallWinPct($_GET["year"]))
		return 1;
	if($tm1->getOverallWins($_GET["year"]) > $tm2->getOverallWins($_GET["year"]))
		return -1;
	if($tm1->getOverallWins($_GET["year"]) < $tm2->getOverallWins($_GET["year"]))
		return 1;
	if($tm1->getDivisionWinPct($_GET["year"]) > $tm2->getDivisionWinPct($_GET["year"]))
		return -1;
	if($tm1->getDivisionWinPct($_GET["year"]) < $tm2->getDivisionWinPct($_GET["year"]))
		return 1;
	if($tm1->getDivisionWins($_GET["year"]) > $tm2->getDivisionWins($_GET["year"]))
		return -1;
	if($tm1->getDivisionWins($_GET["year"]) < $tm2->getDivisionWins($_GET["year"]))
		return 1;
	if($tm1->getOverallPF($_GET["year"]) > $tm2->getOverallPF($_GET["year"]))
		return -1;
	if($tm1->getOverallPF($_GET["year"]) < $tm2->getOverallPF($_GET["year"]))
		return 1;
	if($tm1->getDivisionPF($_GET["year"]) > $tm2->getDivisionPF($_GET["year"]))
		return -1;
	if($tm1->getDivisionPF($_GET["year"]) < $tm2->getDivisionPF($_GET["year"]))
		return 1;
	return 0; // random tiebreaker
}

usort($teams, "league_rank");
for ($i = 0; $i < sizeof($team_array); $i++)
	usort($team_array[$i], "division_rank");

echo "<h3>League Rankings</h3>\n";
foreach ($teams as $team)
{
	echo "<p>" . $team->getFFLTeamFullName() . "</p>\n";
}
echo "<h3>Division Winners</h3>\n";
foreach ($team_array as $division)
{
	echo "<h4>" . $division[0]->getDivisionDesc() . "</h4>";
	echo "<p>" . $division[0]->getFFLTeamFullName() . "</p>\n";
}
for ($i = 0; $i < sizeof($teams); $i++)
	foreach ($team_array as $division)
		if ($teams[$i]->getFFLTeamID() == $division[0]->getFFLTeamID())
		{
			unset($teams[$i]);
			break;
		}
echo "<h3>League Wild Cards</h3>\n";
foreach ($teams as $team)
{
	echo "<p>" . $team->getFFLTeamFullName() . "</p>\n";
}
for ($i = 0; $i < sizeof($team_array); $i++)
	array_shift($team_array[$i]);
echo "<h3>Division Wild Cards</h3>\n";
foreach ($team_array as $division)
{
	$x = reset($division);
	echo "<h4>" . $x->getDivisionDesc() . "</h4>\n";
	foreach ($division as $team)
		echo "<p>" . $team->getFFLTeamFullName() . "</p>\n";
}

require($DOC_ROOT . "/lib/footer.php"); ?>
Return current item: Online Fantasy Football League