I can see what you are trying to do and I offer you this, as a starter:
# don't import everything, if you only need one function
from random import randint
# option to have a pause, so that the fight lasts a number of seconds
from time import sleep
creatures = {
1 : ['Golem', 3, 100],
2 : ['Ogre', 4, 100],
3 : ['Minotaur', 6, 100]
}
players = {
1 : ['Shawn', 0, 100],
2 : ['Alice', 0, 100],
3 : ['Bob', 0, 100]
}
weapons = {
1 : ['a pointed stick', 1, 10],
2 : ['a short knife', 3, 10],
3 : ['a long knife', 4, 10],
4 : ['a short sward', 5, 10],
5 : ['a long sward', 6, 10],
6 : ['a bow and arrows', 8, 10]
}
# indices
name = 0
damage = 1
health, usage = 2, 2
# get a random player and weapon
player = players.get(randint(1,len(players)))
weapon = weapons.get(randint(1,len(weapons)))
weaponName = weapon[name]
playerDamage = weapon[damage]
# get a random creature
creature = creatures.get(randint(1,len(creatures)))
creatureName = creature[name]
creatureDamage = creature[damage]
print(f"{player[name]} has {weaponName} and will be fighting a {creatureName}")
Don’t Panic! The above code is not as complicated as you may think, at first glance, and is designed to be extendable: you can add players, weapons, and creatures, without any change to the main body of the code; simply add to the dictionaries. The first number is a damage rating and the second number is a health rating. For the weapons, the ‘health rating’ can be seen as a ‘usage’, which should be reduced by one, each time the weapon is used, so each weapon can only be used 10 times; change this as you see fit. e.g: maybe ‘a pointed stick’ should only be used four times.
I think that the ‘hit’ should be a random number between zero and four: if ‘hit’ is zero, then it’s a ‘miss’, any other value being a ‘hit’.
Then, who goes first?
A ‘coin flip’ would be: choose = randint(0,1)
So, we now have the scene set, ready for the fight to commence. I’ll not take this any further for now, because:
- You may not understand any of this or even like it
- You may want to develop this in your own way, which would be a better learning experience
You can use any of this, all of this or none of this; it’s your choice. You may even want to wait and see what others have to say. I’m not a coding expert, but this is how I would set out, if I were to start this kind of a project.