Example #1
0
 def roll_skill_check(player, skill):
     """ 1d20 throw to check skill success """
     dice_roll = Dice.roll(die=1, sides=20)
     skill_modifier = player.get_attribute_modifier(
         skill.attribute_modifier)
     #Other skill misc. modifier
     return DiceRoll(dice_roll, skill_modifier)
Example #2
0
 def roll_saving_fortitude_throw(player):
     '''
     Saving throw from unusual/magic attack - physical attack, or vitality/health attack
     '''
     dice_roll = Dice.roll(die=1, sides=20)  #1d20
     constitution_modifier = player.constitution_modifier(
     ) + player.character_class.get_spell_save_fortitude(player)
     return DiceRoll(dice_roll, constitution_modifier)
Example #3
0
 def roll_perception_check(player):
     """ 
     Throw to check perception, such as mechanical trap detection
     1d20 + Wisdom modifier
     (Any other revlevant bonus needs to be added by calling function based on situation)
     """
     dice_roll = Dice.roll(die=1, sides=20)
     modifier = GameRules.get_attribute_modifier(player.wisdom)
     return DiceRoll(dice_roll, modifier)
Example #4
0
 def roll_initiative_check(player):
     '''
     Throw to check who responds first on encounter
     1d20 + dexterity modifier + any specific bonus
     '''
     dice_roll = Dice.roll(die=1, sides=20)  #1d20
     dexterity_modifier = GameRules.get_attribute_modifier(player.dexterity)
     iniative_bonus = player.initiative_bonus
     return DiceRoll(dice_roll, dexterity_modifier + iniative_bonus)
Example #5
0
 def roll_death_save(player):
     """ Saving throw on death """
     dice_roll = Dice.roll(die=1, sides=20)  #1d20
     if dice_roll == 20:
         player.heal(1)
         return True
     elif dice_roll >= 10:
         return True
     return False
Example #6
0
 def damage(self, player):
     if not player.character_class.is_skill_proficient(player, self):
         #Shouldn't be able to happen
         return 0
     dmg_dice = player.character_class.get_skill_damage(self, player.level)
     dmg = Dice.roll(dmg_dice[0], dmg_dice[1])
     #TODO is this right?
     mod = player.get_attribute_modifier([self.attribute_modifier])
     return dmg + mod
Example #7
0
 def roll_saving_spell_throw(spell, target):
     """ Saving throw from effect spell """
     dice_roll = Dice.roll(die=1, sides=20)  #1d20
     spell_modifier = 0
     try:
         spell_modifier = target.get_attribute_modifier(
             spell.saving_throw_attribute)
     except:
         pass
     return DiceRoll(dice_roll, spell_modifier)
Example #8
0
 def roll_weapon_attack_score(player):
     """ Returns critical_strike, 1D20 + ability modifier + proficiency bonus + any other attack bonus """
     #1d20 + ability_modifier + proficiency_bonus (if proficient) + any special attack bonus (like +1 on a weapon)
     attack_roll = Dice.roll(die=1, sides=20)  #1d20
     ability_modifier = player.determine_ability_modifier()
     proficiency_bonus = player.determine_proficiency_bonus()
     other_attack_bonus = player.other_attack_bonus
     return DiceRoll(
         attack_roll,
         ability_modifier + proficiency_bonus + other_attack_bonus)
Example #9
0
 def roll_weapon_throw_score(player):
     """ Returns critical_strike, 1D20 + weapon proficiency + weapon attack modifier """
     attack_roll = Dice.roll(die=1, sides=20)  #1d20
     ability_modifier = player.determine_ability_modifier()
     proficiency_bonus = player.determine_proficiency_bonus()
     other_attack_bonus = player.other_attack_bonus + player.determine_throw_bonus(
     )
     return DiceRoll(
         attack_roll,
         ability_modifier + proficiency_bonus + other_attack_bonus)
Example #10
0
    def __test_roll(self, rolls, die, sides):
        do_roll = (Dice.roll(die, sides) for x in range(rolls))
        result = {}

        #Test dice values are in the expected range
        for roll in do_roll:
            result[roll] = 1
            self.assertGreaterEqual(
                roll, die * 1,
                'Minimum roll. Die: %i, Sides: %i' % (die, sides))
            self.assertLessEqual(
                roll, sides * die,
                'Maximum roll. Die: %i, Sides: %i' % (die, sides))

        #Test every possible value has at least one entry
        for val in range(die, die * sides + 1):
            self.assertTrue(
                val in result.keys(),
                'Possible dice result exists, failed to find %i' % val)
Example #11
0
 def _damage(self, caster):
     dice = SpellStats.get_damage_dice(self)
     return Dice.roll(dice[0],dice[1])
Example #12
0
 def _mana(self):
     dice = PotionStats.get_mana_dice(self)
     return Dice.roll(dice[0], dice[1]) + dice[2]
Example #13
0
 def _damage(self, target):
     dice = PotionStats.get_damage_dice(self)
     return Dice.roll(dice[0], dice[1]) + dice[2]
Example #14
0
 def _damage(self, attacker):
     dice = WeaponStats.get_damage_dice(self)
     return Dice.roll(dice[0], dice[1])
Example #15
0
 def _damage(self, attacker):
     dmg = Weapon._damage(self, attacker)
     dice = WeaponStats.get_ammo_dice(self.__ammo)
     dmg += Dice.roll(dice[0], dice[1]) + dice[2]
     return dmg
Example #16
0
 def roll_spell_attack_score(spell, player):
     """ Returns dice roll (1D20) + spell modifier """
     attack_roll = Dice.roll(die=1, sides=20)  #1d20
     spell_modifier = spell.get_spell_attack_modifier(player)
     return DiceRoll(attack_roll, spell_modifier)
Example #17
0
 def is_thrown_item_lost():
     """50% chance of losing arrow"""
     return Dice.roll(1, 2) == 1
Example #18
0
 def roll_trap_attack_score(trap):
     """ Returns dice roll (1D20) + trap modifier """
     attack_roll = Dice.roll(die=1, sides=20)  #1d20
     trap_attack_bonus = trap.attack_bonus
     return DiceRoll(attack_roll, trap_attack_bonus)
Example #19
0
 def roll_saving_will_throw(player):
     """ Saving throw from unusual/magic attack - mental attack/magical effect """
     dice_roll = Dice.roll(die=1, sides=20)  #1d20
     wisdom_modifier = player.wisdom_modifier(
     ) + player.character_class.get_spell_save_will(player)
     return DiceRoll(dice_roll, wisdom_modifier)
Example #20
0
 def roll_saving_reflex_throw(player):
     """ Saving throw from unusual/magic attack - dodge area attack """
     dice_roll = Dice.roll(die=1, sides=20)  #1d20
     dexterity_modifier = player.dexterity_modifier(
     ) + player.character_class.get_spell_save_reflex(player)
     return DiceRoll(dice_roll, dexterity_modifier)
Example #21
0
 def determine_hit_points(dice, sides, bonus):
     return bonus + Dice.roll(dice, sides)