teamOf function

LudoTeam? teamOf(
  1. int playerIndex,
  2. List<LudoTeam>? teams
)

Returns the LudoTeam that playerIndex belongs to, from teams. Returns null if teams is null (i.e. not in teams mode).

Implementation

LudoTeam? teamOf(int playerIndex, List<LudoTeam>? teams) {
  if (teams == null) return null;
  for (final t in teams) {
    if (t.contains(playerIndex)) return t;
  }
  return null;
}