Game client written as a React application using Redux for game state management.
For simplicity, both
P1
andP2
roles share the same (UI) implementation, achieved by defining higher-order components to minimise the duplication. It would be perfectly reasonable to provide different implementations ofP2
.
This project was bootstrapped with Create React App.
npm start
- Starts the development server
This contains the session types and runtime generated from the Scribble protocol.
Enums defined for the client roles and message labels. Can be reused by the user in their implementation.
User-defined payloads not generated by the toolchain.
Encoding of states and transitions of the P1
EFSM.
Example of a send state.
The following props are supported:
Pos: SendComponentFactory<Point>
- Parameters:
- Event, e.g. 'Click', 'Hover'
- Event handler - a function that consumes the
UIEvent
and returns aPoint
to send
- Returns:
- A React component that will invoke the event handler and send the result as a
Pos
message when the event is triggered.
- A React component that will invoke the event handler and send the result as a
- Parameters:
Example of a receive state.
Abstract methods to be implemented:
abstract Win(point: Point): void
- handle aWin
messageabstract Draw(point: Point): void
- handle aDraw
messageabstract Update(point: Point): void
- handle aUpdate
message
Example of a terminal state.
Session runtime, to be rendered by the user in order to instantiate the session.
The following props are supported:
endpoint: string
- URL of WebSocket server to connect to
states: [Constructor<S31>, Constructor<S32>, Constructor<S33>, Constructor<S34>]
- List of concrete user implementations of each EFSM state
waiting: JSX.Element
- Component to render when the client is waiting for the server to announce that the session has began
Encoding of states and transitions of the P2
EFSM, similar to above.
Client-side state management for the game written in typical Redux fashion.
Game board implemented as a React component, connected to the Redux store to access the game state and render accordingly.
Contains the concrete user implementations of each EFSM state.