-
Notifications
You must be signed in to change notification settings - Fork 0
Implementing a Game Engine
Game engines currently run along with the Laink server, in the same process, and so (for now) must be written in Ruby. See domohnoes.rb for an example game.
In the future these should move to a separate process using the same communication framework, turning the server into a lightweight broker for setting up games. This will require games to support n reader threads for n players, instead of the server doing this.
To add a new game type supported by the server:
-
requirethegametype.rbfile. -
Create a new class that subclasses
Laink::GameType. -
Add the required method calls:
gametype "com.danceliquid.domohnoes" # The unique signature identifying this game type name "Domohnoes" # A nice name for your game players 2..4 # The number of players supported (may be an integer or range) -
[optional] Provide an
initializemethod that callssuper(). -
[optional] Provide a
startmethod that callssuper(). -
Provide a
current_playermethod that returns the appropriate item from theplayersarray -
Provide a
statemethod that, given a player from theplayersarray, returns an object that supportsto_jsonand describes everything a player would need to know to make a move. (And nothing they shouldn't know!) -
Provide a
handle_message(message,player)method that either processes the message or callssuper. Most important, be able to handle{"command":"move"}messages. -
Call
finish_game(winning_player)on the superclass when the game is over.