private void StockShop() { var wandBuilder = new WandCreator(); Repeat.Times(100, () => this.inventory.Add(wandBuilder.Process())); var potionCreator = new PotionCreator(); Repeat.Times(100, () => this.inventory.Add(potionCreator.Process())); }
public void SelectAPotionFromAListOfSpellsAndChargesProperly(int level, int value) { var spellList = SpellList.CreateForTesting("cleric"); spellList.Add(level, "Cure Light Wounds"); var cureSpell = new Spell("Cure Light Wounds", "healing"); var spellLists = EntityGateway <SpellList> .LoadWithSingleItem(spellList); var spells = EntityGateway <Spell> .LoadWithSingleItem(cureSpell); var potionCreator = new PotionCreator(spellLists, spells); var potion = potionCreator.Process(); Assert.Equal(cureSpell, potion.Spell); Assert.Equal(value, potion.Value); }
public void MaxSpellLevelIsLevel3() { var spellList = SpellList.CreateForTesting("cleric"); spellList.Add(1, "Cure Light Wounds"); spellList.Add(4, "Cure Serious Wounds"); var cureSpell = new Spell("Cure Light Wounds", "healing"); var cureSeriousSpell = new Spell("Cure Serious Wounds", "healing"); var spellLists = EntityGateway <SpellList> .LoadWithSingleItem(spellList); var spells = EntityGateway <Spell> .LoadFromList(new Spell[] { cureSpell, cureSeriousSpell }); var potionCreator = new PotionCreator(spellLists, spells); var potion = potionCreator.Process(); //Always equals cureSpell Assert.Equal(cureSpell, potion.Spell); }
public MainMap(Hero myHero, Weapon mainWeapon, Armor armor, Skill skill) { // // CREATING POTIONS USING FACTORY METHOD PATTERN // PotionCreator[] creators = new PotionCreator[2]; List <Consumable> potions = new List <Consumable>(); creators[0] = new HealthPotionCreator(); creators[1] = new DamagePotionCreator(); foreach (PotionCreator creator in creators) { Consumable product = creator.FactoryMethod(); potions.Add(product); } potions[0].Avatar = new BitmapImage(new Uri("../Images/HPpotion.png", UriKind.RelativeOrAbsolute)); potions[1].Avatar = new BitmapImage(new Uri("../Images/potion.png", UriKind.RelativeOrAbsolute)); this.Myhero = myHero; this.MainWeapon = mainWeapon; this.Armor = armor; this.Skill = skill; this.Enemy1 = new Enemy("Ork", 25, 23, new Trophy("Amulet", "Ancient Amulet", new BitmapImage(new Uri("../Images/amulet.png", UriKind.RelativeOrAbsolute))), new BitmapImage(new Uri("../Images/ork.png", UriKind.RelativeOrAbsolute))); this.Enemy2 = new Enemy("Wolf", 25, 32, potions[0], // using one of the potions here, as Loot for an Enemy new BitmapImage(new Uri("../Images/shadow.png", UriKind.RelativeOrAbsolute))); this.Treasure = new Trophy("Crocs", "Ugly Shoes", new BitmapImage(new Uri("../Images/crocs.png", UriKind.RelativeOrAbsolute))); this.DataContext = this; InitializeComponent(); SetAvatars(); }