I am new to python and want to write a simple text adventure game. The player enters a tavern and interacts with the guests. The game takes place in a fantasy setting, where there are multiple races. I want to randomly generate each guest and then interact with them in the tavern. Here is my simplified code:
import random
class guest:
def __init__(self,race,name,mood):
self.race = race
self.name = name
self.mood = mood
def humannames():
human_names_choice = ('Mark','Joe','Bill')
return random.choice(human_names_choice)
def orcnames():
orc_names_choice = ('Ug','Orok','Ushnar')
return random.choice(orc_names_choice)
def humanmoods():
human_moods_choice = ('entertained','disgusted','pleased')
return random.choice(human_moods_choice)
def orcmoods():
orc_moods_choice = ('drunk','pissed off','angry')
return random.choice(orc_moods_choice)
guest_human = guest('human',humannames(),humanmoods())
guest_orc = guest('orc',orcnames(),orcmoods())
allguests = [guest_human,guest_orc]
guest1 = random.choice(allguests)
print('You meet a ' + guest1.race + ' named ' + guest1.name + '. He seems ' + guest1.mood)
So far so good. With this system i can add many more races,names etc. later. My problem is the following:
It is logical, that guest1.name and guest.race never change. If i print the last statement 5 times in a row, i will get the same results, because the values are set at the start. This is good for me, because those things should never change. With guest1.mood however it is more complicated. A tavern guest doesnt always have the same mood, it changes over time.
Question: How can i keep guest1.name and guest.race static but get a new random mood everytime the player meets the same guest again later?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire