Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13981

How to make tables of information for variables

$
0
0

I'm learning Python and making a Dungeons & Dragons-based text-based game. I'm curious if there's a way to make a table or something so I don't have to specify the same variables (enemy_ac, enemy_hp, etc.) every time for each creature.

#Function to spawn an enemydef encounter():    global enemy    global enemy_weapon    global enemy_ac    global enemy_hp    global enemy_attack_mod    global enemy_damage_mod    global enemy_exp    #print("Debug: Running Encounter Function")    chance_encounter = randint(1,100)    if chance_encounter in range(90,96):        enemy = "Orc"        enemy_weapon = "Greataxe"        enemy_ac = 13        enemy_hp = 15        enemy_attack_mod = 5        enemy_damage_mod = 3        enemy_exp = 100        print("An Orc howls in bloodlust as it brings its Greataxe to bare!!")        print("")    elif chance_encounter >= 97:        enemy = "Worg"        enemy_weapon = "Bite"        enemy_ac = 13        enemy_hp = 26        enemy_attack_mod = 5        enemy_damage_mod = 3        enemy_exp = 100        print(r"""                          ,               ,,/( ,,,,,,,,,,___,,              )b     ,,,           "`,_,             /(     /                   `,            L/7_/\,,|            /        \             ,`      `,  \     ,|          \              ,      /  /``````||      |\,  \__,)))                    /  / |      \\     \  \,,,,,,/                   |  /  |       \\   )/                   \ (|  )     ,,//   /                    `_)_/     ((___/"'""")        print("A Worg is released into the arena!!")        print("")    else:        enemy = "Goblin"        enemy_weapon = "Scimitar"        enemy_ac = 15        enemy_hp = 7        enemy_attack_mod = 4        enemy_damage_mod = 2        enemy_exp = 50        print(r"""              /(.-""-.)\                |\  \/      \/  /|            | \ / =.  .= \ / |            \( \   o\/o   / )/             \_, '-/  \-' ,_/                /   \__/   \                  \ \__/\__/ /                ___\ \|--|/ /___            /`    \      /    `\          /       '----'       \""")        print ("A frenzied Goblin charges you with a Scimitar!!")

Any advice appreciated - thanks!

Not sure how to even start approaching this... Googling around.


Viewing all articles
Browse latest Browse all 13981

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>