コード例 #1
0
ファイル: MarriageLogic.cs プロジェクト: chenchungit/ky
        public static void OnChangeName(int roleId, string oldName, string newName)
        {
            if (string.IsNullOrEmpty(oldName) || string.IsNullOrEmpty(newName))
            {
                return;
            }

            SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleId);

            // 未婚不处理
            if (clientData == null ||
                clientData.MyMarriageData == null ||
                clientData.MyMarriageData.nSpouseID == -1)
            {
                return;
            }

            // 把我的信息重新发给我的配偶
            GameClient spouseClient = GameManager.ClientMgr.FindClient(clientData.MyMarriageData.nSpouseID);

            if (spouseClient != null)
            {
                // 我改名了,要通知我的配偶
                MarriageOtherLogic.getInstance().SendSpouseDataToClient(spouseClient);
            }

            MarryPartyLogic.getInstance().OnChangeName(roleId, oldName, newName);
        }
コード例 #2
0
 public bool initialize()
 {
     MarriageOtherLogic.getInstance().init();
     this.ManAndWifeBossXmlItems.LoadFromXMlFile("Config/ManAndWifeBoss.xml", "", "MonsterID", 0);
     TCPCmdDispatcher.getInstance().registerProcessorEx(870, 1, 2, MarryFuBenMgr.getInstance(), TCPCmdFlags.IsStringArrayParams);
     GlobalEventSource.getInstance().registerListener(18, MarryFuBenMgr.getInstance());
     GlobalEventSource.getInstance().registerListener(12, MarryFuBenMgr.getInstance());
     return(true);
 }
コード例 #3
0
 public bool destroy()
 {
     GlobalEventSource.getInstance().removeListener(18, MarryFuBenMgr.getInstance());
     GlobalEventSource.getInstance().removeListener(12, MarryFuBenMgr.getInstance());
     if (null != this.MarriageInstanceDic)
     {
         lock (this.MarriageInstanceDic)
         {
             this.MarriageInstanceDic.Clear();
         }
     }
     MarriageOtherLogic.getInstance().destroy();
     return(true);
 }
コード例 #4
0
 public static void OnChangeName(int roleId, string oldName, string newName)
 {
     if (!string.IsNullOrEmpty(oldName) && !string.IsNullOrEmpty(newName))
     {
         SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleId);
         if (clientData != null && clientData.MyMarriageData != null && clientData.MyMarriageData.nSpouseID != -1)
         {
             GameClient spouseClient = GameManager.ClientMgr.FindClient(clientData.MyMarriageData.nSpouseID);
             if (spouseClient != null)
             {
                 MarriageOtherLogic.getInstance().SendSpouseDataToClient(spouseClient);
             }
             MarryPartyLogic.getInstance().OnChangeName(roleId, oldName, newName);
         }
     }
 }
