This exercise is very very long, it’s ~260 lines of code, so I’m not going to post the whole list of codes here. You can check it out on my github at the above link if you wish to compare it.
What I’ve posted is my work that I’ve modified for the cheat.
1. Change it! Maybe you hate this game. Could be too violent, you aren’t into sci-fi. Get the game working, then change it to what you like. This is your computer, you make it do what you want.
I’ll work on a new game after studying this exercise more.
2. I have a bug in this code. Why is the door lock guessing 11 times?
Because we didn’t include the 1st attempt as a count, simply change guesses = 1, instead of 0.
3. Explain how returning the next room works.
A while statement is in the play() function, as long as the current scene is not finished. It will loop and run the next scene.
4. Add cheat codes to the games so you can get past the more difficult rooms. I can do this with two words on one line.
I could not figure out how to use multiple logic operators in one line, for example, while guess != code && guesses < 10, how could I make this? while guess != code || “cheat” && guesses < 10. Anyone have any idea how to put the cheat with 2 words on one line?
However, I did create a cheat function shown on my pictures. that would allow me to pass the level by typing in “cheat”. I had to remove the to_i and converting the number generator into a string, because to_i converts any string I typed in, for example “cheat” into 0, which renders my cheat function useless.
5. Go back to my description and analysis, then try to build a small combat system for the hero and the various Gothons he encounters.
Will place this system into my new game.
6. This is actually a small version of something called a “finite state machine.” Read about them. They might not make sense but try anyway.
It’s basically saying everything has a finite amount of state. Here’s a good video to explain it. https://www.youtube.com/watch?v=hJIST1cEf6A