public static void ProcessDestroyBangHui(DBManager dbMgr)
        {
            DateTime  dateTime  = DateTime.Now;
            int       dayID     = dateTime.DayOfYear;
            DayOfWeek dayOfWeek = dateTime.DayOfWeek;
            int       nowTimer  = dateTime.Hour * 60 + dateTime.Minute;

            if (dayID != BangHuiDestroyMgr.LastCheckDestroyDayID)
            {
                BangHuiDestroyMgr.LastCheckDestroyDayID = dayID;
                BangHuiDestroyMgr.LastCheckDestroyTimer = nowTimer;
            }
            else if (nowTimer >= BangHuiDestroyMgr.DestroyTimer && BangHuiDestroyMgr.LastCheckDestroyTimer < BangHuiDestroyMgr.DestroyTimer && dayOfWeek == DayOfWeek.Sunday)
            {
                BangHuiDestroyMgr.LastCheckDestroyDayID = dayID;
                BangHuiDestroyMgr.LastCheckDestroyTimer = nowTimer;
                BangHuiDestroyMgr.HandleDestroyBangHuis(dbMgr);
            }
        }
        /// <summary>
        /// 处理解散帮会
        /// </summary>
        /// <param name="dbMgr"></param>
        private static void HandleDestroyBangHuis(DBManager dbMgr)
        {
            // 临时注释掉战盟解散代码 [5/11/2014 LiaoWei]
            int moneyPerLevel = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-per-qilevel", 10000);

            //执行扣除战盟维护资金
            DBWriter.SubBangHuiTongQianByQiLevel(dbMgr, moneyPerLevel);

            //获取帮会列表数据
            List <int> noMoneyBangHuiList = DBQuery.GetNoMoneyBangHuiList(dbMgr);

            for (int i = 0; i < noMoneyBangHuiList.Count; i++)
            {
                int bhid = noMoneyBangHuiList[i];

                //执行删除帮会的操作
                BangHuiDestroyMgr.DoDestroyBangHui(dbMgr, bhid);

                //添加GM命令消息
                string gmCmdData = string.Format("-autodestroybh {0}", bhid);
                ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
            }
        }
        private static void HandleDestroyBangHuis(DBManager dbMgr)
        {
            int moneyPerLevel = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-per-qilevel", 10000);

            if (moneyPerLevel > 0)
            {
                DBWriter.SubBangHuiTongQianByQiLevel(dbMgr, moneyPerLevel);
                int        maxLevel           = GameDBManager.GameConfigMgr.GetGameConfigItemInt("juntuanbanghuimax", 8);
                string     goldjoin           = GameDBManager.GameConfigMgr.GetGameConfigItemStr("bhmatch_goldjoin", "");
                List <int> goldjoinList       = ConfigHelper.String2IntList(goldjoin, '|');
                List <int> noMoneyBangHuiList = DBQuery.GetNoMoneyBangHuiList(dbMgr, maxLevel);
                for (int i = 0; i < noMoneyBangHuiList.Count; i++)
                {
                    int bhid = noMoneyBangHuiList[i];
                    if (!goldjoinList.Exists((int x) => x == bhid))
                    {
                        BangHuiDestroyMgr.DoDestroyBangHui(dbMgr, bhid);
                        string gmCmdData = string.Format("-autodestroybh {0}", bhid);
                        ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
                    }
                }
            }
        }
