示例#1
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null || player.events == null || string.IsNullOrEmpty(player.nickname) || player.nickname.Length == 0 || player.checkEventVisitConfirm)
         {
             client.SendCompletePacket(PackageDataManager.EVENT_VISIT_CONFIRM_0x80001500_PAK);
         }
         else
         {
             int dateNow = int.Parse(DateTime.Now.ToString("yyMMdd"));
             if (player.events.NextVisitDate <= dateNow)
             {
                 EventVisitModel eventVisit = EventVisitSyncer.GetEvent(eventId);
                 if (eventVisit != null)
                 {
                     if (eventVisit.EventIsEnabled())
                     {
                         player.events.NextVisitDate = int.Parse(DateTime.Now.AddDays(1).ToString("yyMMdd"));
                         if (player.ExecuteQuery($"UPDATE player_events SET next_visit_date='{player.events.NextVisitDate}', last_visit_sequence1='{player.events.LastVisitSequence1++}' WHERE player_id='{player.playerId}'"))
                         {
                             bool IsReward = false;
                             try
                             {
                                 IsReward = eventVisit.box[player.events.LastVisitSequence2].reward1.IsReward;
                             }
                             catch
                             {
                             }
                             if (!IsReward)
                             {
                                 player.ExecuteQuery($"UPDATE player_events SET last_visit_sequence2='{player.events.LastVisitSequence2++}' WHERE player_id='{player.playerId}'");
                             }
                             client.SendPacket(new EVENT_VISIT_CONFIRM_PAK(EventErrorEnum.VisitEvent_Success, eventVisit, player.events));
                         }
                         else
                         {
                             client.SendCompletePacket(PackageDataManager.EVENT_VISIT_CONFIRM_0x80001505_PAK);
                         }
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.EVENT_VISIT_CONFIRM_0x80001503_PAK);
                     }
                 }
                 else
                 {
                     client.SendCompletePacket(PackageDataManager.EVENT_VISIT_CONFIRM_0x80001505_PAK);
                 }
             }
             else
             {
                 client.SendCompletePacket(PackageDataManager.EVENT_VISIT_CONFIRM_0x80001502_PAK);
             }
             player.checkEventVisitConfirm = true;
         }
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
示例#2
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null || player.nickname.Length == 0 || player.checkEventVisitReward || type > 1)
         {
             client.SendCompletePacket(PackageDataManager.EVENT_VISIT_REWARD_ERROR_USERFAIL_PAK);
         }
         else if (player.events != null)
         {
             if (player.events.LastVisitSequence1 == player.events.LastVisitSequence2)
             {
                 client.SendCompletePacket(PackageDataManager.EVENT_VISIT_REWARD_ERROR_ALREADYCHECK_PAK);
             }
             else
             {
                 EventVisitModel eventv = EventVisitSyncer.GetEvent(eventId);
                 if (eventv == null)
                 {
                     client.SendCompletePacket(PackageDataManager.EVENT_VISIT_REWARD_ERROR_UNKNOWN_PAK);
                     return;
                 }
                 if (eventv.EventIsEnabled())
                 {
                     VisitItem chI = eventv.GetReward(player.events.LastVisitSequence2, type);
                     if (chI != null)
                     {
                         GoodItem good = ShopManager.GetGood(chI.goodId);
                         if (good != null)
                         {
                             player.events.NextVisitDate = int.Parse(DateTime.Now.AddDays(1).ToString("yyMMdd"));
                             if (player.ExecuteQuery($"UPDATE player_events SET next_visit_date='{player.events.NextVisitDate}', last_visit_sequence2='{player.events.LastVisitSequence2++}' WHERE player_id='{player.playerId}'"))
                             {
                                 client.SendPacket(new PROTOCOL_INVENTORY_ITEM_CREATE_ACK(1, player, new ItemsModel(good.item.id, good.item.category, good.item.name, good.item.equip, chI.count)));
                                 client.SendCompletePacket(PackageDataManager.EVENT_VISIT_REWARD_SUCCESS_PAK);
                             }
                             else
                             {
                                 client.SendCompletePacket(PackageDataManager.EVENT_VISIT_REWARD_ERROR_UNKNOWN_PAK);
                             }
                         }
                         else
                         {
                             client.SendCompletePacket(PackageDataManager.EVENT_VISIT_REWARD_ERROR_NOTENOUGH_PAK);
                         }
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.EVENT_VISIT_REWARD_ERROR_UNKNOWN_PAK);
                     }
                 }
                 else
                 {
                     client.SendCompletePacket(PackageDataManager.EVENT_VISIT_REWARD_ERROR_WRONGVERSION_PAK);
                 }
             }
             player.checkEventVisitReward = true;
         }
         else
         {
             client.SendCompletePacket(PackageDataManager.EVENT_VISIT_REWARD_ERROR_UNKNOWN_PAK);
         }
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }