GenericGame class

Represents a generic game, with common fields that can be manipulated by common GenericEvents

Includes

Annotations
  • @freezed

Constructors

GenericGame(IList<Player> players, IList<PlayerID> readyPlayers, IList<IList<double>> allRoundScores, DateTime time, IList<GameMessage> messages, GameStatus status, int? currentPlayerIndex, int round, bool isMultiPly, bool isSimultaneousAction)
const
factory
GenericGame.fromJson(Map<String, dynamic> map)
factory
GenericGame.start(IList<Player> players, {required bool multiPly, required bool simultaneousAction})
Creates a default initialized game with players
factory
GenericGame.startRandom(IList<Player> players, {required bool multiPly, required bool simultaneousAction})
Creates a default initialized game where the first player is chosen at random
factory

Properties

allRoundScores IList<IList<double>>
no setterinherited
copyWith → $GenericGameCopyWith<GenericGame>
no setterinherited
currentPlayer Player?
Gets the player at the currentPlayerIndex
no setter
currentPlayerIndex int?
no setterinherited
gameOver bool
Gets whether the game is over
no setter
hashCode int
The hash code for this object.
no setterinherited
isMultiPly bool
no setterinherited
isSimultaneousAction bool
no setterinherited
messages IList<GameMessage>
no setterinherited
playerRoundScores IMap<PlayerID, IList<double>>
Gets the scores for each player for all rounds based off of allRoundScores
no setter
players IList<Player>
no setterinherited
readyPlayers IList<String>
no setterinherited
round int
no setterinherited
roundOver bool
Gets whether the round is over
no setter
roundPlayerScores IList<IMap<PlayerID, double>>
Gets the scores for each round for each player based off of allRoundScores
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status GameStatus
no setterinherited
time DateTime
no setterinherited
totalScores IMap<PlayerID, double>
Gets the total score for each player based off of allRoundScores
no setter

Methods

addMessage(GameMessage msg) GenericGame
Returns a copy of the GenericGame with the msg added to messages
addReadyPlayer(PlayerID player) GenericGame
Adds a ready player to the list
clearReadyPlayers() GenericGame
Clears the list of ready players
finishRound([Map<PlayerID, double>? scores]) GenericGame
Returns a copy of the GenericGame with the round incremented, status set to GameStatus.Started and optionally the players' scores added to allRoundScores
nextPlayer() GenericGame
Returns a copy of the GenericGame with the next player in the player array as the current player
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setNextPlayer(PlayerID player) GenericGame
Returns a copy of the GenericGame with the current player being the one with id player
shufflePlayers() GenericGame
Shuffles the player list, and resets the currentPlayerIndex to the first
toJson() Map<String, dynamic>
inherited
toString() String
A string representation of this object.
inherited
updateScores(Map<PlayerID, double> scores) GenericGame
Returns a copy of the GenericGame with the scores added to allRoundScores
updateStatus(GameStatus status) GenericGame
Returns a copy of the GenericGame with the status updated to status
updateTime() GenericGame
Returns a copy of the GenericGame with the time updated to the current time

Operators

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