Exercise 45 Improving on Input Output text files

I have this idea with the game where the introduction screen. The player can input their name and if they want two options be a “fighter” or “wizard”. What I have come up with so far is, create a text file, either “fighter.txt” or “wizard.txt” that can later on be read() and split() using a delimiter to get what type of character will fighter the poor monster.

That seems to be ok, however on searching on the topic I have read that doing this way is bad which then made me think. How could it be done better, considering all scenes or rooms are in separated classes in separate .py files. Any ideas?

Not sure why that’s bad, but aren’t you using JSON already for your game? You can save the state of the game in a JSON file and load it each time. Totally works that way.

Hmmm, don’t think so, will look into it though. Cheers! Oh, I think I know what you mean, was a pure accident that I sent the gist file as Javascript. I think it might be time to take the plunge.

deleted the post, as I wanted to attack it with a fresh brain. :slight_smile:

Couldn’t implement .json dump but managed to use pickle instead

Yeah that works just fine.