static void robotPlay(mj_huanghuang_table _table, Int64 site)
        {
            if (site != _table.card_righter)
            {
                return;
            }

            Random ra         = new Random();
            int    r          = ra.Next();
            int    card_index = r % _table.player_cards[_table.card_righter].Count;
            Int64  c          = (Int64)_table.player_cards[_table.card_righter][card_index];

            _table.player_cards[_table.card_righter].RemoveAt(card_index);
            _table.player_play_cards[_table.card_righter].Add(c);

            _table.broadcast("mj_huanghuang", "play_card", c);

            if (c == _table.laizi)//出的牌是癞子,则底分乘以2
            {
                _table.site[_table.card_righter].player_info["base"] = (Int64)_table.site[_table.card_righter].player_info["base"] * 2;
                log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "CheckAndProcessRobotRight laizi");
                _table.draw();
            }
            else
            {
                _table.processer_card = c;
                _table.play_carder    = _table.card_righter;

                _table.processer = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.card_righter);
                while (_table.processer != _table.card_righter)
                {
                    if (mj_huanghuang_check.check_peng(_table.player_cards[_table.processer], _table.laizipi, c))
                    {
                        log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "peng");

                        _table.next_card_righter = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.card_righter);
                        _table.card_righter      = (Int64)_table.GetEndSite();

                        _table._hh_state = hh_state.peng;

                        if (_table.site[_table.processer].is_robot)
                        {
                            onRobot(_table, _table.processer);
                        }
                        return;
                    }

                    if (mj_huanghuang_check.check_gang(_table.player_cards[_table.processer], _table.player_peng[_table.processer], _table.laizipi, c, false, true))
                    {
                        log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "gang");

                        _table.next_card_righter = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.card_righter);
                        _table.card_righter      = (Int64)_table.GetEndSite();

                        _table._hh_state = hh_state.gang;

                        if (_table.site[_table.processer].is_robot)
                        {
                            onRobot(_table, _table.processer);
                        }
                        return;
                    }

                    if (mj_huanghuang_check.check_dian_hu(_table.player_cards[_table.processer], _table.laizi, c) != HupaiState.no_hu)
                    {
                        log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "hu");

                        _table.next_card_righter = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.card_righter);
                        _table.card_righter      = (Int64)_table.GetEndSite();

                        _table._hh_state = hh_state.dian_hu;

                        if (_table.site[_table.processer].is_robot)
                        {
                            onRobot(_table, _table.processer);
                        }
                        return;
                    }

                    _table.processer = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.processer);
                }

                if (_table.processer == _table.card_righter)
                {
                    _table.card_righter = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.card_righter);

                    log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "CheckAndProcessRobotRight next card_righter");
                    _table.draw();
                }
            }
        }
Exemple #2
0
        public void play(Int64 room_id, Int64 card)
        {
            log.log.trace(new System.Diagnostics.StackFrame(), service.timerservice.Tick, "begin play");

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

            if (_table == null)
            {
                return;
            }

            var client_uuid = hub.hub.gates.current_client_uuid;
            var _proxy      = _table.get_player_proxy(client_uuid);

            if (_proxy == null)
            {
                log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "player proxy is null");
                return;
            }

            if ((Int64)_proxy.player_info["site"] != _table.card_righter)
            {
                log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "player not card righter");
                return;
            }

            log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "check player site");

            if (!_table.player_cards[_table.card_righter].Contains(card))
            {
                log.log.error(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "no exist cards:{0}", card);
                return;
            }

            _table.play_card_player = (Int64)_proxy.player_info["site"];

            _table.mopai_state = false;
            _table.play_state  = true;

            _table.player_play_cards[_table.card_righter].Add(card);

            log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "play card_righter cards count:{0}", _table.player_cards[_table.card_righter].Count);

            if (card == _table.laizi)
            {
                log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "laizi draw card");

                _table.player_cards[_table.card_righter].Remove(card);

                _table.broadcast("mj_huanghuang", "play_card", card);

                _proxy.player_info["base"] = (Int64)_proxy.player_info["base"] * 2;
                _table.draw();
            }
            else
            {
                _table.player_cards[_table.card_righter].Remove(card);

                _table.broadcast("mj_huanghuang", "play_card", card);

                _table.processer_card = card;
                _table.play_carder    = _table.card_righter;

                _table.processer = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.card_righter);
                while (_table.processer != _table.card_righter)
                {
                    if (mj_huanghuang_check.check_peng(_table.player_cards[_table.processer], _table.laizipi, card))
                    {
                        log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "peng");

                        _table.next_card_righter = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.card_righter);
                        _table.card_righter      = (Int64)_table.GetEndSite();

                        _table._hh_state = hh_state.peng;

                        if (_table.site[_table.processer].is_robot)
                        {
                            robotUtil.onRobot(_table, _table.processer);
                        }
                        return;
                    }

                    if (mj_huanghuang_check.check_gang(_table.player_cards[_table.processer], _table.player_peng[_table.processer], _table.laizipi, card, false, true))
                    {
                        log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "gang");

                        _table.next_card_righter = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.card_righter);
                        _table.card_righter      = (Int64)_table.GetEndSite();

                        _table._hh_state = hh_state.gang;

                        if (_table.site[_table.processer].is_robot)
                        {
                            robotUtil.onRobot(_table, _table.processer);
                        }
                        return;
                    }

                    if (mj_huanghuang_check.check_dian_hu(_table.player_cards[_table.processer], _table.laizi, card) != HupaiState.no_hu)
                    {
                        log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "hu");

                        _table.next_card_righter = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.card_righter);
                        _table.card_righter      = (Int64)_table.GetEndSite();

                        _table._hh_state = hh_state.dian_hu;

                        if (_table.site[_table.processer].is_robot)
                        {
                            robotUtil.onRobot(_table, _table.processer);
                        }
                        return;
                    }

                    _table.processer = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.processer);
                }


                if (_table.processer == _table.card_righter)
                {
                    _table.card_righter = (Int64)_table.GetNextSite((GameCommon.mjSite)_table.card_righter);

                    log.log.trace(new System.Diagnostics.StackFrame(true), service.timerservice.Tick, "draw card to next card_righter");
                    _table.draw();
                }
            }

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