Beispiel #1
0
        public ValueTask <ISpellBook> ByTag(string[] filter, ISpellBook spellBook)
        {
            if (filter.Any())
            {
                var removeList = new List <ISpell>();
                var enumTags   = filter.Select(Enum.Parse <Tag>).ToArray();
                foreach (var spell in spellBook.Spells)
                {
                    var containsTag = false;
                    if (spell.Tags != null && spell.Tags.Any())
                    {
                        foreach (var tag in enumTags)
                        {
                            if (spell.Tags.Contains(tag))
                            {
                                containsTag = true;
                            }
                        }
                    }

                    if (!containsTag)
                    {
                        removeList.Add(spell);
                    }
                }

                foreach (var spell in removeList)
                {
                    spellBook.Spells.Remove(spell);
                }
            }

            return(new ValueTask <ISpellBook>(spellBook));
        }
Beispiel #2
0
        public ValueTask <ISpellBook> BySpell(string[] filter, ISpellBook spellBook)
        {
            if (filter.Any())
            {
                var removeList = new List <ISpell>();
                foreach (var spell in spellBook.Spells)
                {
                    var containsWord = false;
                    if (spell.Tags != null && spell.Tags.Any())
                    {
                        foreach (var word in filter)
                        {
                            if (spell.Name.Contains(word, StringComparison.OrdinalIgnoreCase))
                            {
                                containsWord = true;
                            }
                        }
                    }

                    if (!containsWord)
                    {
                        removeList.Add(spell);
                    }
                }

                foreach (var spell in removeList)
                {
                    spellBook.Spells.Remove(spell);
                }
            }

            return(new ValueTask <ISpellBook>(spellBook));
        }
 public InventoryItem(int newID, IWeapon weapon, IArmor armor, ISpellBook spellBook, int quantity)
 {
     ID        = newID;
     Weapon    = weapon;
     Armor     = armor;
     SpellBook = spellBook;
     Quantity  = quantity;
 }
        public InventoryItem(ISpellBook spellBook)
        {
            DatabaseConnection conn   = new DatabaseConnection();
            DatabaseReader     reader = conn.QueryRowFromTableWhereColNameEqualsInt("Inventory", "Spell_Book_FK", spellBook.ID);

            SpellBook = spellBook;
            if (reader.NextRow())
            {
                ID       = reader.GetIntFromCol("ID");
                Quantity = reader.GetIntFromCol("Quantity");
            }
            else
            {
                string query = $"INSERT INTO Inventory (Spell_Book_FK, Quantity) VALUES ({spellBook.ID}, 0);";
                conn.ExecuteNonQuery(query);
                Quantity = 0;
                reader.CloseReader();
                reader = conn.QueryRowFromTableWhereColNameEqualsInt("Inventory", "Spell_Book_FK", spellBook.ID);
                ID     = reader.GetIntFromCol("ID");
            }
            reader.CloseReader();
            conn.CloseConnection();
        }
Beispiel #5
0
 public ValueTask <ISpellBook> BySpecial(string[] filter, ISpellBook spellBook)
 {
     return(new ValueTask <ISpellBook>(spellBook));
 }
Beispiel #6
0
 public ValueTask <bool> BySchool(string[] filter, ISpellBook spellBook)
 {
     return(filter.Any()
         ? new ValueTask <bool>(filter.Any(school => string.Equals(school, spellBook.School, StringComparison.OrdinalIgnoreCase)))
         : new ValueTask <bool>(true));
 }