def test_Damage(self): play = Player('Greg') bp = play.backpack bp.weapons.append(Weapon('sword', 20, lambda: Dice.eight_sided(), True)) dam = play.get_damage_inflicted() print(str.format("Damage: {}", dam)) self.assertTrue(1 <= dam <= 8)
def get_initial_hit_points(self): bonus = pu.BONUS_PENALTIES[self.attributes.constitution] bonus = bonus if bonus > 0 else 0 return Dice.eight_sided() + bonus
def get_saving_throw(self, versus_attack)->bool: roll = Dice.twenty_sided() return (roll >= Fighter.SAVING_THROWS[versus_attack]), roll
def make_hit(roll: int): return Dice.twenty_sided() > roll
def make_goblin(gname: str) -> Monster: monster = Monster(name=gname, damage=lambda: Dice.eight_sided(), armour=6, xpvalue=1) monster.init_hp(6) monster.wallet = Wallet(gold=Dice.eight_sided()) return monster
def create_fighter(name: str) -> Fighter: fighter = Fighter(name, pu.roll_attributes(3)) fighter.backpack.weapons.append(Weapon('sword', 20, lambda: Dice.six_sided(), True)) fighter.backpack.armors.append(Armor("mail", 10, 5, True)) return fighter
def fighter_initiative(dexterity) -> bool: return Dice.twenty_sided() + pu.BONUS_PENALTIES[dexterity] > GOBLIN_INITIATIVE
def test_weapon(self): weapon = Weapon('sword', 20, lambda: Dice.eight_sided()) print(str.format('Attack1 = {0}', weapon.get_damage())) print(str.format('Attack2 = {0}', weapon.get_damage())) self.assertIsNotNone(weapon)