I am trying to create a weapon that provides random damage. I am doing so using an item database in the form
itemsList = {
1: {"name": "Padded Armor", "armor": 1, "value": 5, "class": "Light"},
2: {"name": "Leather Armor", "armor": 2, "value": 10, "class": "Light"},
....
19: {"name": "Dagger", "damage" : int(random.randrange(1, 4)), "value": 2, "Type": "Dagger"},
20: {"name": "Dagger + 1", "damage" : int(random.randrange(1, 4) + 1), "value": 200, "Type": "Dagger"},
21: {"name": "Dagger + 2", "damage" : int(random.randrange(1, 4) + 2), "value": 750, "Type": "Dagger"},
22: {"name": "Dagger + 3", "damage" : int(random.randrange(1, 4) + 3), "value": 2000, "Type": "Dagger"}
}
Every time I attempt to call "damage"
it just returns the same result. I understand that this is because the random number is generated one and then saved to that dictionary key.
How would I go about generating a random number every time damage is called?
Aucun commentaire:
Enregistrer un commentaire