コード例 #5
0
        public static MarryResult MarryDivorce(GameClient client, MarryDivorceType divorceType)
        {
            MarryResult result;

            if (!MarryLogic.IsVersionSystemOpenOfMarriage())
            {
                result = MarryResult.NotOpen;
            }
            else if (0 >= client.ClientData.MyMarriageData.byMarrytype)
            {
                result = MarryResult.NotMarried;
            }
            else if (!SingletonTemplate <CoupleArenaManager> .Instance().IsNowCanDivorce(TimeUtil.NowDateTime()))
            {
                result = MarryResult.DeniedByCoupleAreanTime;
            }
            else
            {
                int        spouseID     = client.ClientData.MyMarriageData.nSpouseID;
                GameClient spouseClient = GameManager.ClientMgr.FindClient(spouseID);
                if (divorceType == MarryDivorceType.DivorceForce || divorceType == MarryDivorceType.DivorceFree || divorceType == MarryDivorceType.DivorceFreeAccept)
                {
                    if (client.ClientData.ExchangeID > 0 || client.ClientSocket.IsKuaFuLogin || client.ClientData.CopyMapID > 0)
                    {
                        return(MarryResult.SelfBusy);
                    }
                    if (-1 != client.ClientData.FuBenID && MapTypes.MarriageCopy == Global.GetMapType(client.ClientData.MapCode))
                    {
                        return(MarryResult.SelfBusy);
                    }
                    if (null != spouseClient)
                    {
                        if (-1 != spouseClient.ClientData.FuBenID && MapTypes.MarriageCopy == Global.GetMapType(spouseClient.ClientData.MapCode))
                        {
                            return(MarryResult.TargetBusy);
                        }
                    }
                    if (divorceType == MarryDivorceType.DivorceForce || divorceType == MarryDivorceType.DivorceFree)
                    {
                        if (MarryLogic.ApplyExist(client.ClientData.RoleID))
                        {
                            return(MarryResult.SelfBusy);
                        }
                    }
                }
                int _man  = client.ClientData.RoleID;
                int _wife = spouseID;
                if (client.ClientData.MyMarriageData.byMarrytype == 2)
                {
                    DataHelper2.Swap <int>(ref _man, ref _wife);
                }
                if (divorceType == MarryDivorceType.DivorceForce)
                {
                    if (client.ClientData.UserMoney < MarryLogic.DivorceForceCost)
                    {
                        return(MarryResult.MoneyNotEnough);
                    }
                    if (!SingletonTemplate <CoupleWishManager> .Instance().PreClearDivorceData(_man, _wife))
                    {
                        return(MarryResult.NotOpen);
                    }
                    if (!SingletonTemplate <CoupleArenaManager> .Instance().PreClearDivorceData(_man, _wife))
                    {
                        return(MarryResult.NotOpen);
                    }
                    if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, MarryLogic.DivorceForceCost, "强制离婚", false, true, false, DaiBiSySType.None))
                    {
                    }
                    client.ClientData.MyMarriageData.byMarrytype = -1;
                    client.ClientData.MyMarriageData.nSpouseID   = -1;
                    MarryFuBenMgr.UpdateMarriageData2DB(client);
                    MarriageOtherLogic.getInstance().ResetRingAttr(client);
                    if (null != spouseClient)
                    {
                        spouseClient.ClientData.MyMarriageData.nSpouseID   = -1;
                        spouseClient.ClientData.MyMarriageData.byMarrytype = -1;
                        MarryFuBenMgr.UpdateMarriageData2DB(spouseClient);
                        MarriageOtherLogic.getInstance().ResetRingAttr(spouseClient);
                        MarriageOtherLogic.getInstance().SendMarriageDataToClient(spouseClient, true);
                        if (spouseClient._IconStateMgr.CheckJieRiFanLi(spouseClient, ActivityTypes.JieriMarriage))
                        {
                            spouseClient._IconStateMgr.AddFlushIconState(14000, spouseClient._IconStateMgr.IsAnyJieRiTipActived());
                            spouseClient._IconStateMgr.SendIconStateToClient(spouseClient);
                        }
                    }
                    else
                    {
                        string       tcpstring          = string.Format("{0}", spouseID);
                        MarriageData spouseMarriageData = Global.sendToDB <MarriageData, string>(10186, tcpstring, client.ServerId);
                        if (spouseMarriageData != null && 0 < spouseMarriageData.byMarrytype)
                        {
                            spouseMarriageData.byMarrytype = -1;
                            spouseMarriageData.nSpouseID   = -1;
                            MarryFuBenMgr.UpdateMarriageData2DB(spouseID, spouseMarriageData, client);
                        }
                    }
                    MarryPartyLogic.getInstance().MarryPartyRemove(client.ClientData.RoleID, true, client);
                    MarryPartyLogic.getInstance().MarryPartyRemove(spouseID, true, client);
                    MarriageOtherLogic.getInstance().SendMarriageDataToClient(client, true);
                    if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage))
                    {
                        client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                        client._IconStateMgr.SendIconStateToClient(client);
                    }
                    string msg = string.Format(GLang.GetLang(486, new object[0]), client.ClientData.RoleName);
                    MarryLogic.SendDivorceMail(spouseID, GLang.GetLang(487, new object[0]), msg, spouseClient, client.ServerId);
                    SingletonTemplate <CoupleArenaManager> .Instance().OnDivorce(client.ClientData.RoleID, spouseID);
                }
                else if (divorceType == MarryDivorceType.DivorceFree)
                {
                    if (null == spouseClient)
                    {
                        return(MarryResult.TargetOffline);
                    }
                    if (spouseClient.ClientData.ExchangeID > 0 || spouseClient.ClientSocket.IsKuaFuLogin || spouseClient.ClientData.CopyMapID > 0)
                    {
                        return(MarryResult.TargetBusy);
                    }
                    if (Global.GetTotalBindTongQianAndTongQianVal(client) < MarryLogic.DivorceCost)
                    {
                        return(MarryResult.MoneyNotEnough);
                    }
                    if (!Global.SubBindTongQianAndTongQian(client, MarryLogic.DivorceCost, "申请离婚"))
                    {
                        return(MarryResult.MoneyNotEnough);
                    }
                    MarryLogic.AddMarryApply(client.ClientData.RoleID, MarryApplyType.ApplyDivorce, spouseID);
                    string notifyData = string.Format("{0}:{1}", client.ClientData.RoleID, 1);
                    spouseClient.sendCmd(892, notifyData, false);
                    SingletonTemplate <CoupleArenaManager> .Instance().OnSpouseRequestDivorce(spouseClient, client);
                }
                else
                {
                    if (null == spouseClient)
                    {
                        return(MarryResult.TargetOffline);
                    }
                    if (!MarryLogic.RemoveMarryApply(spouseID, MarryApplyType.ApplyDivorce))
                    {
                        return(MarryResult.ApplyTimeout);
                    }
                    MarryLogic.RemoveMarryApply(spouseID, MarryApplyType.ApplyNull);
                    if (divorceType == MarryDivorceType.DivorceFreeAccept)
                    {
                        if (SingletonTemplate <CoupleWishManager> .Instance().PreClearDivorceData(_man, _wife) && SingletonTemplate <CoupleArenaManager> .Instance().PreClearDivorceData(_man, _wife))
                        {
                            client.ClientData.MyMarriageData.byMarrytype       = -1;
                            client.ClientData.MyMarriageData.nSpouseID         = -1;
                            spouseClient.ClientData.MyMarriageData.byMarrytype = -1;
                            spouseClient.ClientData.MyMarriageData.nSpouseID   = -1;
                            MarryFuBenMgr.UpdateMarriageData2DB(client);
                            MarryFuBenMgr.UpdateMarriageData2DB(spouseClient);
                            MarriageOtherLogic.getInstance().SendMarriageDataToClient(client, true);
                            MarriageOtherLogic.getInstance().SendMarriageDataToClient(spouseClient, true);
                            MarriageOtherLogic.getInstance().ResetRingAttr(client);
                            MarriageOtherLogic.getInstance().ResetRingAttr(spouseClient);
                            MarryPartyLogic.getInstance().MarryPartyRemove(client.ClientData.RoleID, true, client);
                            MarryPartyLogic.getInstance().MarryPartyRemove(spouseID, true, client);
                            if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage))
                            {
                                client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                                client._IconStateMgr.SendIconStateToClient(client);
                            }
                            if (spouseClient._IconStateMgr.CheckJieRiFanLi(spouseClient, ActivityTypes.JieriMarriage))
                            {
                                spouseClient._IconStateMgr.AddFlushIconState(14000, spouseClient._IconStateMgr.IsAnyJieRiTipActived());
                                spouseClient._IconStateMgr.SendIconStateToClient(spouseClient);
                            }
                            SingletonTemplate <CoupleArenaManager> .Instance().OnDivorce(client.ClientData.RoleID, spouseID);
                        }
                        else
                        {
                            GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, spouseClient, MarryLogic.DivorceCost, "自由离婚拒绝返还绑金", false);
                            GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(488, new object[0]), new object[0]), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0);
                            GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, spouseClient, StringUtil.substitute(GLang.GetLang(488, new object[0]), new object[0]), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0);
                        }
                    }
                    else if (divorceType == MarryDivorceType.DivorceFreeReject)
                    {
                        GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, spouseClient, MarryLogic.DivorceCost, "自由离婚拒绝返还绑金", false);
                        string notifyData = string.Format("{0}:{1}", client.ClientData.RoleID, 3);
                        spouseClient.sendCmd(892, notifyData, false);
                    }
                }
                result = MarryResult.Success;
            }
            return(result);
        }
