GM.dart is a library for digital board games that are still primarily designed to be played face-to-face (i.e. there's a tablet/laptop with the board in the center and everyone has their own hand of cards on their phone).
I still need to finish cleaning up and documenting the API, but basically, each board game consists of three elements: a GameEngine, one or more GameInterfaces and a GameManager. The GameEngine should contain the core logic of the game, while the GameInterface should handle user interaction. Both elements use the GameManager to communicate between one another.
A GameManager will generally use some sort of networking to communicate to remote GameInterfaces, though one could also be implemented to coordinate a pass-and-play game on one device.
While I plan to write more built-in GameManagers, so far the only one is SocketManager, which uses Web Sockets to handle events. server.dart provides a simple implementation of a server compatible with SocketManager. A single server can simultaneously support multiple games.
While the GameEngine and GameInterface should be written in tandem for each game, GameManagers are completely separate. The existing SocketManager should work for any game that wishes to use Web Sockets and the same games included in this repository should work with any properly written GameManager.
In order to demonstrate the library, I developed two samples during the hackathon: Guess the Number, a simple game for any number of players where you try to guess a number between 1 and 100, and The Hackers of Silicon, a somewhat simplified clone of Settlers of Catan for 3 or 4 players (plus an additional device to display the board).
The Dart code of both the library and the samples is available on GitHub. JS-compiled versions of the samples are linked above and should work on any browser that supports Web Sockets (the latest versions of all five major browsers do). You're welcome to play around with it, but the library definitely needs some polishing before it's ready for production. Once I clean it up, document it (and probably add a few more features), I'll upload it to Pub (Dart's package manager) so it can easily be included in projects.
Built With
- dart
- digitalocean
- web-sockets
Log in or sign up for Devpost to join the conversation.