my goal is to create an army manager for the tabletop game mythras, where each soldier has their own hp, attack value, etc, that i can use to add detail to the large scale battles. i want to be able to direct commands to it (eg, 'damage 3 soldiers') and have it randomly determine which soldier is attacked, how much damage it does, and whether it kills them (as well as how it heals up, following the standard healing rules). I don't have a lot at the moment at all, just a dictionary that contains a nested dictionary for each soldier's hp and attack value, randomly determined:
from random import randint
Soldier1 = {
"HP" : randint(1,10),
"ATK" : randint(1,10),
}
Soldier2 = {
"HP" : randint(1,10),
"ATK" : randint(1,10),
}
Soldier3 = {
"HP" : randint(1,10),
"ATK" : randint(1,10),
}
myArmy = {
"Soldier 1" : Soldier1,
"Soldier 2" : Soldier2,
"Soldier 3" : Soldier3
}
print(myArmy)
from random import randint
Soldier1 = {
"HP" : randint(1,10),
"ATK" : randint(1,10),
}
Soldier2 = {
"HP" : randint(1,10),
"ATK" : randint(1,10),
}
Soldier3 = {
"HP" : randint(1,10),
"ATK" : randint(1,10),
}
myArmy = {
"Soldier 1" : Soldier1,
"Soldier 2" : Soldier2,
"Soldier 3" : Soldier3
}
print(myArmy)
now, that works fine for the three soldiers listed there, but i don't need 3 soldiers, i need 300. how can i input a number and have it create that many soldiers on the fly?
and, further to that, are dictionaries the best choice for this? i know the technical difference between dictionaries and classes, but i don't have any real-world context to either to know which is best for what i need.