コード例 #6
0
        public static MarryResult MarryReply(GameClient client, int sourceID, int accept)
        {
            MarryResult result;

            if (!MarryLogic.IsVersionSystemOpenOfMarriage())
            {
                result = MarryResult.NotOpen;
            }
            else if (client.ClientData.MyMarriageData.byMarrytype > 0)
            {
                result = MarryResult.SelfMarried;
            }
            else
            {
                GameClient sourceClient = GameManager.ClientMgr.FindClient(sourceID);
                if (sourceClient == null)
                {
                    result = MarryResult.ApplyTimeout;
                }
                else if (sourceClient.ClientData.MyMarriageData.byMarrytype > 0)
                {
                    result = MarryResult.TargetMarried;
                }
                else if (!MarryLogic.RemoveMarryApply(sourceID, MarryApplyType.ApplyInit))
                {
                    result = MarryResult.ApplyTimeout;
                }
                else
                {
                    if (!client.ClientData.IsMainOccupation || !sourceClient.ClientData.IsMainOccupation)
                    {
                        accept = 0;
                    }
                    if (accept == 0 || client.ClientData.MyMarriageData.byAutoReject == 1)
                    {
                        string notifyData = string.Format("{0}:{1}:{2}", 1, client.ClientData.RoleID, client.ClientData.RoleName);
                        sourceClient.sendCmd(894, notifyData, false);
                        GameManager.ClientMgr.AddUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, sourceClient, MarryLogic.MarryCost, "求婚被拒绝返还钻石", ActivityTypes.None, "");
                    }
                    else
                    {
                        MarryLogic.RemoveMarryApply(sourceID, MarryApplyType.ApplyNull);
                        MarryLogic.ApplyLogoutClear(client);
                        MarryLogic.RemoveMarryApply(client.ClientData.RoleID, MarryApplyType.ApplyNull);
                        int initRingID = 0;
                        if (null != MarriageOtherLogic.getInstance().WeddingRingDic.SystemXmlItemDict)
                        {
                            initRingID = MarriageOtherLogic.getInstance().WeddingRingDic.SystemXmlItemDict.Keys.First <int>();
                        }
                        if (sourceClient.ClientData.MyMarriageData.nRingID <= 0)
                        {
                            sourceClient.ClientData.MyMarriageData.nRingID = initRingID;
                        }
                        if (client.ClientData.MyMarriageData.nRingID <= 0)
                        {
                            client.ClientData.MyMarriageData.nRingID = initRingID;
                        }
                        sbyte sourceType = (sbyte)(sourceClient.ClientData.RoleSex != 1 || client.ClientData.RoleSex == sourceClient.ClientData.RoleSex ? 1 : 2);
                        sourceClient.ClientData.MyMarriageData.byMarrytype = sourceType;
                        client.ClientData.MyMarriageData.byMarrytype       = (sbyte)(sourceType == 1 ? 2 : 1);
                        sourceClient.ClientData.MyMarriageData.nSpouseID   = client.ClientData.RoleID;
                        client.ClientData.MyMarriageData.nSpouseID         = sourceID;
                        if (sourceClient.ClientData.MyMarriageData.byGoodwilllevel == 0)
                        {
                            sourceClient.ClientData.MyMarriageData.ChangTime       = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss");
                            sourceClient.ClientData.MyMarriageData.byGoodwilllevel = 1;
                        }
                        if (client.ClientData.MyMarriageData.byGoodwilllevel == 0)
                        {
                            client.ClientData.MyMarriageData.ChangTime       = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss");
                            client.ClientData.MyMarriageData.byGoodwilllevel = 1;
                        }
                        EventLogManager.AddRingBuyEvent(sourceClient, 0, initRingID, 0, 0, 0, 1, "");
                        EventLogManager.AddRingBuyEvent(client, 0, initRingID, 0, 0, 0, 1, "");
                        MarryFuBenMgr.UpdateMarriageData2DB(sourceClient);
                        MarryFuBenMgr.UpdateMarriageData2DB(client);
                        MarriageOtherLogic.getInstance().SendMarriageDataToClient(sourceClient, true);
                        MarriageOtherLogic.getInstance().SendMarriageDataToClient(client, true);
                        MarriageOtherLogic.getInstance().UpdateRingAttr(sourceClient, true, false);
                        if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage))
                        {
                            client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                            client._IconStateMgr.SendIconStateToClient(client);
                        }
                        if (sourceClient._IconStateMgr.CheckJieRiFanLi(sourceClient, ActivityTypes.JieriMarriage))
                        {
                            sourceClient._IconStateMgr.AddFlushIconState(14000, sourceClient._IconStateMgr.IsAnyJieRiTipActived());
                            sourceClient._IconStateMgr.SendIconStateToClient(sourceClient);
                        }
                        FriendData friendData = Global.FindFriendData(client, sourceID);
                        if (friendData != null && friendData.FriendType != 0)
                        {
                            GameManager.ClientMgr.RemoveFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, friendData.DbID);
                            friendData = null;
                        }
                        if (friendData == null)
                        {
                            GameManager.ClientMgr.AddFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, -1, sourceID, Global.FormatRoleName(sourceClient, sourceClient.ClientData.RoleName), 0);
                        }
                        friendData = Global.FindFriendData(sourceClient, client.ClientData.RoleID);
                        if (friendData != null && friendData.FriendType != 0)
                        {
                            GameManager.ClientMgr.RemoveFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, sourceClient, friendData.DbID);
                            friendData = null;
                        }
                        if (friendData == null)
                        {
                            GameManager.ClientMgr.AddFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, sourceClient, -1, client.ClientData.RoleID, Global.FormatRoleName(client, client.ClientData.RoleName), 0);
                        }
                        string broadCastMsg = string.Format(GLang.GetLang(485, new object[0]), sourceClient.ClientData.RoleName, client.ClientData.RoleName);
                        Global.BroadcastRoleActionMsg(client, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlySysHint, 0, 0, 100, 100);
                        SingletonTemplate <CoupleArenaManager> .Instance().OnMarry(sourceClient, client);
                    }
                    result = MarryResult.Success;
                }
            }
            return(result);
        }
