setBot method

void setBot(
  1. int playerIndex,
  2. bool isBot
)

Hands playerIndex over to the bot (true) or to a human (false) — e.g. when a player leaves mid-game.

Implementation

void setBot(int playerIndex, bool isBot) {
  RangeError.checkValidIndex(playerIndex, _state.players, 'playerIndex');
  final changed = isBot ? _bots.add(playerIndex) : _bots.remove(playerIndex);
  if (!changed) return;
  _notify();
  _scheduleNext();
}