Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # give the player the ability to "talk" and touch things
- # if there is nothing to interact with, say that there is nothing
- if "interobj" not in self.location and "interper" not in self.location:
- dismiss_fx.play()
- print("There's nothing of interest here.")
- # proceed if there is
- else:
- # print the things that are in the room
- confirm_fx.play()
- print("In the area, these things stand out to " + self.name + ": ")
- if "interobj" in self.location:
- print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + self.location["interobj"])
- if "interper" in self.location:
- print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + self.location["interper"])
- # prompt the user to interact with one of the things
- interaction = input(colorama.Fore.CYAN + colorama.Style.BRIGHT + "nWhich do you want " + self.name + " to interact with?: ")
- # determine if the thing the user interacted with is in the location
- try:
- raise KeyError(interaction)
- except KeyError as e:
- if str(e) != self.location["interobj"]:
- raise
- elif interaction == self.location["interobj"]:
- # return whatever was noteworthy about the object
- confirm_fx.play()
- print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + self.location["intercom"])
- print("")
- checkprog(self,interaction)
- except KeyError as e:
- if str(e) != self.location["interper"]:
- raise
- elif interaction == self.location["interper"]:
- # return whatever the character had to say
- confirm_fx.play()
- print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + self.location["intersay"])
- print("")
- checkprog(self,interaction)
- except KeyError:
- # input is invalid
- invalid_fx.play()
- print(self.name + " couldn't find a '" + interaction + "'.")
- print("")
Add Comment
Please, Sign In to add comment