function match($mysqli, $userId) { // Wahrscheinlichkeit 1 zu 1 das bestMatch aufgerufen wird switch (rand(0, 1)) { case 0: $bestMatch = bestMatch($mysqli, $userId); if ($bestMatch != false) { return $bestMatch; } else { return randomArticle($mysqli, $userId); } break; case 1: return randomArticle($mysqli, $userId); break; } }
$action = $_REQUEST['action']; switch ($action) { case 'players': echo json_encode(players()); break; case 'update': echo json_encode(updateStats(time(), $_REQUEST['team1'], $_REQUEST['team2'], $_REQUEST['scores'])); break; case 'reset': resetStats(); break; case 'ranking': echo json_encode(ranking()); break; case 'history': echo json_encode(history()); break; case 'log': echo json_encode(gameLog()); break; case 'match': if (isset($_REQUEST['team2'])) { echo json_encode(match($_REQUEST['team1'], $_REQUEST['team2'])); } else { echo json_encode(bestMatch($_REQUEST['team1'])); } break; case 'profile': echo json_encode(profile($_REQUEST['id'])); break; }