I'm trying to make a simple program for my own personal use. It's a randomization program that I want to randomize both the Mastery (in this game's case, Grim Dawn, that's basically a class) and the Active Skill to level up and focus on using primarily. My goal with this program is to add some variety to the game by playing builds that I wouldn't regularly play due to them being randomly chosen for me.
Here's the first part of my program:
import random
import keyboard
print("Press enter to randomize your first mastery:")
while True:
if keyboard.is_pressed("enter"):
with open('masteries.txt', 'r') as f:
masteries = f.readlines()
random_mastery1 = random.choice(masteries)
print(random_mastery1)
break
This does exactly what I want it to do: Reads the game's classes from masteries.txt and outputs one of them randomly.
Next I have the following line of code:
print("Press enter to randomize your active skill for the {} mastery".format(random_mastery1))
What I want to happen is, based on the random Mastery that was selected from the masteries.txt file, it will then retrieve a random Active Skill from the corresponding Active Skill .txt file. For example, let's say that the randomly chosen Mastery was Soldier, I would like for it to choose an Active Skill randomly from the soldieractiveskills.txtfile.
I've been researching on a decent way to do this, but I'm pretty stuck. It looks like there's a way to do this with variables, but I can't figure it out. Any input?
Aucun commentaire:
Enregistrer un commentaire