Exemple #1
0
    void timerCallback_fapai(object obj)
    {
        try
        {
            switch ((TimerType)obj)
            {
            case TimerType.TimerType_fapai:
            {
                m_timerUtil_FaPai.stopTimer();

                for (int i = 0; i < getPlayerDataList().Count; i++)
                {
                    int num       = getPlayerDataList()[i].getPokerList()[m_fapaiIndex].m_num;
                    int pokerType = (int)getPlayerDataList()[i].getPokerList()[m_fapaiIndex].m_pokerType;

                    if (!getPlayerDataList()[i].isOffLine())
                    {
                        JObject jo2 = new JObject();
                        jo2.Add("tag", m_tag);
                        jo2.Add("uid", getPlayerDataList()[i].m_uid);
                        jo2.Add("playAction", (int)TLJCommon.Consts.PlayAction.PlayAction_FaPai);
                        jo2.Add("num", num);
                        jo2.Add("pokerType", pokerType);

                        if (m_fapaiIndex == 24)
                        {
                            jo2.Add("isEnd", 1);
                        }
                        else
                        {
                            jo2.Add("isEnd", 0);
                        }

                        PlayService.m_serverUtil.sendMessage(getPlayerDataList()[i].m_connId, jo2.ToString());
                    }

                    getPlayerDataList()[i].m_allotPokerList.Add(new PokerInfo(num, (TLJCommon.Consts.PokerType)pokerType));
                }

                // 牌未发完
                if (m_fapaiIndex < 24)
                {
                    ++m_fapaiIndex;

                    startFaPaiTimer();
                }
                // 牌已发完
                else
                {
                    m_timerUtil.startTimer(m_qiangzhuTime, TimerType.TimerType_qiangzhu);
                }
            }
            break;
            }
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error("RoomData----" + "timerCallback_fapai异常: " + ex);
        }
    }
    void timerCallback_breakRom(object obj)
    {
        try
        {
            switch ((TimerType)obj)
            {
            case TimerType.TimerType_breakRoom:
            {
                LogUtil.getInstance().writeRoomLog(this, "房间时限已到,强制解散该房间");

                m_timerUtil.stopTimer();

                // 发送给客户端
                {
                    JObject respondJO = new JObject();
                    respondJO.Add("tag", m_tag);
                    respondJO.Add("playAction", (int)TLJCommon.Consts.DDZ_PlayAction.PlayAction_BreakRoom);

                    for (int i = 0; i < m_playerDataList.Count; i++)
                    {
                        if ((!m_playerDataList[i].m_isAI) && (!m_playerDataList[i].isOffLine()))
                        {
                            PlayService.m_serverUtil.sendMessage(m_playerDataList[i].m_connId, respondJO.ToString());
                        }
                    }
                }

                // 强制解散该房间
                {
                    // 所有玩家倒计时停止
                    for (int i = 0; i < m_playerDataList.Count; i++)
                    {
                        m_playerDataList[i].m_timerUtil.stopTimer();
                    }

                    DDZ_GameLogic.removeRoom(m_gameBase, this, true);
                }
            }
            break;
            }
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error("RoomData----" + "timerCallback_breakRom异常: " + ex);
        }
    }
    void timerCallback_fapai(object obj)
    {
        try
        {
            switch ((TimerType)obj)
            {
            case TimerType.TimerType_fapai:
            {
                m_timerUtil_FaPai.stopTimer();

                for (int i = 0; i < getPlayerDataList().Count; i++)
                {
                    int num       = getPlayerDataList()[i].getPokerList()[m_fapaiIndex].m_num;
                    int pokerType = (int)getPlayerDataList()[i].getPokerList()[m_fapaiIndex].m_pokerType;

                    //if (!getPlayerDataList()[i].isOffLine())
                    {
                        JObject jo2 = new JObject();
                        jo2.Add("tag", m_tag);
                        jo2.Add("uid", getPlayerDataList()[i].m_uid);
                        jo2.Add("playAction", (int)TLJCommon.Consts.DDZ_PlayAction.PlayAction_FaPai);
                        jo2.Add("num", num);
                        jo2.Add("pokerType", pokerType);

                        if (m_fapaiIndex == 16)
                        {
                            jo2.Add("isEnd", 1);
                        }
                        else
                        {
                            jo2.Add("isEnd", 0);
                        }

                        PlayService.m_serverUtil.sendMessage(getPlayerDataList()[i].m_connId, jo2.ToString());
                    }

                    getPlayerDataList()[i].m_allotPokerList.Add(new PokerInfo(num, (TLJCommon.Consts.PokerType)pokerType));

                    LogUtil.getInstance().writeRoomLog(this, "发牌给:" + getPlayerDataList()[i].m_uid + "----num = " + num + "  pokerType = " + pokerType);
                }

                // 牌未发完
                if (m_fapaiIndex < 16)
                {
                    ++m_fapaiIndex;

                    startFaPaiTimer();
                }
                // 牌已发完
                else
                {
                    for (int i = 0; i < getDiPokerList().Count; i++)
                    {
                        LogUtil.getInstance().writeRoomLog(this, "底牌:----num = " + getDiPokerList()[i].m_num + "  pokerType = " + (int)getDiPokerList()[i].m_pokerType);
                    }

                    // 随机一个玩家开始抢地主
                    {
                        m_roomState = DDZ_RoomState.RoomState_qiangdizhu;

                        DDZ_PlayerData playerData = null;
                        int            r          = RandomUtil.getRandom(0, getPlayerDataList().Count - 1);
                        //r = 0;
                        playerData = getPlayerDataList()[r];

                        m_firstQiangDiZhuPlayer = playerData;
                        m_curQiangDiZhuPlayer   = playerData;

                        // 开始倒计时
                        playerData.m_timerUtil.startTimer(m_qiangDiZhuTime, TimerType.TimerType_qiangDizhu);

                        JObject jo2 = new JObject();
                        jo2.Add("tag", m_tag);
                        jo2.Add("curMaxFen", 0);
                        jo2.Add("curJiaoDiZhuUid", m_curQiangDiZhuPlayer.m_uid);
                        jo2.Add("playAction", (int)TLJCommon.Consts.DDZ_PlayAction.PlayAction_CallPlayerQiangDiZhu);

                        for (int i = 0; i < getPlayerDataList().Count; i++)
                        {
                            PlayService.m_serverUtil.sendMessage(getPlayerDataList()[i].m_connId, jo2.ToString());
                        }

                        // 如果离线了则托管出牌
                        if (playerData.isTuoGuan())
                        {
                            // 开始倒计时
                            playerData.m_timerUtilOffLine.startTimer(m_tuoguanOutPokerDur, TimerType.TimerType_qiangDizhu);
                        }
                    }
                }
            }
            break;
            }
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error("DDZ_RoomData----" + "timerCallback_fapai异常: " + ex);
        }
    }