Skip to content
Settlers Journal
Go back

Implementing the New FSM Transition Design with Regression Testing

Edit page

TLDR

Continuing to implement the new Transition / Finite State Machine design. Regression testing by manually running scripts and verifying board state.

Test coverage baseline - redesign allows for much easier testing and less code duplication / misdirection.

alt text

Logic from Glides being moved into updated Transitions.


public class TransitionRollForOrderRollPlaceFreeSettlement extends TransitionBase {

  public TransitionRollForOrderRollPlaceFreeSettlement() {
    super(StateEnum.ROLL_FOR_ORDER, ActionEnum.ROLL, StateEnum.PLACE_FREE_SETTLEMENT);
  }

  @Override
  boolean canUpdateState(CatanGame catanGame, Map<String, String> parameters) {
    return catanGame.getStateEnum() == getStartStateEnum()
        && catanGame.getPlayers()
        .stream()
        .filter(p -> p.getTurnOrderRollResult() != null)
        .count() == catanGame.getPlayers().size() - 1;
  }

  .
  .
  .

}

Main work

Challenges

Learnings


Edit page
Share this post on:

Previous Post
Writing Unit Tests for PlaceSettlementAction
Next Post
Simplifying the FSM by Removing Glides and Adopting ActionEnum.NOOP