don't know if anyone cares....but i wrote this real fast...its not pretty but it'll give an accurate feel for the draft lottery...
or at least how i understand it works...i could be wrong.
(using the standings as of this afternoon)
http://gigaphoid.dyndns.org/profet/draft
(refresh to replay the lottery)
here is the source:
or at least how i understand it works...i could be wrong.
(using the standings as of this afternoon)
http://gigaphoid.dyndns.org/profet/draft
(refresh to replay the lottery)
here is the source:
PHP:
<?php
$TOTAL_PICKS = 1000;
$teams=array(
array(city => 'Pittsburgh', name => 'Penguins'),
array(city => 'Washington', name => 'Capitals'),
array(city => 'Chicago', name => 'Blackhawks'),
array(city => 'Columbus', name => 'Bluejackets'),
array(city => 'Phoenix', name => 'Coyotes'),
array(city => 'New York', name => 'Rangers'),
array(city => 'Anaheim', name => 'Mighty Ducks'),
array(city => 'Florida', name => 'Panthers'),
array(city => 'Carolina', name => 'Hurricanes'),
array(city => 'Atlanta', name => 'Thrashers'),
array(city => 'Minnesota', name => 'Wild'),
array(city => 'Los Angeles', name => 'Kings'),
array(city => 'Buffalo', name => 'Sabres'),
array(city => 'Nashville', name => 'Predators'),
);
$numberOfPicks=array( $TOTAL_PICKS * .25,
$TOTAL_PICKS * .188,
$TOTAL_PICKS * .142,
$TOTAL_PICKS * .107,
$TOTAL_PICKS * .081,
$TOTAL_PICKS * .062,
$TOTAL_PICKS * .047,
$TOTAL_PICKS * .036,
$TOTAL_PICKS * .027,
$TOTAL_PICKS * .021,
$TOTAL_PICKS * .015,
$TOTAL_PICKS * .011,
$TOTAL_PICKS * .008,
$TOTAL_PICKS * .005);
for($x=0; $x<14; $x++)
{
for($y=0; $y<$numberOfPicks[$x]; $y++)
{
$picks[] = $x;
}
}
shuffle($picks);
$pick = rand(0, $TOTAL_PICKS-1);
$winnersPosition = $picks[$pick];
$winnersNewPosition = $winnersPosition - 4;
if($winnersNewPosition < 0)
$winnersNewPosition = 0;
moveElementInArray($teams, $winnersPosition, $winnersNewPosition);
printHTML($teams);
function moveElementInArray(&$array, $oldPosition, $newPosition)
{
$removed = array_splice($array, $oldPosition, count($array), array_slice($array, $oldPosition+1));
$item = $removed[0];
$rear = array_splice($array, $newPosition);
$array[] = $item;
$array = array_merge($array, $rear);
}
function printHTML(&$teams)
{
?>
<html>
<body>
<table>
<tr>
<td>Position</td>
<td>City</td>
<td>Team</td>
</tr>
<?php
for($x=0; $x < count($teams); $x++)
{
$position = $x + 1;
echo "<tr>\n\t";
echo "<td>$position</td>";
echo '<td>' . $teams[$x][city] . '</td>';
echo '<td>' . $teams[$x][name] . '</td>';
echo "</tr>\n";
}
?>
</table>
</body>
</html>
<?php
}
?>
Last edited: