Game Over
Explore how to manage the game over state in Elixir state machines by modeling permissible events, handling state transitions, and ensuring error responses for invalid actions. This lesson helps you understand how to structure and control complex application states within your functional Elixir applications.
We'll cover the following...
The end state
State machines often, but not always, have an end state. This is a state from which we can’t transition. In Islands, we have an end state called :game_over.
We won’t need any new check/2 clauses for the :game_over state because there are no new actions to add to the whitelist. The catchall clause returns an error no matter what we try to do when the state is :game_over.
At this point, we can see our state machine make it through all the states and try all the events.
New IEx session
Let’s start a new IEx session, get a new rules struct, and make sure it’s in the ...