예제 #1
0
        public static InventoryItemModel TryCreateItem(int templateId, TaxCollector TCollector, int quantity = 1, short position = -1, string Stats = null, Boolean useMax = false)
        {
            if (!ItemTemplateTable.Cache.ContainsKey(templateId)) // Template inexistant
            {
                return(null);
            }

            // Recup template
            var Template = ItemTemplateTable.GetTemplate(templateId);

            // Creation

            var Item = new InventoryItemModel()
            {
                ID         = DatabaseCache.nextItemGuid++,
                TemplateID = templateId,
                Position   = position,
                Quantity   = quantity,
                Effects    = (Stats == null ? Template.GenerateStats().ToItemStats() : Stats)
            };

            Item.GetStats();

            // Ajout de l'item dans l'inventaire
            TCollector.Items.Add(Item.ID, Item);
            addItem(Item, true);

            return(Item);
        }
예제 #2
0
        public static void Load()
        {
            ObjTemplateByMount.Clear();
            StatsByMount.Clear();
            var reader = DatabaseManager.Provider.ExecuteReader("SELECT * FROM static_mounts");

            while (reader.Read())
            {
                ObjTemplateByMount.Add(reader.GetInt32("id"), ItemTemplateTable.GetTemplate(reader.GetInt32("scrollID")));
                try
                {
                    List <Couple <int, Double> > _stats = new List <Couple <int, Double> >();
                    foreach (String stat in Regex.Split(reader.GetString("stats"), "\\|"))
                    {
                        String[]             infos = stat.Split('=');
                        Couple <int, Double> c     = new Couple <int, Double>(int.Parse(infos[0]), (infos.Length > 1 ? double.Parse(infos[1], CultureInfo.InvariantCulture) : 0));
                        _stats.Add(c);
                    }
                    StatsByMount.Add(reader.GetInt32("id"), _stats);
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
            reader.Close();

            Logger.Info("Loaded @'" + ObjTemplateByMount.Count + "'@ Mount");
        }
예제 #3
0
        public static InventoryItemModel TryCreateItem(int templateId, Player Character, int quantity = 1, short position = -1, string Stats = null, Boolean useMax = false)
        {
            if (!ItemTemplateTable.Cache.ContainsKey(templateId)) // Template inexistant
            {
                return(null);
            }

            // Recup template
            var Template = ItemTemplateTable.GetTemplate(templateId);

            // Creation

            var Item = new InventoryItemModel()
            {
                ID         = DatabaseCache.nextItemGuid++,
                TemplateID = templateId,
                Position   = position,
                Quantity   = quantity,
                Effects    = (Stats == null ? (Template.Type == 113 ? Template.StatsTemplate : Template.GenerateStats(useMax).ToItemStats()) : Stats)
            };

            Item.GetStats();

            // Ajout de l'item dans l'inventaire
            if (Character.InventoryCache.Add(Item))
            {
                addItem(Item, true);
            }
            return(Item);
        }
예제 #4
0
 public static void Update(List <BidHouseItem> list)
 {
     try
     {
         DatabaseManager.Provider.ExecuteQuery("TRUNCATE TABLE `bidhouse_items`");
     }
     catch (Exception e)
     {
         Logger.Error("Can't execute query : " + e.ToString());
     }
     try
     {
         MySqlCommand Command;
         foreach (var BHI in list)
         {
             if (BHI.Owner == -1)
             {
                 continue;
             }
             Command = new MySqlCommand()
             {
                 Connection  = DatabaseManager.Provider.getConnection(),
                 CommandText = "INSERT INTO `bidhouse_items` VALUES(@map,@owner,@price,@count,@item);",
             };
             Command.Prepare();
             Command.Parameters.AddWithValue("@map", BHI.MapID);
             Command.Parameters.AddWithValue("@owner", BHI.Owner);
             Command.Parameters.AddWithValue("@price", BHI.Price);
             Command.Parameters.AddWithValue("@count", BHI.getQuantity(false));
             Command.Parameters.AddWithValue("@item", BHI.Item.ID);
             Command.ExecuteNonQuery();
         }
         ItemTemplateTable.UpdateAVGPrice();
     }
     catch (Exception e)
     {
         Logger.Error("Can't execute query : " + e.ToString());
     }
 }