function create_game($roomid)
{
    global $db, $ir;
    $alreadymade = $db->num_rows($db->query("SELECT ttt_room FROM ttt_game WHERE ttt_room = {$roomid}"));
    if (!$alreadymade) {
        $turn = rand(1, 2);
        $turnuid = p_to_uid($turn, $roomid);
        if ($turn == 1) {
            $other = 2;
        } else {
            $other = 1;
        }
        $otheruid = p_to_uid($other, $roomid);
        $db->query("UPDATE ttt_room SET turn={$turnuid},play_time=0 WHERE id={$roomid}");
        $db->query("INSERT INTO ttt_game (ttt_room, x, p1, p2) VALUES ({$roomid}, {$turnuid}, {$turnuid}, {$otheruid})");
    }
}
function create_game($roomid)
{
    global $db, $ir, $firstmovemarkfield;
    $alreadymade = $db->num_rows($db->query("SELECT man_room FROM man_game WHERE man_room = {$roomid}"));
    if (!$alreadymade) {
        $roominfo = $db->fetch_row($db->query("SELECT * FROM man_room WHERE id={$roomid}"));
        $turn = rand(1, 2);
        $turnuid = p_to_uid($turn, $roomid);
        $db->query("UPDATE man_room SET turn={$turnuid},play_time=0 WHERE id={$roomid}");
        $db->query("INSERT INTO man_game (man_room, {$firstmovemarkfield}, p1, p2) VALUES ({$roomid}, {$turnuid}, {$roominfo['p1']}, {$roominfo['p2']})");
    }
}
function create_game($roomid)
{
    global $db, $ir, $firstmovemarkfield;
    $alreadymade = $db->num_rows($db->query("SELECT ms_room FROM ms_game WHERE ms_room = {$roomid}"));
    if (!$alreadymade) {
        $roominfo = $db->fetch_row($db->query("SELECT * FROM ms_room WHERE id={$roomid}"));
        $turn = rand(1, 2);
        $turnuid = p_to_uid($turn, $roomid);
        if ($turn == 1) {
            $other = 2;
        } else {
            $other = 1;
        }
        $otheruid = p_to_uid($other, $roomid);
        $db->query("UPDATE ms_room SET turn={$turnuid},play_time=0 WHERE id={$roomid}");
        $db->query("INSERT INTO ms_game (ms_room, {$firstmovemarkfield}, p1, p2, mselected) VALUES ({$roomid}, {$turnuid}, {$roominfo['p1']}, {$roominfo['p2']}, 1)");
    }
    create_mines($roomid);
}
function create_game($roomid)
{
    global $db, $ir, $firstmovemarkfield;
    $alreadymade = $db->num_rows($db->query("SELECT ck_room FROM ck_game WHERE ck_room = {$roomid}"));
    if (!$alreadymade) {
        $roominfo = $db->fetch_row($db->query("SELECT * FROM ck_room WHERE id={$roomid}"));
        $turn = rand(1, 2);
        $turnuid = p_to_uid($turn, $roomid);
        if ($turn == 1) {
            $other = 2;
        } else {
            $other = 1;
        }
        $otheruid = p_to_uid($other, $roomid);
        $db->query("UPDATE ck_room SET turn={$turnuid},play_time=0 WHERE id={$roomid}");
        $db->query("INSERT INTO ck_game (ck_room, {$firstmovemarkfield}, p1, p2) VALUES ({$roomid}, {$turnuid}, {$roominfo['p1']}, {$roominfo['p2']})");
        board_setup($roomid, $turnuid, $otheruid);
    }
}
function create_game($roomid)
{
    global $db, $ir, $firstmovemarkfield;
    $alreadymade = $db->num_rows($db->query("SELECT bs_room FROM bs_game WHERE bs_room = {$roomid}"));
    if (!$alreadymade) {
        $roominfo = $db->fetch_row($db->query("SELECT * FROM bs_room WHERE id={$roomid}"));
        $turn = rand(1, 2);
        $turnuid = p_to_uid($turn, $roomid);
        $db->query("UPDATE bs_room SET turn={$turnuid},play_time=0 WHERE id={$roomid}");
        $db->query("INSERT INTO bs_game (bs_room, {$firstmovemarkfield}, p1, p2) VALUES ({$roomid}, {$turnuid}, {$roominfo['p1']}, {$roominfo['p2']})");
        $blankboard = "c1-h|c2-h|c3-h|c4-h|c5-h|b1-h|b2-h|b3-h|b4-h|0|d1-h|d2-h|d3-h|s1-h|s2-h|s3-h|p1-h|p2-h|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0";
        $db->query("UPDATE bs_game SET p1b='{$blankboard}',p2b='{$blankboard}' WHERE bs_room={$roomid}");
    }
}