Example #4
0
        public void HandleDeleteRole(DBUserInfo dbUserInfo, DBRoleInfo dbRoleInfo)
        {
            DBManager dbMgr  = DBManager.getInstance();
            string    userID = dbUserInfo.UserID;
            int       roleID = dbRoleInfo.RoleID;

            lock (dbUserInfo)
            {
                if (dbRoleInfo.Faction > 0 && dbRoleInfo.BHZhiWu == 1)
                {
                    int  nRoleID = -1;
                    bool bGoOn   = false;
                    List <BangHuiMemberData>  bangHuiMemberDataList  = DBQuery.GetBangHuiMemberDataList(dbMgr, dbRoleInfo.Faction);
                    List <BangHuiMgrItemData> bangHuiMgrItemDataList = DBQuery.GetBangHuiMgrItemItemDataList(dbMgr, dbRoleInfo.Faction);
                    if (bangHuiMemberDataList != null && bangHuiMemberDataList.Count > 0)
                    {
                        if (bangHuiMgrItemDataList != null)
                        {
                            nRoleID = Global.GetDBRoleInfoByZhiWu(bangHuiMgrItemDataList, 2);
                            if (nRoleID <= 0)
                            {
                                nRoleID = Global.GetDBRoleInfoByZhiWu(bangHuiMgrItemDataList, 3);
                                if (nRoleID <= 0)
                                {
                                    nRoleID = Global.GetDBRoleInfoByZhiWu(bangHuiMgrItemDataList, 4);
                                    if (nRoleID <= 0)
                                    {
                                        bGoOn = true;
                                    }
                                }
                            }
                        }
                        if (bGoOn)
                        {
                            for (int i = 0; i < bangHuiMemberDataList.Count; i++)
                            {
                                if (bangHuiMemberDataList[i].RoleID != roleID)
                                {
                                    nRoleID = bangHuiMemberDataList[i].RoleID;
                                    break;
                                }
                            }
                        }
                        if (nRoleID > 0)
                        {
                            lock (Global.BangHuiMutex)
                            {
                                DBRoleInfo dbRole = dbMgr.GetDBRoleInfo(ref nRoleID);
                                if (dbRole != null)
                                {
                                    if (dbRole.Faction == dbRoleInfo.Faction)
                                    {
                                        dbRole.BHZhiWu = 1;
                                        DBWriter.UpdateBangHuiMemberZhiWu(dbMgr, dbRole.Faction, nRoleID, 1);
                                        DBWriter.UpdateBangHuiRoleID(dbMgr, nRoleID, dbRole.Faction);
                                        int    serverLineID = dbRoleInfo.ServerLineID;
                                        string strCmdData   = string.Format("0::0::0:-chbhzhiwu {0} {1} {2} {3}:0:0:-1", new object[]
                                        {
                                            dbRoleInfo.Faction,
                                            nRoleID,
                                            1,
                                            dbRoleInfo.RoleID
                                        });
                                        List <LineItem> itemList = LineManager.GetLineItemList();
                                        if (null != itemList)
                                        {
                                            for (int i = 0; i < itemList.Count; i++)
                                            {
                                                if (itemList[i].LineID != serverLineID)
                                                {
                                                    ChatMsgManager.AddChatMsg(itemList[i].LineID, strCmdData);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        BangHuiDestroyMgr.ClearBangHuiLingDi(dbMgr, dbRoleInfo.Faction);
                    }
                    else
                    {
                        BangHuiDestroyMgr.DoDestroyBangHui(dbMgr, dbRoleInfo.Faction);
                    }
                }
                dbRoleInfo.Faction  = 0;
                dbRoleInfo.BHName   = "";
                dbRoleInfo.BHZhiWu  = 0;
                dbRoleInfo.BangGong = 0;
                DBWriter.UpdateRoleBangHuiInfo(dbMgr, dbRoleInfo.RoleID, dbRoleInfo.Faction, dbRoleInfo.BHName, 0);
                int index = dbUserInfo.ListRoleIDs.IndexOf(roleID);
                if (index >= 0 && index < dbUserInfo.ListRoleIDs.Count)
                {
                    dbUserInfo.ListRoleIDs.RemoveAt(index);
                    dbUserInfo.ListRoleSexes.RemoveAt(index);
                    dbUserInfo.ListRoleOccups.RemoveAt(index);
                    dbUserInfo.ListRoleNames.RemoveAt(index);
                    dbUserInfo.ListRoleLevels.RemoveAt(index);
                    dbUserInfo.ListRoleZoneIDs.RemoveAt(index);
                    dbUserInfo.ListRoleChangeLifeCount.RemoveAt(index);
                    dbUserInfo.ListRolePreRemoveTime.RemoveAt(index);
                }
            }
        }