tested version of character et al

This commit is contained in:
bw-mutley
2022-03-19 15:09:04 -03:00
committed by GitHub
parent 062adafe6a
commit 6f6905f1ce
3 changed files with 4 additions and 9 deletions
+2 -2
View File
@@ -1000,7 +1000,7 @@ class Character(Creature):
f"Companion '{beast}' not found. Please add it to" f"Companion '{beast}' not found. Please add it to"
" ``monsters.py``" ) " ``monsters.py``" )
beast = self._resolve_mechanic(beast, monsters.Monster, msg) beast = self._resolve_mechanic(beast, monsters.Monster, msg)
self.Ranger.ranger_beast = (beast, self.proficiency_bonus) self.Ranger.ranger_beast = (beast(), self.proficiency_bonus)
@property @property
def companions(self): def companions(self):
@@ -1019,7 +1019,7 @@ class Character(Creature):
f"Companion '{compa}' not found. Please add it to" f"Companion '{compa}' not found. Please add it to"
" ``monsters.py``" ) " ``monsters.py``" )
new_compa = self._resolve_mechanic(compa, monsters.Monster, msg) new_compa = self._resolve_mechanic(compa, monsters.Monster, msg)
companions_list.append(new_compa) companions_list.append(new_compa())
# Save the updated list for later # Save the updated list for later
self._companions = companions_list self._companions = companions_list
+1 -6
View File
@@ -21,7 +21,7 @@ def read_dice_str(dice_str):
""" """
dice_str = dice_str.replace(" ", "").replace("\n", "") dice_str = dice_str.replace(" ", "").replace("\n", "")
match = dice_re.match(dice_str) match = dice_re.search(dice_str)
if match is None: if match is None:
raise DiceError(f"Cannot interpret dice string {dice_str}") raise DiceError(f"Cannot interpret dice string {dice_str}")
num, faces = int(match.group(1)), int(match.group(2)) num, faces = int(match.group(1)), int(match.group(2))
@@ -79,8 +79,3 @@ def dice_roll_mean(dice_text):
dice = read_dice_str(dice_text) dice = read_dice_str(dice_text)
return round(_dice_mean(dice)) return round(_dice_mean(dice))
if __name__ == "__main__":
ds = "10d12+10"
v = read_dice_str(ds)
print(v)
print(_dice_mean(v))