;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;   Modular Simulator Controller System - Car Information Retrieval       ;;;
;;;                                                                         ;;;
;;;   Author:     Oliver Juwig (TheBigO)                                    ;;;
;;;   License:    (2026) Creative Commons - BY-NC-SA                        ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;-------------------------------------------------------------------------;;;
;;;                            Public Rules Section                         ;;;
;;;-------------------------------------------------------------------------;;;

carNumber(?car, ?nr) <= Get(Car, ?car, Nr, ?nr)

carID(?car, ?id) <= Get(Car, ?car, ID, ?id), !
carID(?car, ?car)

carClass(?car, ?class) <= Get(Car, ?car, Class, ?class), !
carClass(?car, Unknown)

carCategory(?car, ?category) <= Get(Car, ?car, Category, ?category), !
carCategory(?car, false)

carDriverForname(?car, ?forname) <= Get(Car, ?car, Driver.Forname, ?forname)
carDriverSurname(?car, ?surname) <= Get(Car, ?car, Driver.Surname, ?surname)
carDriverNickname(?car, ?nickname) <= Get(Car, ?car, Driver.Nickname, ?nickname)
carDriverCategory(?car, ?category) <= Get(Car, ?car, Driver.Category, ?category), !
carDriverCategory(?car, Unknown)

carModel(?car, ?model) <= Get(Car, ?car, Car, ?model)

carLaps(?car, COMPLETED, ?laps) <= Get(Car, ?car, Laps, ?laps), !
carLaps(?car, COMPLETED, ?laps) <= Get(Car, ?car, Lap, ?laps)
carLaps(?car, RUNNING, ?runningLap) <= Get(Car, ?car, Lap.Running, ?runningLap)
carLaps(?car, FULL, ?laps) <= carLaps(?car, COMPLETED, ?completedLaps), carLaps(?car, RUNNING, ?runningLap),
							  ?laps = ?completedLaps + ?runningLap

carPosition(?car, ?position) <= Get(Car, ?car, Position, ?position)

carLapTime(?car, ?time) <= Get(Car, ?car, Time, ?time)

carSectorsTime(?car, ?times) <= Get(Car, ?car, Time.Sectors, ?times), !
carSectorsTime(?car, false)
