Skip to content
Settlers Journal
Go back

Polishing and Completing the React Proof of Concept

Edit page

TLDR

Polishing the React proof of concept so that it can be a standalone project that is “finished” and does not take up more of my time. Creating a clean design for a single interactive use case (player placing a road). Creating a clean design for optimistically updating the UI and then syncing with server state.

alt text

Landing page.

alt text

User can select a location to place a road.

alt text

UI has optimistically updated and placed a road in the desired location.

alt text

UI syncs its state with the backend server response, either removing the placed road or validating it.

if (await mockPlaceRoad()) {
  // change to final road color and keep other roads removed
  setPendingRoadColor(BoardColor.PLAYER_RED);
  setGameStateOverride({
    currentAction: GameAction.DEMO,
    currentPlayer: PlayerColor.BLUE,
    removedEdgeIds,
  });
  updateActivityLog(
    `API call to place road on ${edgeId} succeeded. No rollback needed. Game state advanced.`
  );
} else {
  // revert everything to original state
  setPendingRoadId(null);
  setPendingRoadColor(null);
  setGameStateOverride({});
  updateActivityLog(
    `API call to place road on ${edgeId} failed (50% chance). Rolling back to original state.`
  );
}

Main work

Challenges

Learnings


Edit page
Share this post on:

Next Post
Hosting the Settlers Journal On a Static Website