public MarryOtherResult ChangeRing(GameClient client, int nRingID) { MarryOtherResult result; if (-1 == client.ClientData.MyMarriageData.byMarrytype) { result = MarryOtherResult.NotMarriaged; } else if (nRingID - client.ClientData.MyMarriageData.nRingID != 1) { result = MarryOtherResult.NotNexRise; } else { SystemXmlItem RingXmlItem = null; if (!this.WeddingRingDic.SystemXmlItemDict.TryGetValue(nRingID, out RingXmlItem) || null == RingXmlItem) { result = MarryOtherResult.NotRing; } else { SystemXmlItem NowRingXmlItem = null; if (!this.WeddingRingDic.SystemXmlItemDict.TryGetValue(client.ClientData.MyMarriageData.nRingID, out NowRingXmlItem) || null == NowRingXmlItem) { result = MarryOtherResult.NotRing; } else { string strCostList = ""; int oldUserMoney = client.ClientData.UserMoney; int oldUserGlod = client.ClientData.Gold; int nCostGam = RingXmlItem.GetIntValue("NeedZuanShi", -1); int nBeforeCostGam = NowRingXmlItem.GetIntValue("NeedZuanShi", -1); int chajia = nCostGam - nBeforeCostGam; if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, chajia, "更换婚戒扣除", true, true, false, DaiBiSySType.None)) { result = MarryOtherResult.NeedGam; } else { strCostList += EventLogManager.NewResPropString(ResLogType.FristBindZuanShi, new object[] { -chajia, oldUserGlod, client.ClientData.Gold, oldUserMoney, client.ClientData.UserMoney }); client.ClientData.MyMarriageData.nRingID = nRingID; EventLogManager.AddRingBuyEvent(client, 1, nRingID, (int)client.ClientData.MyMarriageData.byGoodwilllevel, (int)client.ClientData.MyMarriageData.byGoodwilllevel, (int)client.ClientData.MyMarriageData.byGoodwillstar, (int)client.ClientData.MyMarriageData.byGoodwillstar, strCostList); this.UpdateRingAttr(client, true, false); MarryFuBenMgr.UpdateMarriageData2DB(client); this.SendMarriageDataToClient(client, true); result = MarryOtherResult.Success; } } } } return(result); }
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); }