NPlayer

The NPlayer Service provides helpers RPCs for ensuring round-robin turn taking among the roles in the project’s room.

Each role will receive a “start game” message at the start and then “start turn” message when it is the given role’s turn to act.

RPCS

NPlayer.endTurn(next: String?)

End your current turn.

Arguments:

  • next: String? (String) - Specify the player to go next

NPlayer.getActive()

Get the player whose turn it currently is.

Returns: String (String) - role id of the active player, or empty string if there are no players

NPlayer.getN()

Get the number of detected players in the game.

Returns: Integer (Integer) - number of players

NPlayer.getNext()

Get the player who will be active next.

Returns: String (String) - role id of the next player, or empty string if there are no players

NPlayer.getPrevious()

Get the player who played last.

Returns: String (String) - role id of the previous player, or empty string if no previous player

NPlayer.start()

Start a new turn-based game.

Returns: Boolean (Boolean) - true on successful start