TLDR
Writing validation logic for the PLACE_FREE_SETTLMENT action, which requires checking the current game’s graph state. Returning 409 if the requested action is illegal.
Rough ideas about how state transitions would work.
Determining which indices would be illegal to place a settlement at.
Returning 409 if an invalid index was chosen.
Main work
- In
CatanGraphService, checking if settlement indices are already taken. - In
CatanGraphService, checking if settlement indices are adjacent to taken settlements.
Challenges
PLACE_SETTLEMENTis the first action that could result in two different next states. We now have to think about how we could determine the correctTransitionout of the complete list that referencePLACE_SETTLEMENT. Or, we need to move the next state update responsibility into eachAction’s logic.- We’re now at the point where a more wholistic error/exception strategy will be needed. Attempting an invalid action, like placing a settlement in an illegal location, has nuance.
Learnings
- IntelliJ debugger is really nice for adding watches and evaluating partial expressions.
- Relying on functional patterns like the Stream API can make direct breakpoints impossible sometimes. This is the one of the biggest negatives of the
StreamAPI, in my opinion.
- Relying on functional patterns like the Stream API can make direct breakpoints impossible sometimes. This is the one of the biggest negatives of the