LudoBotController constructor
LudoBotController({
- required List<
LudoPlayer> players, - required Set<
int> botPlayerIndices, - LudoDiceRules diceRules = const LudoDiceRules(),
- int diceRoller()?,
- bool enableAudio = true,
- Duration thinkDuration = const Duration(milliseconds: 300),
- List<
LudoTeam> ? teams, - LudoDiceRolledCallback? onDiceRolled,
- LudoPieceMovedCallback? onPieceMoved,
- LudoPieceCapturedCallback? onPieceCaptured,
- LudoTurnChangedCallback? onTurnChanged,
- LudoPlayerWonCallback? onPlayerWon,
- LudoTeamWonCallback? onTeamWon,
- LudoGameFinishedCallback? onGameFinished,
- Duration stepAnimationDuration = const Duration(milliseconds: 180),
Implementation
LudoBotController({
required List<LudoPlayer> players,
required this.botPlayerIndices,
LudoDiceRules diceRules = const LudoDiceRules(),
int Function()? diceRoller,
bool enableAudio = true,
this.thinkDuration = const Duration(milliseconds: 300),
List<LudoTeam>? teams,
// Forward all callbacks
LudoDiceRolledCallback? onDiceRolled,
LudoPieceMovedCallback? onPieceMoved,
LudoPieceCapturedCallback? onPieceCaptured,
LudoTurnChangedCallback? onTurnChanged,
LudoPlayerWonCallback? onPlayerWon,
LudoTeamWonCallback? onTeamWon,
LudoGameFinishedCallback? onGameFinished,
Duration stepAnimationDuration = const Duration(milliseconds: 180),
}) : _scorer = const LudoMoveScorer(),
_inner = LudoController(
players: players,
diceRules: diceRules,
diceRoller: diceRoller,
enableAudio: enableAudio,
teams: teams,
onDiceRolled: onDiceRolled,
onPieceMoved: onPieceMoved,
onPieceCaptured: onPieceCaptured,
onTurnChanged: onTurnChanged,
onPlayerWon: onPlayerWon,
onTeamWon: onTeamWon,
onGameFinished: onGameFinished,
stepAnimationDuration: stepAnimationDuration,
) {
// Listen to inner controller and re-notify our own listeners so the
// board / dice widgets rebuild correctly.
_inner.addListener(_onInnerChanged);
// Kick off bot if the first player happens to be a bot.
_scheduleBotTurnIfNeeded();
}