Ejemplo n.º 1
0
            unlink(GAME_ROOT . './gamedata/tmp/rooms/' . $data['roomid'] . '.txt');
            $data['status'] = 0;
        } else {
            $roomlist[$data['roomid']]['id'] = $data['roomid'];
            $roomlist[$data['roomid']]['status'] = $data['status'];
            $roomlist[$data['roomid']]['nowplayer'] = $cnt;
            $roomlist[$data['roomid']]['maxplayer'] = $roomtypelist[$roomdata['roomtype']]['pnum'];
            $roomlist[$data['roomid']]['roomtype'] = $roomdata['roomtype'];
            $roomlist[$data['roomid']]['roomdata'] = $roomdata;
        }
    } else {
        if ($data['status'] == 2) {
            if (file_exists(GAME_ROOT . './gamedata/tmp/rooms/' . $data['roomid'] . '.txt')) {
                $roomdata = json_decode(mgzdecode(base64_decode(file_get_contents(GAME_ROOT . './gamedata/tmp/rooms/' . $data['roomid'] . '.txt'))), 1);
                if (update_roomstate($roomdata, 1)) {
                    room_save_broadcast($data['roomid'], $roomdata);
                }
                $roomlist[$data['roomid']]['id'] = $data['roomid'];
                $roomlist[$data['roomid']]['status'] = $data['status'];
                $roomlist[$data['roomid']]['roomtype'] = $roomdata['roomtype'];
                $roomlist[$data['roomid']]['roomdata'] = $roomdata;
            } else {
                $db->query("UPDATE {$gtablepre}rooms SET status = 0 WHERE roomid='{$data['roomid']}'");
                $data['status'] = 0;
            }
        }
    }
}
//var_dump($roomlist);
//die();
//排序方式:等待中优于游戏中,人越接近满越优先,人已满放最后,依然相同按ID
Ejemplo n.º 2
0
            for ($i = 0; $i < $roomtypelist[$roomdata['roomtype']]['pnum']; $i++) {
                if (!$roomdata['player'][$i]['forbidden']) {
                    $pname = $roomdata['player'][$i]['name'];
                    $pname = (string) $pname;
                    $result = $db->query("SELECT * FROM {$gtablepre}users WHERE username = '******'");
                    if ($db->num_rows($result) != 1) {
                        continue;
                    }
                    $pdata = $db->fetch_array($result);
                    enter_battlefield($pdata['username'], $pdata['password'], $pdata['gender'], $pdata['icon'], $pdata['card']);
                    $db->query("UPDATE {$tablepre}players SET teamID='{$roomtypelist[$roomdata['roomtype']]['teamID'][$roomtypelist[$roomdata['roomtype']]['leader-position'][$i]]}' WHERE name='{$pname}'");
                }
            }
            //进入连斗
            $gamestate = 40;
            addnews($now, 'combo');
            systemputchat($now, 'combo');
            save_gameinfo();
            //再次广播信息,这次让所有玩家跳转到游戏中
            $roomdata['roomstat'] = 0;
            $db->query("UPDATE {$gtablepre}rooms SET status=2 WHERE roomid='{$roomid}'");
            $roomdata['timestamp']++;
            $roomdata['chatdata'] = room_init($roomdata['roomtype'])['chatdata'];
            room_save_broadcast($roomid, $roomdata);
        }
    }
    die;
}
?>

Ejemplo n.º 3
0
function room_enter($id)
{
    eval(import_module('sys'));
    $id = (int) $id;
    $result = $db->query("SELECT status FROM {$gtablepre}rooms WHERE roomid = '{$id}'");
    if (!$db->num_rows($result)) {
        gexit('房间编号不存在', __FILE__, __LINE__);
        die;
    }
    $zz = $db->fetch_array($result);
    if ($zz['status'] == 0) {
        gexit('房间编号不存在', __FILE__, __LINE__);
        die;
    }
    if (!file_exists(GAME_ROOT . './gamedata/tmp/rooms/' . $id . '.txt')) {
        gexit('房间编号不存在', __FILE__, __LINE__);
        die;
    }
    $roomdata = json_decode(mgzdecode(base64_decode(file_get_contents(GAME_ROOT . './gamedata/tmp/rooms/' . $id . '.txt'))), 1);
    global $cuser;
    room_new_chat($roomdata, "<span class=\"grey\">{$cuser}进入了房间</span><br>");
    $db->query("UPDATE {$gtablepre}users SET roomid = 's{$id}' WHERE username = '******'");
    room_save_broadcast($id, $roomdata);
    header('Location: index.php');
    die;
}