hasPlayerWon function

bool hasPlayerWon(
  1. List<LudoPiece> pieces,
  2. int playerIndex
)

Returns true if playerIndex's own 4 pieces have all finished.

Implementation

bool hasPlayerWon(List<LudoPiece> pieces, int playerIndex) {
  return pieces
      .where((p) => p.playerIndex == playerIndex)
      .every((p) => p.isFinished);
}