예제 #1
0
function getAverageAndBest(&$average,&$best)
{
	global 
		$times,$timetype,$avgtype,
		$timelimit, $tries, $cutpassed;
	//
	$average = 0;
	$dnfs = 0;
	if (!$timelimit)
		$timelimit_hh = 0;
	else
		$timelimit_hh = timeNum($timelimit);
	switch($timetype)
	{
	case 1:
		$b = timeNum("999:59.99") + 1;
		break;
	case 2:
		$b = timeNum("80") + 1;
		break;
	default:
		$b = timeNum("0102060:00.00") + 1;
	}
	$w = 0;
	for ($x=1;$x<=$times;$x++)
	{
		if ($x<=$tries || $cutpassed)
		{
			$t = timeNum($_GET["t$x"]);
			if ($t<0)
				$dnfs++;
			else
			{
				if ($t<$b) 
				{
					$b = $t;
					$bidx = $x;
				}
				if ($timetype!=3)
				{
					if ($t>$w) $w = $t;
					$average += $t;
				}
				if ($timelimit_hh && !$cutpassed && $t<$timelimit_hh) $cutpassed = true;
			}
		}
	}
	// set BEST
	if (!$cutpassed && ($dnfs==$tries))
		$best = "DNF";
	elseif ($dnfs==$times)
		$best = "DNF";
	else
		$best = $_GET["t$bidx"];
	// set AVERAGE
	switch($avgtype)
	{
	case 0: // average of 5
		if (!$cutpassed)
			$average = "";
		elseif ($dnfs>1)
			$average = "DNF";
		elseif ($dnfs==1)
			$average = numTime(($average-$b)/($times-2));
		else
			$average = numTime(($average-$b-$w)/($times-2));
		break;
	case 1: // mean of 3
		if (!$cutpassed)
			$average = "";
		elseif ($dnfs)
			$average = "DNF";
		else
			$average = numTime($average/$times);
		break;
	default: // best
		if ($timetype!=3)
			$average = "";
		elseif ($dnfs==$times)
			$average = "DNF";
		else
			$average = sprintf("%015d",$b); // trick to show results ordered
	}
}
예제 #2
0
function getAverageAndBest(&$average,&$best)
{
	global 
		$times,$timetype,$avgtype,
		$scores, $scoresread;
	//
	$average = 0;
	$dnfs = 0;
	switch($timetype)
	{
	case 1:
		$b = timeNum("999:59.99") + 1;
		break;
	case 2:
		$b = timeNum("80") + 1;
		break;
	default:
		$b = timeNum("0102060:00.00") + 1;
	}
	$w = 0;
	for ($x=1;$x<=$scoresread;$x++)
	{
		$t = $timetype==3 ? timeNum($scores[$x]) : $scores[$x];
		if ($t<0)
			$dnfs++;
		else
		{
			if ($t<$b) 
			{
				$b = $t;
				$bidx = $x;
			}
			if ($timetype!=3)
			{
				if ($t>$w) $w = $t;
				$average += $t;
			}
		}
	}
	$cutpassed = ($scoresread==$times);
	// set BEST
	if ($dnfs==$scoresread)
		$best = "DNF";
	else
		$best = $timetype==3 ? $scores[$bidx] : numTime($scores[$bidx]);
	// set AVERAGE
	switch($avgtype)
	{
	case 0: // average of 5
		if (!$cutpassed)
			$average = "";
		elseif ($dnfs>1)
			$average = "DNF";
		elseif ($dnfs==1)
			$average = numTime(($average-$b)/($times-2));
		else
			$average = numTime(($average-$b-$w)/($times-2));
		break;
	case 1: // mean of 3
		if (!$cutpassed)
			$average = "";
		elseif ($dnfs)
			$average = "DNF";
		else
			$average = numTime($average/$times);
		break;
	default: // best
		if ($timetype!=3)
			$average = "";
		//elseif ($dnfs==$times)
		elseif ($dnfs==$scoresread)
			$average = "DNF";
		else
			$average = sprintf("%015d",$b); // trick to show results ordered
	}
}