コード例 #7
0
 public void init()
 {
     try
     {
         this.dNeedGam = GameManager.systemParamsList.GetParamValueDoubleArrayByName("XianHuaCost", ',');
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic XianHuaCost", false, false);
     }
     try
     {
         this.dRingmodulus = GameManager.systemParamsList.GetParamValueDoubleByName("GoodWillXiShu", 0.0);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic GoodWillXiShu", false, false);
     }
     try
     {
         this.dOtherRingmodulus = GameManager.systemParamsList.GetParamValueDoubleByName("BanLvXiShu", 0.0);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic BanLvXiShu", false, false);
     }
     try
     {
         this.WeddingRingDic.LoadFromXMlFile("Config/WeddingRing.xml", "", "GoodsID", 0);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic WeddingRing.xml", false, false);
     }
     try
     {
         SystemXmlItems RoseXmlItems = new SystemXmlItems();
         RoseXmlItems.LoadFromXMlFile("Config/GiveRose.xml", "", "GoodsID", 0);
         foreach (KeyValuePair <int, SystemXmlItem> item in RoseXmlItems.SystemXmlItemDict)
         {
             MarriageRoseData rosedata = new MarriageRoseData();
             rosedata.nBaseAddGoodWill = item.Value.GetIntValue("GoodWill", -1);
             string[] strfiled = item.Value.GetStringValue("MultiplyingPower").Split(new char[]
             {
                 '|'
             });
             int nAddRate = 0;
             for (int i = 0; i < strfiled.Length; i++)
             {
                 string[] strfiled2 = strfiled[i].Split(new char[]
                 {
                     ','
                 });
                 nAddRate += (int)(Convert.ToDouble(strfiled2[1]) * 100.0);
                 rosedata.modulusList.Add(Convert.ToInt32(strfiled2[0]));
                 rosedata.rateList.Add(nAddRate);
             }
             this.RoseDataDic.Add(Convert.ToInt32(item.Value.GetIntValue("GoodsID", -1)), rosedata);
         }
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic GiveRose.xml", false, false);
     }
     try
     {
         SystemXmlItems XmlItems = new SystemXmlItems();
         XmlItems.LoadFromXMlFile("Config/GoodWill.xml", "", "Type", 0);
         sbyte tmpStar = 0;
         int   nAddExp = 0;
         this.GoodwillAllExpList.Add(0);
         foreach (KeyValuePair <int, SystemXmlItem> item in XmlItems.SystemXmlItemDict)
         {
             tmpStar = 0;
             foreach (XElement xmlnode in item.Value.XMLNode.Descendants())
             {
                 nAddExp += Convert.ToInt32(xmlnode.Attribute("NeedGoodWill").Value);
                 this.GoodwillAllExpList.Add(nAddExp);
                 tmpStar += 1;
             }
         }
         this.byMaxGoodwillLv   = (sbyte)((this.GoodwillAllExpList.Count - 1) / (int)tmpStar);
         this.byMaxGoodwillStar = tmpStar;
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "init marryotherlogic GoodWill.xml", false, false);
     }
     TCPCmdDispatcher.getInstance().registerProcessorEx(871, 1, 1, MarriageOtherLogic.getInstance(), TCPCmdFlags.IsStringArrayParams);
     TCPCmdDispatcher.getInstance().registerProcessorEx(872, 1, 1, MarriageOtherLogic.getInstance(), TCPCmdFlags.IsStringArrayParams);
     TCPCmdDispatcher.getInstance().registerProcessorEx(873, 1, 1, MarriageOtherLogic.getInstance(), TCPCmdFlags.IsStringArrayParams);
 }
