Game<E extends Event> class abstract

Abstract class that all games must inherit from

Available Extensions

Constructors

Game()

Properties

generic GenericGame
generic game holding some commonly used state
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type GameType
Returns the name game type that is registered for serialization
no setter

Methods

copyWithGeneric(GenericGame updates(GenericGame)) Game<Event>
Copies the state of the game with generic replaced by the function applying updates to the most recent copy of generic
moveNextRound(GameConfig config) Game<Event>
Logic to apply after all players have consented they want to play another round to initialize the next round
next(E event) GameOrError<Game<Event>>
This method takes an event and returns the changed game state or an error
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes the state for consumption by the frontend
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

gameNames Map<GameType, String>
Stores the user friendly name of the game based on the type
final

Static Methods

fromJson(Map<String, dynamic> json) Game<Event>
Converts the game from json to the particular type based on the type field
gameEventFromJson(Map<String, dynamic> json) GameEvent
Returns the game event translated from json
getInitialState(GameConfig gameConfig, IList<Player> players) Game<Event>
Will get the initial state for a particular configuration
registerGameType<T extends Game<Event>, Q extends Game<Event>>(GameType type, {required String name, required Q fromJson(Map<String, dynamic>), required T initialState(GameConfig, IList<Player>), required GameEvent gameEventFromJson(Map<String, dynamic>), Q toClientView(T)?}) → void
Registers a game type with the server
toClientView(Game<Event> g) Game<Event>
Optionally converts the game from a full game state to a view of the game from the client's perspective