Documentation
¶
Index ¶
- Constants
- Variables
- type CalculatedPitTime
- type Car
- type CarClass
- type CarList
- type Event
- type EventType
- type FuelReq
- type PitService
- type PitServiceDuration
- type PitServiceDurations
- type PitStrat
- type PitTimeLoss
- type PitstopDetails
- type RaceClass
- type RaceInfo
- type RaceLaps
- type RaceProgress
- type RaceStrategy
- type ResourceType
- type SavedStrategy
- type Setup
- type SetupCondition
- type SetupFile
- type SetupGroup
- type SetupList
- type SetupType
- type SetupVisibility
- type SetupVote
- type Stint
- type StintAdjustment
- type StintAdjustmentType
- type Stints
- type StratType
- type StrategyDatadeprecated
- type StrategyList
- type Track
- type TrackLayout
- type TrackLayoutList
- type TrackList
- type User
- type UserPublic
Constants ¶
const ( CarClassLMH CarClass = "LMH" CarClassLMDh CarClass = "LMDh" CarClassP2 CarClass = "P2" CarClassGTE CarClass = "GTE" CarClassGT3 CarClass = "GT3" RaceClassHypercar = "HYPERCAR" RaceClassLMP2 = "LMP2" RaceClassLMGTE = "LMGTE" RaceClassLMGT3 = "LMGT3" )
const ( PitService_WingAngle = "wing_angle" PitService_Grille = "grille" PitService_Brakes = "brakes" PitService_Fuel = "fuel" PitService_Tire = "tire" PitService_DriverSwap = "driver_swap" )
const ( SetupTypeSprint SetupType = "sprint" SetupTypeEndurance SetupType = "endurance" SetupTypeHotlap SetupType = "hotlap" SetupConditionDry SetupCondition = "dry" SetupConditionMixed SetupCondition = "mixed" SetupConditionDamp SetupCondition = "damp" SetupConditionWet SetupCondition = "wet" SetupConditionFlooded SetupCondition = "flooded" SetupVote_Upvote SetupVote = "upvote" SetupVote_Downvote SetupVote = "downvote" SetupVisibility_Public SetupVisibility = "public" SetupVisibility_Hidden SetupVisibility = "hidden" SetupVisibility_Private SetupVisibility = "private" )
Variables ¶
var ( ResourceType_Setup ResourceType = "setup" EventType_Created EventType = "created" EventType_Updated EventType = "updated" EventType_Removed EventType = "removed" )
var CarClasses = []CarClass{ CarClassLMH, CarClassLMDh, CarClassP2, CarClassGTE, CarClassGT3, }
var RaceClasses = []RaceClass{ RaceClassHypercar, RaceClassLMP2, RaceClassLMGTE, RaceClassLMGT3, }
Functions ¶
This section is empty.
Types ¶
type CalculatedPitTime ¶
type CalculatedPitTime struct {
PitLength int64 `json:"pit_length"`
}
type Car ¶
type Car struct { ID uuid.UUID `json:"id"` Class CarClass `json:"class"` RaceClass RaceClass `json:"race_class"` Manufacturer string `json:"manufacturer"` Model string `json:"model"` Spec *string `json:"spec,omitempty"` Year uint `json:"year"` CreatedAt time.Time `json:"-"` UpdatedAt *time.Time `json:"-"` }
type Event ¶
type Event struct { Service string `json:"-"` ResourceType ResourceType `json:"resource_type"` ResourceID uuid.UUID `json:"resource_id"` Type string `json:"event_type"` Data any `json:"data"` }
func (Event) Payload ¶
func (e Event) Payload() json.RawMessage
type PitService ¶
type PitService = string
type PitServiceDuration ¶
type PitServiceDuration struct { RaceClass RaceClass Service PitService Amount *int64 Milliseconds int64 }
type PitServiceDurations ¶
type PitServiceDurations map[PitService][]PitServiceDuration
type PitStrat ¶
type PitStrat struct { Type StratType `json:"type" validate:"required"` Primary bool `json:"primary,omitempty"` Stops int `json:"stops"` Stints []Stint `json:"stints" validate:"required"` TimeSaved float64 `json:"time_saved,omitempty"` EstTimeLoss float64 `json:"est_time_loss,omitempty"` FuelSaveLaps float64 `json:"fuel_save_laps,omitempty"` MaxTimeLossPerLap int64 `json:"max_time_loss_per_lap,omitempty"` }
type PitTimeLoss ¶
type PitstopDetails ¶
type PitstopDetails struct { Tires int64 `json:"tires" validate:"gt=-1,lt=5"` Refuel int64 `json:"refuel" validate:"lt=20000"` HasWingAngle bool `json:"has_wing_angle"` HasGrille bool `json:"has_grille"` HasBrakes bool `json:"has_brakes"` HasDriverSwap bool `json:"has_driver_swap"` Damage int64 `json:"damage"` }
type RaceInfo ¶
type RaceInfo struct { TankCapacity float64 `json:"tank_capacity,omitempty" validate:"lt=100000"` FuelUse float64 `json:"fuel_use" validate:"required,gt=0,lt=100000"` EnergyUse float64 `json:"energy_use,omitempty" validate:"required_without=TankCapacity,lt=100000"` RaceTime int64 `json:"race_time" validate:"gt=0,lt=172800000"` // less than 48hrs Laptime int64 `json:"laptime" validate:"required,gt=9999,lt=6000000"` // less than 100mnts ExcludeSafeLap bool `json:"exclude_safe_lap"` TyreChangeFrequency *uint `json:"tyre_change_frequency"` CarID *uuid.UUID `json:"car_id,omitempty" validate:"required_with=TrackID"` TrackID *uuid.UUID `json:"track_id,omitempty" validate:"required_with=CarID,required_with=TrackLayoutID"` TrackLayoutID *uuid.UUID `json:"track_layout_id,omitempty"` StintLaps float64 `json:"-"` Laps float64 `json:"-"` SafeLaps float64 `json:"-"` // Deprecated: pit length is deprecated as we no longer allow the user to // supply pit length but rather rely on our average pitstop time loss // calculation based on empirical data. PitLength int64 `json:"-"` }
func (*RaceInfo) CalculateRaceLaps ¶
func (i *RaceInfo) CalculateRaceLaps()
CalculateRaceLaps based on the race length time, laptime, and pitlength time adjusting the race laps for the amount of required pit stops.
func (*RaceInfo) GetCapacityAndUse ¶
GetCapacityAndUse returns the fuel tank capacity and per lap FuelUse. If the info *entities.RaceInfo however defines EnergyUse, then the capacity defaults to 10000 (100%), and EnergyUse is returned as usage.
func (*RaceInfo) GetMaxSaveStintLaps ¶
GetMaxSaveStintLaps returns the maximum laps of a stint for a fuel save drive based on the provided maxSavePercent.
func (*RaceInfo) HasCarAndLocation ¶
HasCarAndLocation returns an error if the race info does not have a car id or a track id set.
type RaceProgress ¶
type RaceProgress struct { RemainingTime float64 `json:"remaining_time" validate:"lt:172800000,required_without=LapsComplete"` // less than 48 hrs LapsComplete float64 `json:"laps_complete" validate:"lt:100000"` FuelTank float64 `json:"fuel_tank" validate:"lt:100000"` EnergyTank float64 `json:"energy_tank" validate:"lt:100000"` }
type RaceStrategy ¶
type RaceStrategy struct { ID uuid.UUID `json:"id"` RaceInfo RaceInfo `json:"race_info"` Laps float64 `json:"laps"` SafeLaps float64 `json:"safe_laps"` MinRequired FuelReq `json:"min_required"` SafeRequired FuelReq `json:"safe_required"` FuelRatio float64 `json:"fuel_ratio,omitempty"` Strategies []PitStrat `json:"strategies"` RecommStrat StratType `json:"recomm_strat"` CreatedAt time.Time `json:"-"` UpdatedAt *time.Time `json:"-"` // contains filtered or unexported fields }
func (*RaceStrategy) PrimaryStrategy ¶
func (rs *RaceStrategy) PrimaryStrategy() *PitStrat
func (*RaceStrategy) SetPrimaryStrategy ¶
func (rs *RaceStrategy) SetPrimaryStrategy(stratType StratType) error
func (*RaceStrategy) Strategy ¶
func (rs *RaceStrategy) Strategy(stratType StratType) *PitStrat
type ResourceType ¶
type ResourceType = string
type SavedStrategy ¶
type SavedStrategy struct { ID uuid.UUID `json:"id"` UserID uuid.UUID `json:"-"` Passphrase string `json:"passphrase,omitempty"` Name string `json:"name"` Data RaceStrategy `json:"data"` Progress *RaceProgress `json:"race_progress,omitempty"` StintAdjustments []StintAdjustment `json:"stint_adjustments"` CreatedAt time.Time `json:"-"` UpdatedAt *time.Time `json:"-"` }
type Setup ¶
type Setup struct { ID uuid.UUID `json:"id" validate:"uuid"` ParentID *uuid.UUID `json:"parent_id,omitempty"` CarID uuid.UUID `json:"car_id" validate:"required,uuid"` TrackID uuid.UUID `json:"track_id" validate:"required,uuid"` TrackLayoutID *uuid.UUID `json:"track_layout_id"` Visibility SetupVisibility `json:"visibility"` Name string `json:"name,omitempty"` FileName string `json:"file_name" validate:"required"` FileContent string `json:"file_content,omitempty" validate:"required_without=ID"` Laptime string `json:"laptime" validate:"custom_laptime_validation"` Type SetupType `json:"type" validate:"required,oneof=sprint endurance hotlap"` Condition SetupCondition `json:"condition" validate:"required,oneof=dry damp wet flooded mixed"` Rating int64 `json:"rating" validate:"eq=0"` Description *string `json:"description,omitempty"` Downloads int `json:"downloads" validate:"eq=0"` VideoLink string `json:"video_link,omitempty" validate:"omitempty,http_url"` Version string `json:"version"` UserID uuid.UUID `json:"user_id" validate:"required,uuid"` User string `json:"display_name" validate:"required"` UserObj *UserPublic `json:"user"` UserVote *bool `json:"user_vote"` AIGenerated bool `json:"ai_generated"` CreatedAt time.Time `json:"uploaded_at"` UpdatedAt *time.Time `json:"modified,omitempty"` }
TODO(slax0rr): add custom validation to check the track layout id against the stored layout data
func (*Setup) SetDefaultVisibility ¶
func (s *Setup) SetDefaultVisibility()
type SetupCondition ¶
type SetupCondition = string
type SetupGroup ¶
type SetupVisibility ¶
type SetupVisibility = string
type Stint ¶
type Stint struct { StintNumber uint `json:"stint_number" validate:"required"` Laps float64 `json:"laps" validate:"required,gt=0"` Save float64 `json:"save,omitempty"` TargetUse FuelReq `json:"target_use" validate:"required"` StintRequired FuelReq `json:"stint_required" validate:"required"` FuelRatio float64 `json:"fuel_ratio" validate:"required"` PitLength int64 `json:"pit_length" validate:"required"` Complete bool `json:"complete,omitempty"` CompletedLaps float64 `json:"completed_laps,omitempty"` Locked bool `json:"locked,omitempty"` EstTimeLoss float64 `json:"est_time_loss"` }
func (*Stint) CalculateFuel ¶
CalculateFule requirements for the stint.
func (*Stint) MarkComplete ¶
func (s *Stint) MarkComplete()
type StintAdjustment ¶
type StintAdjustment struct { StintNumber uint `json:"stint_number" validate:"required,gt=0"` Type StintAdjustmentType `json:"type"` Laps float64 `json:"laps,omitempty"` PitLength int64 `json:"pit_length,omitempty"` PitDetails *PitstopDetails `json:"pit_details,omitempty"` }
type StintAdjustmentType ¶
type StintAdjustmentType = string
var ( StintAdjustmentType_PitLength StintAdjustmentType = "pitlength" StintAdjustmentType_Pitstop StintAdjustmentType = "pitstop" StintAdjustmentType_Laps StintAdjustmentType = "laps" )
type StratType ¶
type StratType = string
var ( // StratType_NoStop strategy is where the driver drives flat out for one // stint, as the race does not require multiple stints. StratType_NoStop StratType = "no_stop" // StratType_FlatOut strategy is where a driver drives flat out the whole // time not saving any fuel, and refueling only enough fuel to take the car // to the end of that stint. StratType_FlatOut StratType = "flat_out" // StratType_EvenSave strategy is where the last stint is removed from the // strategy and its laps are distributed among the remaining stints. StratType_EvenSave StratType = "even_save" // StratType_MaxStint strategy is where a driver saves enough fuel through // the stint to extend the stint by one lap and use up the whole full tank, // as opposed to underfueling and going flat out. StratType_MaxStint StratType = "max_stint" // StratType_HybridSave strategy is where each stint is extended to add // one more lap in order to have the driver use up the whole tank, as with // StratType_MaxStint, however, if the then remaining last stint is small // enough, it is removed and its remaining laps are distributed among other // remaining stints. // // TODO(slax0rr): Implementation missing. StratType_HybridSave StratType = "hybrid_save" )
type StrategyData
deprecated
type StrategyData struct { RaceInfo RaceInfo `json:"race_info" validate:"required"` Laps float64 `json:"laps" validate:"required,gt=0"` SafeLaps float64 `json:"safe_laps" validate:"required,gt=0"` MinRequired FuelReq `json:"min_required" validate:"required"` SafeRequired FuelReq `json:"safe_required" validate:"required"` FuelRatio float64 `json:"fuel_ratio,omitempty"` PitStrategy PitStrat `json:"pit_strategy" validate:"required"` }
Deprecated: Will be removed in favour of `RaceStrategy` since the single saved strategy will no longer be used, but we will rather transmit the whole array every time and just mark the chosen pit strategy as the primary one once the user decides to save.
type StrategyList ¶
type StrategyList []SavedStrategy
type TrackLayout ¶
type TrackLayoutList ¶
type TrackLayoutList []TrackLayout
type User ¶
type User struct { ID uuid.UUID `json:"id"` Email string `json:"email,omitempty"` Username string `json:"username,omitempty"` DisplayName string `json:"display_name,omitempty"` AvatarLink string `json:"avatar_link,omitempty"` }
func (*User) ToPublic ¶
func (u *User) ToPublic() *UserPublic