LudoController constructor

LudoController({
  1. required List<LudoPlayer> players,
  2. LudoDiceRules diceRules = const LudoDiceRules(),
  3. int diceRoller()?,
  4. LudoDiceRolledCallback? onDiceRolled,
  5. LudoPieceMovedCallback? onPieceMoved,
  6. LudoPieceCapturedCallback? onPieceCaptured,
  7. LudoTurnChangedCallback? onTurnChanged,
  8. LudoPlayerWonCallback? onPlayerWon,
  9. LudoTeamWonCallback? onTeamWon,
  10. LudoGameFinishedCallback? onGameFinished,
  11. bool enableAudio = true,
  12. Duration stepAnimationDuration = const Duration(milliseconds: 180),
  13. List<LudoTeam>? teams,
})

Implementation

LudoController({
  required List<LudoPlayer> players,
  this.diceRules = const LudoDiceRules(),
  int Function()? diceRoller,
  this.onDiceRolled,
  this.onPieceMoved,
  this.onPieceCaptured,
  this.onTurnChanged,
  this.onPlayerWon,
  this.onTeamWon,
  this.onGameFinished,
  bool enableAudio = true,
  this.stepAnimationDuration = const Duration(milliseconds: 180),
  // Teams mode — pass kDefaultTeams or a custom list to enable.
  List<LudoTeam>? teams,
})  : assert(
        players.length >= 2 && players.length <= 4,
        'flutter_ludo supports 2 to 4 players.',
      ),
      assert(
        teams == null || players.length == 4,
        'Teams mode requires exactly 4 players.',
      ),
      assert(diceRules.startAllowedValues.isNotEmpty),
      _diceRoller = diceRoller ?? _defaultDiceRoller,
      _engine     = LudoEngine(diceRules, teams: teams),
      // _audio      = AudioService(enabled: enableAudio),
      _teams      = teams {
  _state = _initialState(players, teams);
}