コード例 #8
0
ファイル: MarriageLogic.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 离婚
        /// </summary>
        public static MarryResult MarryDivorce(GameClient client, MarryDivorceType divorceType)
        {
            if (!MarryLogic.IsVersionSystemOpenOfMarriage())
            {
                return(MarryResult.NotOpen);
            }

            if (0 >= client.ClientData.MyMarriageData.byMarrytype)
            {
                return(MarryResult.NotMarried);
            }

            if (!CoupleArenaManager.Instance().IsNowCanDivorce(TimeUtil.NowDateTime()))
            {
                return(MarryResult.DeniedByCoupleAreanTime);
            }

            int        spouseID     = client.ClientData.MyMarriageData.nSpouseID;
            GameClient spouseClient = GameManager.ClientMgr.FindClient(spouseID);

            if (divorceType == MarryDivorceType.DivorceForce || divorceType == MarryDivorceType.DivorceFree || divorceType == MarryDivorceType.DivorceFreeAccept)
            {
                if (client.ClientData.ExchangeID > 0 || true == client.ClientSocket.IsKuaFuLogin || client.ClientData.CopyMapID > 0)
                {
                    return(MarryResult.SelfBusy);
                }
                if (-1 != client.ClientData.FuBenID && MapTypes.MarriageCopy == Global.GetMapType(client.ClientData.MapCode))
                {
                    return(MarryResult.SelfBusy);
                }
                if (null != spouseClient)
                {
                    if (-1 != spouseClient.ClientData.FuBenID && MapTypes.MarriageCopy == Global.GetMapType(spouseClient.ClientData.MapCode))
                    {
                        return(MarryResult.TargetBusy);
                    }
                }

                if (divorceType == MarryDivorceType.DivorceForce || divorceType == MarryDivorceType.DivorceFree)
                {
                    if (true == ApplyExist(client.ClientData.RoleID))
                    {
                        return(MarryResult.SelfBusy);
                    }
                }
            }

            int _man = client.ClientData.RoleID, _wife = spouseID;

            if (client.ClientData.MyMarriageData.byMarrytype == 2)
            {
                DataHelper2.Swap(ref _man, ref _wife);;
            }

            if (divorceType == MarryDivorceType.DivorceForce)
            {
                if (client.ClientData.UserMoney < DivorceForceCost)
                {
                    return(MarryResult.MoneyNotEnough);
                }

                // 情侣竞技和情侣祝福都需要离婚清除数据,所以,可能会导致部分清除失败,由于竞技更要求数据的准确性,所以先清除情侣祝福,再清楚情侣竞技

                // 情侣祝福排行版通知清除排行数据
                // 必须保证先清除成功,才能强制离婚离婚
                if (!CoupleWishManager.Instance().PreClearDivorceData(_man, _wife))
                {
                    return(MarryResult.NotOpen);
                }

                // 情侣竞技通知中心竞技、排行数据,dbserver清除战报数据
                // 必须保证先清除成功,才能强制离婚离婚
                if (!CoupleArenaManager.Instance().PreClearDivorceData(_man, _wife))
                {
                    return(MarryResult.NotOpen);
                }

                //强制离婚
                if (false == GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, DivorceForceCost, "强制离婚", false))
                {
                    // return MarryResult.MoneyNotEnough;
                }

                client.ClientData.MyMarriageData.byMarrytype = -1;
                client.ClientData.MyMarriageData.nSpouseID   = -1;
                MarryFuBenMgr.UpdateMarriageData2DB(client);
                MarriageOtherLogic.getInstance().ResetRingAttr(client);

                if (null != spouseClient)
                {
                    spouseClient.ClientData.MyMarriageData.nSpouseID   = -1;
                    spouseClient.ClientData.MyMarriageData.byMarrytype = -1;
                    MarryFuBenMgr.UpdateMarriageData2DB(spouseClient);
                    MarriageOtherLogic.getInstance().ResetRingAttr(spouseClient);

                    //[bing] 给配偶发送CMD_SPR_MARRY_UPDATE
                    MarriageOtherLogic.getInstance().SendMarriageDataToClient(spouseClient);

                    //[bing] 刷新客户端活动叹号
                    if (spouseClient._IconStateMgr.CheckJieRiFanLi(spouseClient, ActivityTypes.JieriMarriage) == true)
                    {
                        spouseClient._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, spouseClient._IconStateMgr.IsAnyJieRiTipActived());
                        spouseClient._IconStateMgr.SendIconStateToClient(spouseClient);
                    }
                }
                else
                {
                    string       tcpstring          = string.Format("{0}", spouseID);
                    MarriageData spouseMarriageData = Global.sendToDB <MarriageData, string>((int)TCPGameServerCmds.CMD_DB_GET_MARRY_DATA, tcpstring, client.ServerId);

                    if (null != spouseMarriageData && 0 < spouseMarriageData.byMarrytype)
                    {
                        spouseMarriageData.byMarrytype = -1;
                        spouseMarriageData.nSpouseID   = -1;
                        MarryFuBenMgr.UpdateMarriageData2DB(spouseID, spouseMarriageData, client);
                    }
                }

                // 取消婚宴
                MarryPartyLogic.getInstance().MarryPartyRemove(client.ClientData.RoleID, true, client);
                MarryPartyLogic.getInstance().MarryPartyRemove(spouseID, true, client);

                //[bing] 给自己发送CMD_SPR_MARRY_UPDATE
                MarriageOtherLogic.getInstance().SendMarriageDataToClient(client);

                //[bing] 刷新客户端活动叹号
                if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage) == true)
                {
                    client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived());
                    client._IconStateMgr.SendIconStateToClient(client);
                }

                // send mail
                string msg = string.Format(Global.GetLang("在您收到这封邮件的时候,您的伴侣{0}已经申请与您强制离婚,现在您已经恢复单身。您的定情信物将被封存,所有属性暂时失效,直至下次结婚时生效。最后,预祝您再次觅得真心人,相伴共度美好的游戏时光。感谢您阅读这封邮件。"), client.ClientData.RoleName);
                SendDivorceMail(spouseID, Global.GetLang("离婚"), msg, spouseClient, client.ServerId);

                CoupleArenaManager.Instance().OnDivorce(client.ClientData.RoleID, spouseID);
            }
            else if (divorceType == MarryDivorceType.DivorceFree)
            {
                //申请离婚
                if (null == spouseClient)
                {
                    return(MarryResult.TargetOffline);
                }
                if (spouseClient.ClientData.ExchangeID > 0 || true == spouseClient.ClientSocket.IsKuaFuLogin || spouseClient.ClientData.CopyMapID > 0)
                {
                    return(MarryResult.TargetBusy);
                }

                if (Global.GetTotalBindTongQianAndTongQianVal(client) < DivorceCost)
                {
                    return(MarryResult.MoneyNotEnough);
                }
                if (Global.SubBindTongQianAndTongQian(client, DivorceCost, "申请离婚") == false)
                {
                    return(MarryResult.MoneyNotEnough);
                }

                AddMarryApply(client.ClientData.RoleID, MarryApplyType.ApplyDivorce, spouseID);

                //发送离婚申请
                string notifyData = string.Format("{0}:{1}", client.ClientData.RoleID, (int)MarryDivorceType.DivorceFree);
                spouseClient.sendCmd((int)TCPGameServerCmds.CMD_SPR_MARRY_DIVORCE, notifyData);
                CoupleArenaManager.Instance().OnSpouseRequestDivorce(spouseClient, client);
            }
            else
            {
                if (null == spouseClient)
                {
                    return(MarryResult.TargetOffline);
                }

                if (RemoveMarryApply(spouseID, MarryApplyType.ApplyDivorce) == false)
                {
                    return(MarryResult.ApplyTimeout);
                }
                RemoveMarryApply(spouseID);

                if (divorceType == MarryDivorceType.DivorceFreeAccept)
                {
                    // 情侣竞技通知中心竞技、排行数据,dbserver清除战报数据
                    // 必须保证先清除成功,才能自由离婚
                    if (CoupleWishManager.Instance().PreClearDivorceData(_man, _wife) &&
                        CoupleArenaManager.Instance().PreClearDivorceData(_man, _wife))
                    {
                        client.ClientData.MyMarriageData.byMarrytype       = -1;
                        client.ClientData.MyMarriageData.nSpouseID         = -1;
                        spouseClient.ClientData.MyMarriageData.byMarrytype = -1;
                        spouseClient.ClientData.MyMarriageData.nSpouseID   = -1;

                        MarryFuBenMgr.UpdateMarriageData2DB(client);
                        MarryFuBenMgr.UpdateMarriageData2DB(spouseClient);

                        MarriageOtherLogic.getInstance().SendMarriageDataToClient(client);
                        MarriageOtherLogic.getInstance().SendMarriageDataToClient(spouseClient);

                        //更新婚戒属性
                        MarriageOtherLogic.getInstance().ResetRingAttr(client);
                        MarriageOtherLogic.getInstance().ResetRingAttr(spouseClient);

                        //取消婚宴
                        MarryPartyLogic.getInstance().MarryPartyRemove(client.ClientData.RoleID, true, client);
                        MarryPartyLogic.getInstance().MarryPartyRemove(spouseID, true, client);

                        //[bing] 刷新客户端活动叹号
                        if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage) == true)
                        {
                            client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived());
                            client._IconStateMgr.SendIconStateToClient(client);
                        }
                        //[bing] 刷新客户端活动叹号
                        if (spouseClient._IconStateMgr.CheckJieRiFanLi(spouseClient, ActivityTypes.JieriMarriage) == true)
                        {
                            spouseClient._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, spouseClient._IconStateMgr.IsAnyJieRiTipActived());
                            spouseClient._IconStateMgr.SendIconStateToClient(spouseClient);
                        }

                        CoupleArenaManager.Instance().OnDivorce(client.ClientData.RoleID, spouseID);
                    }
                    else
                    {
                        GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, spouseClient,
                                                        DivorceCost, "自由离婚拒绝返还绑金", false);
                        //GameManager.ClientMgr.AddUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, spouseClient, DivorceCost, "自由离婚拒绝返还绑金");

                        Global.BroadcastRoleActionMsg(client, RoleActionsMsgTypes.HintMsg, "自由离婚操作失败", true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlySysHint);
                        Global.BroadcastRoleActionMsg(spouseClient, RoleActionsMsgTypes.HintMsg, "自由离婚操作失败", true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlySysHint);
                    }
                }
                else if (divorceType == MarryDivorceType.DivorceFreeReject)
                {
                    GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, spouseClient,
                                                    DivorceCost, "自由离婚拒绝返还绑金", false);
                    //GameManager.ClientMgr.AddUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, spouseClient, DivorceCost, "自由离婚拒绝返还绑金");

                    //发送离婚拒绝讯息
                    string notifyData = string.Format("{0}:{1}", client.ClientData.RoleID, (int)MarryDivorceType.DivorceFreeReject);
                    spouseClient.sendCmd((int)TCPGameServerCmds.CMD_SPR_MARRY_DIVORCE, notifyData);
                }
            }

            return(MarryResult.Success);
        }
