Ejemplo n.º 1
0
        public DataTable GetDataTableQ(Category c, Attrib attrib1, string attrib1T, Attrib attrib2, string attrib2T, AndOr sign)
        {
            string           sql = "SELECT * FROM " + c.ToString() + " WHERE " + attrib1.ToString() + attrib1T + " " + sign.ToString() + " " + attrib2.ToString() + attrib2T + ";";
            SQLiteCommand    cmd = new SQLiteCommand(sql, dbConnection);
            SQLiteDataReader sdr = cmd.ExecuteReader();
            DataTable        dt  = new DataTable();

            dt.Load(sdr);
            return(dt);
        }
Ejemplo n.º 2
0
        private void ParseMaterial(List <object> MaterialList, int NameId, string MobOrGroup)
        {
            foreach (object MaterialObj in MaterialList)
            {
                DataRow row = null;

                if (MaterialObj is string)
                {
                    string Material = MaterialObj.ToString();
                    if (string.Equals(Material, "override", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ToggleMobOverride(MobOrGroup, true);
                        continue;
                    }
                    row = AddNewMaterial(NameId, MobOrGroup, Material);
                    continue;
                }

                int    MinLevel     = -1;
                int    MaxLevel     = -1;
                int    Amount       = 1;
                double Chance       = 0.2;
                bool   NoMultiplier = false;
                bool   NoSpawner    = false;
                bool   Equipped     = false;
                object Lore         = DBNull.Value;
                string Enchantments = null;

                if (MaterialObj is Dictionary <object, object> )
                {
                    Dictionary <object, object> MaterialList2 = (Dictionary <object, object>)MaterialObj;

                    foreach (object MaterialObj2 in MaterialList2.Keys)
                    {
                        string Material = MaterialObj2.ToString();

                        Dictionary <object, object> MaterialAttribs = (Dictionary <object, object>)MaterialList2[MaterialObj2];

                        foreach (object Attrib in MaterialAttribs.Keys)
                        {
                            double TempD       = 0.0;
                            bool   TempBool    = false;
                            string AttribName  = Attrib.ToString().ToLower();
                            object AttribValue = MaterialAttribs[Attrib];
                            switch (AttribName)
                            {
                            case "minlevel":
                                if (double.TryParse(AttribValue.ToString(), out TempD))
                                {
                                    MinLevel = (int)TempD;
                                }
                                break;

                            case "maxlevel":
                                if (double.TryParse(AttribValue.ToString(), out TempD))
                                {
                                    MaxLevel = (int)TempD;
                                }
                                break;

                            case "amount":
                                if (double.TryParse(AttribValue.ToString(), out TempD))
                                {
                                    Amount = (int)TempD;
                                }
                                break;

                            case "chance":
                                if (double.TryParse(AttribValue.ToString(), out TempD))
                                {
                                    Chance = TempD;
                                }
                                break;

                            case "nomultiplier":
                                if (bool.TryParse(AttribValue.ToString(), out TempBool))
                                {
                                    NoMultiplier = TempBool;
                                }
                                break;

                            case "nospawner":
                                if (bool.TryParse(AttribValue.ToString(), out TempBool))
                                {
                                    NoSpawner = TempBool;
                                }
                                break;

                            case "equipped":
                                if (bool.TryParse(AttribValue.ToString(), out TempBool))
                                {
                                    Equipped = TempBool;
                                }
                                break;

                            case "lore":
                                if (AttribValue is List <Object> )
                                {
                                    List <Object> LoreStrings = (List <Object>)AttribValue;
                                    StringBuilder sb          = new StringBuilder();
                                    foreach (object obj in LoreStrings)
                                    {
                                        if (sb.Length > 0)
                                        {
                                            sb.Append(";");
                                        }
                                        sb.Append(obj);
                                    }
                                    if (sb.Length > 0)
                                    {
                                        Lore = sb.ToString();
                                    }
                                }
                                break;

                            case "enchantments":
                                Enchantments = ParseEnchantments(AttribValue);
                                break;
                            }
                        }

                        row = AddNewMaterial(NameId, MobOrGroup, Material);

                        if (MinLevel > -1)
                        {
                            row["MinLevel"] = MinLevel;
                        }
                        if (MaxLevel > -1)
                        {
                            row["MaxLevel"] = MaxLevel;
                        }
                        if (Amount != 1)
                        {
                            row["Amount"] = Amount;
                        }
                        if ((decimal)Chance != m_DefaultChance)
                        {
                            row["Chance"] = Chance;
                        }
                        row["NoMultiplier"] = NoMultiplier;
                        row["NoSpawner"]    = NoSpawner;
                        row["Equipped"]     = Equipped;
                        row["Lore"]         = Lore;
                        if (Enchantments != null)
                        {
                            row["Enchantments"] = Enchantments;
                        }
                    }
                }
            }
        }