GameManager class
Interface used to send events and read updates to the room and game state.
Constructors
- GameManager({required Player player})
Properties
- game → Game?
-
Get currently assigned room's game.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- player → Player
-
Device's player.
final
-
roomDataStream
→ Stream<
RoomData> -
Get stream to read RoomData changes.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createRoom(
Game game, [String? password]) → Future< bool> - Create a new room and join it.
-
getGameResponse(
Map< String, dynamic> request) → Either<CheckResultFailure, dynamic> - Return either a value or failure based on the given request.
-
getRooms(
Game game) → Stream< QuerySnapshot< Map< >String, dynamic> > - Get stream of rooms from Firebase.
-
hasRoom(
) → bool - Check if a room has been assigned.
-
joinRoom(
FirebaseRoomData roomData, [String? password]) → Future< bool> - Join a room from a Firebase room data object.
-
leaveRoom(
) → Future< void> - Leave current room.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sendGameEvent(
Map< String, dynamic> event) → Future<CheckResult> - Send event to be processed by the game rules. Takes a payload json as input and returns a result.
-
sendOtherEvent(
Map< String, dynamic> payload) → Future<void> -
setOnGameEvent<
T extends GameState> (void callback(GameEvent, T)) → void - Pass event function to be called when a game event has been received.
-
setOnGameEventFailure(
void callback(CheckResultFailure)) → void - Pass event function to be called when an event fails.
-
setOnGameResponseFailure(
void callback(CheckResultFailure)) → void - Pass event function to be called when get game response fails.
-
setOnGameStart<
T extends GameState> (void callback(T)) → void - Pass event function to be called when the game starts.
-
setOnGameStartFailure(
void callback(CheckResultFailure)) → void - Pass event function to be called when the game cannot be started.
-
setOnGameStop(
void callback(Map< String, dynamic> ?)) → void - Pass event function to be called when the game is stopped.
-
setOnHostReassigned(
void callback(Player, Player)) → void - Pass event function to be called when the host is reassigned.
-
setOnLeave(
void callback()) → void - Pass event function to be called when you leave.
-
setOnOtherEvent(
void callback(Event)) → void - Pass event function to be called when an other event is received.
-
setOnPlayerJoin(
void callback(Player)) → void - Pass event function to be called when a player joins.
-
setOnPlayerLeave(
void callback(Player)) → void - Pass event function to be called when a player leaves.
-
setPlayerName(
String name) → void - Set player's name.
-
startGame(
) → Future< CheckResult> - Start a game. Can only be called by the host. Returns a result.
-
stopGame(
[Map< String, dynamic> ? log]) → Future<void> - Stop the current game. Can only be called by the host.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → GameManager
-
Get global device GameManager instance.
no setter