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.

60 lines
1.4 KiB
PHP

<?php
require_once 'repository/teamRepository.php';
// MMR will work better with better matchmaking
// worse MM, will then require additional checks, etc
// The more convoluted the worse prolly.
// matchmake by rating, and kfactor (primarily rating)
// Teams made of 5 members
// Each team member has an MMR, and Kfactor
// kfactor = 100 for first 5 games? then drops 10 for next 5, then drops 1 for next 10. stable at 40 from 20-50
// Get tha teams
$dbTeams = getMatchTeams($conn, 1);
$teams = [];
foreach($dbTeams as $dbTeam){
$team = [
'name' => $dbTeam['name'],
'players' => [],
'playerRating' => 0,
'expected' => NULL,
'score' => NULL,
];
$teamPlayers = 0;
$players = getTeamPlayers($conn, $dbTeam['id']);
foreach($players as $player){
$team['players'][] = [
'ign' => $player['ign'],
'rating' => $player['rating'],
'kfactor' => 40,
];
$team['playerRating'] += $player['rating'];
$teamPlayers++;
}
$team['playerRating'] = $team['playerRating']/$teamPlayers;
$teams[] = $team;
}
//die("Db stuff only");
// Expected result of the match
// 1/(1+10^((OpponentRating - Your rating)/400))
// this is for bo1
// TODO:
$teams[0]['expected'] = 1 / ( 1 + ( pow( 10 , ( $teams[1]['playerRating'] - $teams[0]['playerRating'] ) / 400 ) ) );
$teams[1]['expected'] = 1 / ( 1 + ( pow( 10 , ( $teams[0]['playerRating'] - $teams[1]['playerRating'] ) / 400 ) ) );
$teams[0]['score'] = 1;
$teams[1]['score'] = 0;
$t = 1;
$i = 1;
?>