示例#1
0
        public static List <Potions> loadPotions()
        {
            List <Potions> potionList = new List <Potions>();

            using (SQLiteConnection cnn = new SQLiteConnection(LoadConnectionString()))
            {
                cnn.Open();

                SQLiteCommand command = cnn.CreateCommand();

                command.CommandText = "select * from Potions";

                SQLiteDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Potions potion = new Potions();
                    potion.name          = reader.GetString(1);
                    potion.description   = reader.GetString(2);
                    potion.recoveryValue = reader.GetInt32(3);
                    potionList.Add(potion);
                }

                reader.Close();
                cnn.Close();
                return(potionList);
            }
        }
示例#2
0
        public static Potions[] createPotions()
        {
            // Will look for the correct text file and will create potion objects using that information.
            Potions healthPotion        = new Potions(potionList[0].name, potionList[0].description, potionList[0].recoveryValue);
            Potions greaterHealthPotion = new Potions(potionList[1].name, potionList[1].description, potionList[1].recoveryValue);

            // Returns a list of potions created from this method
            Potions[] potionArray = { healthPotion, greaterHealthPotion };
            return(potionArray);
        }