Exemplo n.º 1
0
 public void UpdateMarriageGoodWill(GameClient client, int addGoodwillValue)
 {
     if (MarryLogic.IsVersionSystemOpenOfMarriage())
     {
         if (client.ClientData.MyMarriageData.byMarrytype != -1)
         {
             if (addGoodwillValue != 0)
             {
                 sbyte tmpGoodwilllv   = client.ClientData.MyMarriageData.byGoodwilllevel;
                 sbyte tmpGoodwillstar = client.ClientData.MyMarriageData.byGoodwillstar;
                 if (tmpGoodwilllv != this.byMaxGoodwillLv || tmpGoodwillstar != this.byMaxGoodwillStar)
                 {
                     int oldLevel = (int)client.ClientData.MyMarriageData.byGoodwilllevel;
                     int oldStart = (int)client.ClientData.MyMarriageData.byGoodwillstar;
                     client.ClientData.MyMarriageData.nGoodwillexp += addGoodwillValue;
                     int nNowLvAddExp = this.GoodwillAllExpList[(int)((tmpGoodwilllv - 1) * this.byMaxGoodwillStar + tmpGoodwillstar)];
                     client.ClientData.MyMarriageData.nGoodwillexp += nNowLvAddExp;
                     bool bUpdateLv   = false;
                     bool bUpdateStar = false;
                     for (int i = 1; i < this.GoodwillAllExpList.Count; i++)
                     {
                         if (i == this.GoodwillAllExpList.Count - 1 && client.ClientData.MyMarriageData.nGoodwillexp >= this.GoodwillAllExpList[i])
                         {
                             client.ClientData.MyMarriageData.byGoodwilllevel = this.byMaxGoodwillLv;
                             client.ClientData.MyMarriageData.byGoodwillstar  = this.byMaxGoodwillStar;
                             bUpdateStar = true;
                             client.ClientData.MyMarriageData.nGoodwillexp = this.GoodwillAllExpList[i] - this.GoodwillAllExpList[i - 1];
                         }
                         else if (client.ClientData.MyMarriageData.nGoodwillexp < this.GoodwillAllExpList[i])
                         {
                             int nLv;
                             int nStar;
                             if (i <= (int)(this.byMaxGoodwillStar + 1))
                             {
                                 nLv   = 1;
                                 nStar = i - 1;
                             }
                             else
                             {
                                 nLv   = (i - 2) / (int)this.byMaxGoodwillStar + 1;
                                 nStar = (i - 1) % (int)this.byMaxGoodwillStar;
                                 if (nStar == 0)
                                 {
                                     nStar = 10;
                                 }
                             }
                             if (nLv != (int)tmpGoodwilllv)
                             {
                                 bUpdateLv = true;
                             }
                             if (nStar != (int)tmpGoodwillstar)
                             {
                                 bUpdateStar = true;
                             }
                             client.ClientData.MyMarriageData.byGoodwilllevel = (sbyte)nLv;
                             client.ClientData.MyMarriageData.byGoodwillstar  = (sbyte)nStar;
                             client.ClientData.MyMarriageData.nGoodwillexp   -= this.GoodwillAllExpList[i - 1];
                             break;
                         }
                     }
                     if (bUpdateLv || bUpdateStar)
                     {
                         client.ClientData.MyMarriageData.ChangTime = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss");
                     }
                     MarryFuBenMgr.UpdateMarriageData2DB(client);
                     if (bUpdateLv || bUpdateStar)
                     {
                         this.UpdateRingAttr(client, true, false);
                     }
                     this.SendMarriageDataToClient(client, bUpdateLv || bUpdateStar);
                     if (bUpdateLv)
                     {
                         if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage) || client._IconStateMgr.CheckSpecialActivity(client) || client._IconStateMgr.CheckEverydayActivity(client))
                         {
                             client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                             client._IconStateMgr.SendIconStateToClient(client);
                         }
                     }
                     if (addGoodwillValue > 0)
                     {
                         string strHint = StringUtil.substitute(GLang.GetLang(490, new object[0]), new object[]
                         {
                             addGoodwillValue
                         });
                         GameManager.ClientMgr.NotifyImportantMsg(client, strHint, GameInfoTypeIndexes.Normal, ShowGameInfoTypes.PiaoFuZi, 0);
                     }
                     EventLogManager.AddRingStarSuitEvent(client, client.ClientData.MyMarriageData.nRingID, oldLevel, (int)client.ClientData.MyMarriageData.byGoodwilllevel, oldStart, (int)client.ClientData.MyMarriageData.byGoodwillstar, "");
                 }
             }
         }
     }
 }