function startGame($gameId, $gameName, $players)
{
    $playerNumber = count($players);
    if ($playerNumber < 3) {
        return;
    }
    $date = getDateNow();
    $dateLimit = getDateLimit();
    // Start the game
    $sql = "UPDATE games SET state='ACTIVE' WHERE gameId='{$gameId}' LIMIT 1;";
    mysql_query($sql) or sql_error_report($sql, $_SERVER["SCRIPT_NAME"]);
    // Randomize the players
    shuffle($players);
    $assassinationList = '';
    for ($i = 0; $i < $playerNumber; $i++) {
        $playerId = $players[$i];
        $victimId = $players[($i + 1) % $playerNumber];
        trace("Starting: {$playerId} -> {$victimId}");
        if ($assassinationList != '') {
            $assassinationList .= ', ';
        }
        $assassinationList .= "('{$gameId}', '{$playerId}', '{$victimId}', 'PENDING', '{$date}', '{$dateLimit}')";
    }
    $sql = "INSERT INTO assassinations (gameId, assassinId, victimId, state, startDate, endDate) VALUES {$assassinationList};";
    mysql_query($sql) or sql_error_report($sql, $_SERVER["SCRIPT_NAME"]);
    require_once 'handler.php';
    handleGameStart($gameId);
}
Beispiel #2
0
<?php

include "handler.php";
//include "facebook.php";
//print_r(handleAddDetails(20));
handleGameStart(15);
//$facebook_api_key = '920537198948cb508dd7f38ca4b1a53b';
//$facebook_api_secret = '1df24d2f3941380932ead0268ac31278';
//$auth_token = 'F2877R';
//$facebook = new Facebook($facebook_api_key, $facebook_api_secret);
//$infinite_key_array = $facebook->api_client->auth_getSession($auth_token);
//print_r($infinite_key_array);