示例#1
0
def reset_hero_attributes(hero: Hero):
    from items.weapon import Weapon
    from items.spell import Spell
    hero.health = hero.MAX_HEALTH
    hero.mana = hero.MAX_MANA
    hero.weapon = Weapon.create_weapon(random.choice(WEAPON_NAMES))
    hero.spell = Spell.create_spell(random.choice(SPELL_NAMES))
    def create_hero(cls):
        # add except
        name = input('Hero name: ')
        title = input('Hero title: ')

        weapon = Weapon.create_weapon(random.choice(WEAPON_NAMES))
        spell = Spell.create_spell(random.choice(SPELL_NAMES))

        return cls(name=name, title=title, weapon=weapon, spell=spell)
    def test_if_create_spell_class_method_creates_a_Spell_instance(self):
        s = Spell.create_spell('Fireball')
        range_damage = range(1, 21)
        range_mana_cost = range(1, 11)
        range_cast_range = range(1, 4)

        self.assertEqual(Spell, type(s))
        self.assertEqual(s.name, 'Fireball')
        self.assertTrue(s.damage in range_damage)
        self.assertTrue(s.mana_cost in range_mana_cost)
        self.assertTrue(s.cast_range in range_cast_range)
示例#4
0
def generate_random_value_of_treasure(treasure: str):
    from items.weapon import Weapon
    from items.spell import Spell

    dict_treasure_values = {
        'health': random.randint(1, 20),
        'mana': random.randint(1, 20),
        'weapon': Weapon.create_weapon(random.choice(WEAPON_NAMES)),
        'spell': Spell.create_spell(random.choice(SPELL_NAMES))
    }

    treasure_value = dict_treasure_values[treasure]
    return treasure_value