LudoController constructor
LudoController({
- required List<
LudoPlayer> players, - LudoDiceRules diceRules = const LudoDiceRules(),
- int diceRoller()?,
- LudoDiceRolledCallback? onDiceRolled,
- LudoPieceMovedCallback? onPieceMoved,
- LudoPieceCapturedCallback? onPieceCaptured,
- LudoTurnChangedCallback? onTurnChanged,
- LudoPlayerWonCallback? onPlayerWon,
- LudoTeamWonCallback? onTeamWon,
- LudoGameFinishedCallback? onGameFinished,
- bool enableAudio = true,
- Duration stepAnimationDuration = const Duration(milliseconds: 180),
- 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);
}