matteoferla / DnD-battler

A 5e D&D encounter simulator written for my own amusement to test some hypotheses.
MIT License
80 stars 31 forks source link

ValueError: invalid literal for int() with base 10: 'g' #14

Open RichardScottOZ opened 2 years ago

RichardScottOZ commented 2 years ago

I installed the dev branch

Running the example in the README

from DnD_battler import Creature, Encounter
Creature.load('aboleth') # get from beastiary
level1 = Creature(name="buff peseant", abilities = {'str': 15,'dex': 14,'con':13,'int':12,'wis':10,'cha': 8}, alignment ="good", attack_parameters=['longsword'])
Mismatch with ability con: bonus=0, score=15
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_11496/439451731.py in <module>
      1 from DnD_battler import Creature, Encounter
      2 Creature.load('aboleth') # get from beastiary
----> 3 level1 = Creature(name="buff peseant", abilities = {'str': 15,'dex': 14,'con':13,'int':12,'wis':10,'cha': 8}, alignment ="good", attack_parameters=['longsword'])
      4 #billybob = Creature("lich")
      5 #billybob.alignment = "good"  #the name of the alignment means only what team name they are in.

j:\clone\dnd-battler\DnD_battler\creature\_adv_base.py in __init__(self, **settings)
     10     def __init__(self, **settings):
     11         super().__init__()
---> 12         self.apply_settings(**settings)
     13 
     14     @classmethod

j:\clone\dnd-battler\DnD_battler\creature\_adv_base.py in apply_settings(self, **settings)
     71         # attacks
     72         if 'attack_parameters' in settings or 'attacks' in settings:
---> 73             self.attacks = self.parse_attacks(**settings)

j:\clone\dnd-battler\DnD_battler\creature\_level.py in parse_attacks(self, attacks, attack_parameters, **others)
     65             if isinstance(attack_parameters, str):
     66                 attack_parameters = json.loads(attack_parameters)
---> 67             return [AttackRoll.parse_list_attack(attack, self.str) for attack in attack_parameters]
     68         else:
     69             return []

j:\clone\dnd-battler\DnD_battler\creature\_level.py in <listcomp>(.0)
     65             if isinstance(attack_parameters, str):
     66                 attack_parameters = json.loads(attack_parameters)
---> 67             return [AttackRoll.parse_list_attack(attack, self.str) for attack in attack_parameters]
     68         else:
     69             return []

j:\clone\dnd-battler\DnD_battler\dice\attack_roll.py in parse_list_attack(cls, attack, ability_die)
     44         return cls.parse_attack(name=attack[0],
     45                                 ability_die=ability_die,
---> 46                                 damage_dice=Dice(num_faces=[int(n) for n in attack[3:]], bonus=attack[2]),
     47                                 attack_modifier=attack[1])
     48 

j:\clone\dnd-battler\DnD_battler\dice\attack_roll.py in <listcomp>(.0)
     44         return cls.parse_attack(name=attack[0],
     45                                 ability_die=ability_die,
---> 46                                 damage_dice=Dice(num_faces=[int(n) for n in attack[3:]], bonus=attack[2]),
     47                                 attack_modifier=attack[1])
     48 

ValueError: invalid literal for int() with base 10: 'g'

Haven't tried debugging it yet, will take a bit of time to work out what is doing what.

RichardScottOZ commented 2 years ago

Is this that the 'longsword' is just an example and it needs to parse a type of damage string? 1d8 etc?

RichardScottOZ commented 2 years ago

Or looking in the code, like this?

attack_parameters=[['longsword', 4, 2, 8]])
matteoferla commented 2 years ago

The reason is that the 'armory' was temporarily removed in the dev branch as I am hoping to have it as a json with more details —e.g. finesse. For now equip_standard_weapon is still not an instance method and weapons is a dict of int for now as previously. The former is solely so that it looks odd and reminds future me of the issue.

RichardScottOZ commented 2 years ago

Right!