コード例 #1
0
ファイル: ItemAddingTable.cs プロジェクト: AiiMz/PserverWork
 public static void GetAddingsForItem(Interfaces.IConquerItem item)
 {
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
     cmd.Select("itemadding").Where("UID", item.UID);
     MySqlReader r = new MySqlReader(cmd);
     while (r.Read())
     {
         uint type = r.ReadUInt32("addingtype");
         if (type == 0)
         {
             ItemAdding.Purification_ purification = new ItemAdding.Purification_();
             purification.ItemUID = item.UID;
             purification.Available = true;
             purification.PurificationItemID = r.ReadUInt32("addingid");
             purification.PurificationDuration = r.ReadUInt32("duration");
             purification.PurificationLevel = r.ReadUInt32("addinglevel");
             purification.AddedOn = DateTime.FromBinary(r.ReadInt64("addedon"));
             if (purification.PurificationDuration != 0)
             {
                 TimeSpan span1 = new TimeSpan(purification.AddedOn.AddSeconds(purification.PurificationDuration).Ticks);
                 TimeSpan span2 = new TimeSpan(DateTime.Now.Ticks);
                 int secondsleft = (int)(span1.TotalSeconds - span2.TotalSeconds);
                 if (secondsleft <= 0)
                 {
                     purification.Available = false;
                     RemoveAdding(item.UID, purification.PurificationItemID);
                     continue;
                 }
             }
             item.Purification = purification;
         }
         else
         {
             ItemAdding.Refinery_ extraeffect = new ItemAdding.Refinery_();
             extraeffect.ItemUID = item.UID;
             extraeffect.Available = true;
             extraeffect.EffectID = r.ReadUInt32("addingid");
             extraeffect.EffectLevel = r.ReadUInt32("addinglevel");
             extraeffect.EffectPercent = r.ReadUInt32("addingpercent");
             extraeffect.EffectDuration = r.ReadUInt32("duration");
             extraeffect.AddedOn = DateTime.FromBinary(r.ReadInt64("addedon"));
             if (extraeffect.EffectDuration != 0)
             {
                 TimeSpan span1 = new TimeSpan(extraeffect.AddedOn.AddSeconds(extraeffect.EffectDuration).Ticks);
                 TimeSpan span2 = new TimeSpan(DateTime.Now.Ticks);
                 int secondsleft = (int)(span1.TotalSeconds - span2.TotalSeconds);
                 if (secondsleft <= 0)
                 {
                     extraeffect.Available = false;
                     RemoveAdding(item.UID, extraeffect.EffectID);
                     continue;
                 }
             }
             item.ExtraEffect = extraeffect;
         }
     }
     r.Close();
 }
コード例 #2
0
ファイル: PacketHandler.cs プロジェクト: faresali/co-pserver
        public static void PurifyItem(Purification ps, Client.GameState client)
        {
            Interfaces.IConquerItem Item = null, AddingItem = null;
            if (client.Inventory.TryGetItem(ps.ItemUID, out Item) && client.Inventory.TryGetItem(ps.AddUID, out AddingItem))
            {
                if (ps.ItemUID == ps.AddUID)
                    return;

                var PurifyInformation = Database.ConquerItemInformation.BaseInformations[AddingItem.ID];
                var ItemInformation = Database.ConquerItemInformation.BaseInformations[Item.ID];

                if (PurifyInformation.PurificationLevel > 0)
                {
                    if (ItemInformation.Level >= PurifyInformation.Level)
                    {
                        if (client.Inventory.Contains(1088001, PurifyInformation.PurificationMeteorNeed))
                        {
                            client.Inventory.Remove(1088001, (byte)PurifyInformation.PurificationMeteorNeed);
                            if (Item.Purification.PurificationItemID > 0)
                                Database.ItemAddingTable.RemoveAdding(Item.UID, Item.Purification.PurificationItemID);
                            ps.Mode = Purification.Stabilaze;
                            client.Send(ps);
                            ItemAdding.Purification_ purify = new ItemAdding.Purification_();
                            purify.AddedOn = DateTime.Now;
                            purify.Available = true;
                            purify.ItemUID = ps.ItemUID;
                            purify.PurificationLevel = PurifyInformation.PurificationLevel;
                            purify.PurificationDuration = 7 * 24 * 60 * 60;
                            purify.PurificationItemID = AddingItem.ID;
                            Database.ItemAddingTable.AddPurification(purify);
                            Item.Purification = purify;
                            Item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
                            Item.Send(client);
                            client.Inventory.Remove(AddingItem, Conquer_Online_Server.Game.Enums.ItemUse.Delete);
                            client.Send(ps);
                        }
                    }
                }
            }
        }