def setUp(self): HERO.inventory = inventory.Inventory() HERO.inventory.add_items( items.Potion(), items.Ether(), items.ProteinShake(), items.RedBull(), items.Molotov(), items.ManaCleaner(), items.VodkaShots(), items.MegaPhone(), )
def _set_options(self): """ Set the available items to buy, dependent upon hero level.""" options = { "1": items.Potion(), "2": items.Ether(), "3": items.ManaCleaner(), "4": items.MegaPhone(), } if self.hero.lv >= 10: lv10_options = {"5": items.ProteinShake(), "6": items.RedBull()} options = merge_two_dicts(options, lv10_options) if self.hero.lv >= 15: lv15_options = {"7": items.Molotov()} options = merge_two_dicts(options, lv15_options) if self.hero.lv >= 20: lv20_options = {"8": items.VodkaShots()} options = merge_two_dicts(options, lv20_options) return options
def test_add_items(self): HERO.inventory.add_items( items.Potion(), items.Ether(), items.ProteinShake(), items.RedBull(), items.Molotov(), items.ManaCleaner(), items.VodkaShots(), items.MegaPhone(), ) hero_items = sorted([x.name for x in HERO.inventory]) expected = [ "Potion", "Ether", "Protein Shake", "Red Bull", "Molotov Cocktail", "Mana Cleaner", "Mega Phone", "Vodka Shots", ] self.assertEqual(hero_items, sorted(expected))
def test_selling_cost(self): old_gold = hero.gold STORE.sell(items.Potion()) difference = hero.gold - old_gold self.assertEqual(difference, items.Potion().sell)
def test_selling_transfer(self): old_inv_len = len(hero.inventory) STORE.sell(items.Potion()) new_inv_len = len(hero.inventory) self.assertEqual(new_inv_len, (old_inv_len - 1))
def test_buying_cost(self): old_gold = hero.gold STORE.purchase(items.Potion()) difference = old_gold - hero.gold self.assertEqual(difference, items.Potion().cost)
def test_buying_transfer(self): STORE.purchase(items.Potion()) inv_list = [x.name for x in hero.inventory] self.assertTrue("Potion" in inv_list)
def test_limit(self): HERO.inventory.add_items(items.Potion()) self.assertTrue(HERO.inventory.full)
def test_extract_item(self): potion = HERO.inventory.extract_item("Potion") self.assertEqual(potion.name, items.Potion().name)