コード例 #9
0
ファイル: MarriageLogic.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 对方回复求婚
        /// </summary>
        public static MarryResult MarryReply(GameClient client, int sourceID, int accept)
        {
            if (!MarryLogic.IsVersionSystemOpenOfMarriage())
            {
                return(MarryResult.NotOpen);
            }

            if (client.ClientData.MyMarriageData.byMarrytype > 0)
            {
                return(MarryResult.SelfMarried);
            }

            GameClient sourceClient = GameManager.ClientMgr.FindClient(sourceID);

            if (sourceClient == null)
            {
                return(MarryResult.ApplyTimeout);
            }
            if (sourceClient.ClientData.MyMarriageData.byMarrytype > 0)
            {
                return(MarryResult.TargetMarried);
            }

            if (RemoveMarryApply(sourceID, MarryApplyType.ApplyInit) == false)
            {
                return(MarryResult.ApplyTimeout);
            }

            if (accept == 0 || client.ClientData.MyMarriageData.byAutoReject == 1)
            {
                // 拒绝返钱
                string notifyData = string.Format("{0}:{1}:{2}", (int)MarryNotifyType.NotifyRejectInit, client.ClientData.RoleID, client.ClientData.RoleName);
                sourceClient.sendCmd((int)TCPGameServerCmds.CMD_SPR_MARRY_NOTIFY, notifyData);

                GameManager.ClientMgr.AddUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, sourceClient, MarryCost, "求婚被拒绝返还钻石");
            }
            else
            {
                // 同意
                RemoveMarryApply(sourceID);

                // 如果自己在申请狀态,需取消返钱
                MarryLogic.ApplyLogoutClear(client);
                RemoveMarryApply(client.ClientData.RoleID);

                // 初始婚戒
                int initRingID = 0;
                if (null != MarriageOtherLogic.getInstance().WeddingRingDic.SystemXmlItemDict)
                {
                    initRingID = MarriageOtherLogic.getInstance().WeddingRingDic.SystemXmlItemDict.Keys.First();
                }
                if (sourceClient.ClientData.MyMarriageData.nRingID <= 0)
                {
                    sourceClient.ClientData.MyMarriageData.nRingID = initRingID;
                }
                if (client.ClientData.MyMarriageData.nRingID <= 0)
                {
                    client.ClientData.MyMarriageData.nRingID = initRingID;
                }

                // 更新婚姻狀态
                // marry type 1:丈夫 2:妻子
                sbyte sourceType = (sourceClient.ClientData.RoleSex != 1 || client.ClientData.RoleSex == sourceClient.ClientData.RoleSex)? (sbyte)1 : (sbyte)2;
                sourceClient.ClientData.MyMarriageData.byMarrytype = sourceType;
                client.ClientData.MyMarriageData.byMarrytype       = (sourceType == 1)? (sbyte)2 : (sbyte)1;

                // 更新伴侶role id
                sourceClient.ClientData.MyMarriageData.nSpouseID = client.ClientData.RoleID;
                client.ClientData.MyMarriageData.nSpouseID       = sourceID;

                // 初始化0星1阶 [bing] 因为再结婚还会走这个函数就会被初始化为1阶 应该不初始化它 是个bug 这里FIX下
                if (sourceClient.ClientData.MyMarriageData.byGoodwilllevel == 0)
                {
                    //[bing] 更新时间
                    sourceClient.ClientData.MyMarriageData.ChangTime       = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss");
                    sourceClient.ClientData.MyMarriageData.byGoodwilllevel = 1;
                }
                if (client.ClientData.MyMarriageData.byGoodwilllevel == 0)
                {
                    client.ClientData.MyMarriageData.ChangTime       = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss");
                    client.ClientData.MyMarriageData.byGoodwilllevel = 1;
                }

                MarryFuBenMgr.UpdateMarriageData2DB(sourceClient);
                MarryFuBenMgr.UpdateMarriageData2DB(client);

                MarriageOtherLogic.getInstance().SendMarriageDataToClient(sourceClient);
                MarriageOtherLogic.getInstance().SendMarriageDataToClient(client);

                //更新婚戒属性
                MarriageOtherLogic.getInstance().UpdateRingAttr(sourceClient, true);

                //[bing] 刷新客户端活动叹号
                if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage) == true)
                {
                    client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived());
                    client._IconStateMgr.SendIconStateToClient(client);
                }
                //[bing] 刷新客户端活动叹号
                if (sourceClient._IconStateMgr.CheckJieRiFanLi(sourceClient, ActivityTypes.JieriMarriage) == true)
                {
                    sourceClient._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, sourceClient._IconStateMgr.IsAnyJieRiTipActived());
                    sourceClient._IconStateMgr.SendIconStateToClient(sourceClient);
                }

                // 好友逻辑
                FriendData friendData = Global.FindFriendData(client, sourceID);
                if (friendData != null && friendData.FriendType != 0)
                {
                    GameManager.ClientMgr.RemoveFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool,
                                                       client, friendData.DbID);
                    friendData = null;
                }
                if (friendData == null)
                {
                    GameManager.ClientMgr.AddFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool,
                                                    client, -1, sourceID, Global.FormatRoleName(sourceClient, sourceClient.ClientData.RoleName), 0);
                }

                friendData = Global.FindFriendData(sourceClient, client.ClientData.RoleID);
                if (friendData != null && friendData.FriendType != 0)
                {
                    GameManager.ClientMgr.RemoveFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool,
                                                       sourceClient, friendData.DbID);
                    friendData = null;
                }
                if (friendData == null)
                {
                    GameManager.ClientMgr.AddFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool,
                                                    sourceClient, -1, client.ClientData.RoleID, Global.FormatRoleName(client, client.ClientData.RoleName), 0);
                }

                //扩播消息
                string broadCastMsg = string.Format(Global.GetLang("恭喜 {0} 和 {1} 喜结连理!"), sourceClient.ClientData.RoleName, client.ClientData.RoleName);
                Global.BroadcastRoleActionMsg(client, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlySysHint);

                CoupleArenaManager.Instance().OnMarry(sourceClient, client);
            }

            return(MarryResult.Success);
        }