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. LudoTurnForfeitedCallback? onTurnForfeited,
  12. @Deprecated('Audio was removed in 0.1.0. This flag has no effect.') bool enableAudio = true,
  13. Duration stepAnimationDuration = const Duration(milliseconds: 180),
  14. List<LudoTeam>? teams,
  15. Set<int> botPlayers = const {},
  16. LudoBotDifficulty botDifficulty = LudoBotDifficulty.medium,
  17. LudoBotStrategy? botStrategy,
  18. Duration botThinkDuration = const Duration(milliseconds: 500),
  19. bool autoMoveSingleChoice = true,
  20. Duration autoMoveDelay = const Duration(milliseconds: 250),
})

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,
  this.onTurnForfeited,
  @Deprecated('Audio was removed in 0.1.0. This flag has no effect.')
  bool enableAudio = true,
  this.stepAnimationDuration = const Duration(milliseconds: 180),
  // Teams mode — pass kDefaultTeams or a custom list to enable.
  List<LudoTeam>? teams,
  Set<int> botPlayers = const {},
  LudoBotDifficulty botDifficulty = LudoBotDifficulty.medium,
  LudoBotStrategy? botStrategy,
  this.botThinkDuration = const Duration(milliseconds: 500),
  this.autoMoveSingleChoice = true,
  this.autoMoveDelay = const Duration(milliseconds: 250),
}) : 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),
     assert(
       botPlayers.every((i) => i >= 0 && i < players.length),
       'botPlayers contains an index outside 0..${players.length - 1}.',
     ),
     _diceRoller = diceRoller ?? _defaultDiceRoller,
     _engine = LudoEngine(diceRules, teams: teams),
     _bots = {...botPlayers},
     botStrategy =
         botStrategy ?? LudoBotStrategy.forDifficulty(botDifficulty) {
  _state = LudoGameState.initial(players, teams: teams);
  _scheduleNext();
}