In the Text101 project, the ManageState method will throw an “index out of bounds” exception if the user presses the “3” key in a room with less than three exits. My solution was to check the length of the array before trying to read from it.
In a simple program with three possible inputs and a handful of states, the solution only required modifying a single line of code. But in a large program with dozens of inputs and millions of possible states, it would be almost impossible to deal with.
In general, how do I prevent players from breaking my games by doing things they’re not supposed to?