-- ================================================================================
-- LOCAL FUNCTIONS
-- ================================================================================

local function getCheckpointFromPart(part)
	for _, checkpoint in pairs(checkpoints) do
		if checkpoint.CollisionBody == part then
			return checkpoint
		end
	end
	return nil
end -- getCheckpointFromPart()

local function hasPlayerFinishedLap(player, lap)
	for _, checkpoint in pairs(checkpoints) do
		if checkpoint:PlayerLapPassed(player, lap) ~= lap then
			return false
		end
	end
	return true
end -- hasPlayerFinishedLap()

local function addRacer(player)
	racers[player] = Racer.new()
end -- addRacer()

local function checkAllFinished()
	for _, racer in pairs(racers) do
		if not racer:HasFinishedLap(numLaps) then
			return false
		end
	end
	return true
end -- checkAllFinished()