You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.7 KiB
PHP

<?php
require_once('elo.php');
foreach($teams as $index => $team){
?>
<div style="display: inline-block; vertical-align: middle; margin: 12px; width: 100%;">
<table style="background: lightgrey;">
<thead>
<th>Name</th>
<th>rating</th>
<th>expected</th>
<th>result</th>
</thead>
<tbody>
<td><?php echo($team['name']) ?></td>
<td><?php echo($team['playerRating']) ?></td>
<td><?php echo($team['expected']) ?></td>
<td><?php echo($team['score']) ?></td>
</tbody>
</table>
<table style="background: whitesmoke; width: 100%;">
<caption><?php echo($team['name']) ?></caption>
<thead>
<tr>
<th>Name</th>
<th>kfactor</th>
<th>pre</th>
<th>post</th>
</tr>
</thead>
<tbody>
<tr>
<td>Average</td>
</tr>
<?php
foreach($team['players'] as $player){
$kfactorChange = 1;
// This will calc %diff between player and team rating
$kfactorChange = $player['kfactor']*(($player['rating'] - $team['playerRating'])/$team['playerRating']);
// check if + or - and do stuff
// If win
if ($team['score']){
$playerKfactor = $player['kfactor'] - $kfactorChange;
}
else{
$playerKfactor = $player['kfactor'] + $kfactorChange;
}
// Calculate rating
$player['rating'] = round($player['rating'] + ( $playerKfactor * ( $team['score'] - $team['expected'] ) ));
?>
<tr>
<td><?php echo($player['ign']) ?></td>
<td><?php echo($player['kfactor']) ?></td>
<td><?php echo($player['rating']) ?></td>
<td><?php echo($player['rating']) ?></td>
</tr>
<?php
$i++;
// endforeach players
}
?>
</tbody>
</table>
</div>
<?php
if ($index !== array_key_last($teams)){
?>
<div style="display: inline-block; vertical-align: middle; margin: 24px; ">versus</div>
<?php
}
$t++;
// endforeach teams
}
?>