コード例 #1
0
        // client call
        public void mj_huanghuang_occupat_site(Int64 room_id, Int64 site)
        {
            log.log.trace(new System.Diagnostics.StackFrame(), service.timerservice.Tick, "begin mj_huanghuang_occupat_site");

            mj_huanghuang_table _table = server.tables.get_mj_huanghuang_table(room_id);

            if (_table != null)
            {
                log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "occupat_site");

                if (!_table.site.ContainsKey(site) && site < (int)GameCommon.mjSite.End)
                {
                    string client_uuid = hub.hub.gates.current_client_uuid;

                    var _proxy = _table.get_player_proxy(client_uuid);
                    _table.site.Add(site, _proxy);
                    _table.matcher.Remove(_proxy);

                    _proxy.player_info["site"] = site;
                    _proxy.state = GameCommon.mjPlayerstate.read;
                    _table.broadcast("room", "on_mj_huanghuang_occupat_site", _proxy.player_info["unionid"], site);

                    hub.hub.hubs.call_hub("lobby", "lobby", "occupat_site", _table.owner, room_id);
                }
                else
                {
                    string client_uuid = hub.hub.gates.current_client_uuid;
                    hub.hub.gates.call_client(client_uuid, "room", "occupat_site", false);
                    return;
                }


                if (_table.site.Count == _table.peopleNum)
                {
                    //坐满了则将没坐下的踢出去
                    if (_table != null)
                    {
                        ArrayList _proxys = new ArrayList();
                        ArrayList _uuids  = new ArrayList();

                        foreach (var item in _table.players_uuid)
                        {
                            _proxys.Add(item.Value);
                            _uuids.Add(item.Key);
                        }
                        for (int i = _table.players_uuid.Count - 1; i >= 0; i--)
                        {
                            if (!_table.site.ContainsValue((playerproxy)_proxys[i]))
                            {
                                _table.exit_table((string)_uuids[i]);
                            }
                        }
                    }

                    hub.hub.hubs.call_hub("lobby", "lobby", "begin_game", _table.owner, room_id);

                    //开始游戏
                    log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "1:start game !");
                    _table.frist_begin_game();
                    _table.begin_game();
                    _table.deal();
                }
            }

            log.log.trace(new System.Diagnostics.StackFrame(), service.timerservice.Tick, "end mj_huanghuang_occupat_site");
        }