registerGameType<T extends Game<Event> , Q extends Game<Event> > static method
void
registerGameType<T extends Game<Event> , Q extends Game<Event> >(})
Registers a game type with the server
Implementation
static void registerGameType<T extends Game, Q extends Game>(
GameType type, {
required String name,
required Q Function(Map<String, dynamic>) fromJson,
required T Function(GameConfig, IList<Player>) initialState,
required GameEvent Function(Map<String, dynamic>) gameEventFromJson,
Q Function(T)? toClientView,
}) {
if (!_generalIsRegistered) {
_generalIsRegistered = true;
_registerGeneralEvents();
}
gameNames[type] = name;
_fromJsonFactory[type] = fromJson;
_eventFromJsonFactory[type] = gameEventFromJson;
_initialStates[type] = initialState;
_toClientViews[type] = (toClientView as Game Function(Game)?) ?? (g) => g;
}