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);
        }
    }
Example #2
0
    // 游戏结束
    public override void gameOver(DDZ_RoomData room)
    {
        try
        {
            room.setRoomState(DDZ_RoomState.RoomState_end);

            LogUtil.getInstance().writeRoomLog(room, m_logFlag + "----" + ":比赛结束,roomid = :" + room.getRoomId());

            // 游戏在线统计
            for (int i = 0; i < room.getPlayerDataList().Count; i++)
            {
                Request_OnlineStatistics.doRequest(room.getPlayerDataList()[i].m_uid, room.getRoomId(), room.m_gameRoomType, room.getPlayerDataList()[i].m_isAI, (int)Request_OnlineStatistics.OnlineStatisticsType.OnlineStatisticsType_exit);
            }

            // 是否春天
            {
                if (room.m_winPlayerData.m_isDiZhu == 1)
                {
                    bool isChunTian = true;
                    for (int i = 0; i < room.getPlayerDataList().Count; i++)
                    {
                        if (room.getPlayerDataList()[i].m_isDiZhu == 0)
                        {
                            if (room.getPlayerDataList()[i].m_outPokerCiShu > 0)
                            {
                                isChunTian = false;
                                break;
                            }
                        }
                    }

                    if (isChunTian)
                    {
                        room.m_beishu_chuntian = 2;
                    }
                }
                else
                {
                    bool isChunTian = true;
                    for (int i = 0; i < room.getPlayerDataList().Count; i++)
                    {
                        if (room.getPlayerDataList()[i].m_isDiZhu == 1)
                        {
                            if (room.getPlayerDataList()[i].m_outPokerCiShu > 1)
                            {
                                isChunTian = false;
                                break;
                            }
                        }
                    }

                    if (isChunTian)
                    {
                        room.m_beishu_chuntian = 2;
                    }
                }
            }

            // 计算每个玩家的金币(积分)
            DDZ_GameUtil.setPlayerScore(room, false);

            // 加减金币
            {
                for (int i = 0; i < room.getPlayerDataList().Count; i++)
                {
                    // 加、减玩家金币值
                    Request_ChangeUserWealth.doRequest(room.getPlayerDataList()[i].m_uid, 1, room.getPlayerDataList()[i].m_score, "斗地主结算");
                }
            }

            //// 逻辑处理
            //{
            //    List<string> winnerList = new List<string>();

            //    // 游戏数据统计
            //    Request_GameStatistics.doRequest(room, winnerList);
            //}

            {
                JObject respondJO = new JObject();
                {
                    respondJO.Add("tag", room.m_tag);
                    respondJO.Add("playAction", (int)TLJCommon.Consts.DDZ_PlayAction.PlayAction_GameOver);
                    respondJO.Add("isDiZhuWin", room.m_winPlayerData.m_isDiZhu);

                    for (int i = 0; i < room.getPlayerDataList().Count; i++)
                    {
                        JObject jo = new JObject();
                        jo.Add("score", room.getPlayerDataList()[i].m_score);

                        float beishu = room.m_maxJiaoFenPlayerData.m_jiaofen * room.m_beishu_chuntian * room.m_beishu_bomb;
                        jo.Add("beishu", (int)beishu * (room.getPlayerDataList()[i].m_isJiaBang + 1));

                        respondJO.Add(room.getPlayerDataList()[i].m_uid, jo);
                    }

                    // 倍数
                    for (int i = 0; i < room.getPlayerDataList().Count; i++)
                    {
                        DDZ_PlayerData playerData = room.getPlayerDataList()[i];

                        JArray ja = new JArray();

                        {
                            ja.Add("初始倍数X" + room.m_maxJiaoFenPlayerData.m_jiaofen);

                            if (playerData.m_isJiaBang == 1)
                            {
                                ja.Add("加棒X2");
                            }

                            if (room.m_beishu_bomb > 1)
                            {
                                ja.Add("炸弹X" + room.m_beishu_bomb);
                            }

                            if (room.m_beishu_chuntian > 1)
                            {
                                ja.Add("春天X" + room.m_beishu_chuntian);
                            }
                        }

                        respondJO.Add("beishu_" + playerData.m_uid, ja);
                    }
                }

                for (int i = 0; i < room.getPlayerDataList().Count; i++)
                {
                    // 推送给客户端
                    if (!room.getPlayerDataList()[i].isOffLine())
                    {
                        PlayService.m_serverUtil.sendMessage(room.getPlayerDataList()[i].m_connId, respondJO.ToString());
                    }
                }
            }

            DDZ_GameLogic.removeRoom(this, room, true);
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error(m_logFlag + "gameOver异常: " + ex);
        }
    }
Example #3
0
    public override bool doTaskPlayerCloseConn(string uid)
    {
        try
        {
            DDZ_RoomData room = getRoomByUid(uid);
            if (room == null)
            {
                return(false);
            }

            DDZ_PlayerData playerData = DDZ_GameUtil.getPlayerDataByUid(uid);
            if (playerData == null)
            {
                return(false);
            }

            //// 记录逃跑数据
            //if ((m_roomList[i].m_roomState != RoomState.RoomState_waiting) &&
            //    (m_roomList[i].m_roomState != RoomState.RoomState_end))
            //{
            //    Request_RecordUserGameData.doRequest(room.getPlayerDataList()[i].m_uid, room.m_gameRoomType, (int)TLJCommon.Consts.GameAction.GameAction_Run);
            //}

            switch (room.getRoomState())
            {
            case DDZ_RoomState.RoomState_waiting:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在本桌满人之前退出:" + playerData.m_uid);

                    room.getPlayerDataList().Remove(playerData);

                    if (DDZ_GameUtil.checkRoomNonePlayer(room))
                    {
                        LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此房间人数为0,解散房间:" + room.getRoomId());

                        DDZ_GameLogic.removeRoom(this, room, true);
                    }
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;

            case DDZ_RoomState.RoomState_fapai:
            case DDZ_RoomState.RoomState_qiangdizhu:
            case DDZ_RoomState.RoomState_jiabang:
            case DDZ_RoomState.RoomState_gaming:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在游戏中退出:" + playerData.m_uid);
                    playerData.setIsOffLine(true);
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;

            case DDZ_RoomState.RoomState_end:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在本桌打完后退出:" + playerData.m_uid);

                    room.getPlayerDataList().Remove(playerData);
                    if (room.getPlayerDataList().Count == 0)
                    {
                        LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此房间人数为0,解散房间:" + room.getRoomId());

                        DDZ_GameLogic.removeRoom(this, room, true);
                    }
                    else
                    {
                        // 如果房间人数为空,则删除此房间
                        {
                            if (DDZ_GameUtil.checkRoomNonePlayer(room))
                            {
                                LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此房间人数为0,解散房间:" + room.getRoomId());

                                DDZ_GameLogic.removeRoom(this, room, true);
                            }
                        }
                    }
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;

            default:
            {
                if (!playerData.isOffLine())
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":玩家在未知阶段退出:" + playerData.m_uid);

                    room.getPlayerDataList().Remove(playerData);

                    if (DDZ_GameUtil.checkRoomNonePlayer(room))
                    {
                        LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此房间人数为0,解散房间:" + room.getRoomId());

                        DDZ_GameLogic.removeRoom(this, room, true);
                    }
                }
                else
                {
                    LogUtil.getInstance().addDebugLog(m_logFlag + "----" + ":此玩家连续退出/掉线:" + playerData.m_uid);
                }
            }
            break;
            }

            return(true);
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":doTaskPlayerCloseConn异常:" + ex);
        }

        return(false);
    }