Game<E extends Event> class
Null safety
Abstract class that all games must inherit from
- Available Extensions
Constructors
- Game()
Properties
- generic → GenericGame
-
generic game holding some commonly used state
read-only
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- type → GameType
-
Returns the name game type that is registered for serialization
read-only
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 non-existent 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
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, ISet< 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, ISet<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