Documentation
¶
Index ¶
- type EventPublisher
- type Pitstop
- type PitstopService
- type RaceProgress
- type RaceStrategy
- func (s *RaceStrategy) CalculateMaxTimeLoss(saveStrat, flatoutStrat *entities.PitStrat)
- func (s *RaceStrategy) DefaultTrackLayoutFallback(ctx context.Context, info *entities.RaceInfo) error
- func (s *RaceStrategy) EnsurePitLength(info *entities.RaceInfo)
- func (s *RaceStrategy) FetchStrategy(ctx context.Context, id, userID uuid.UUID, passphrase string) (*entities.SavedStrategy, error)
- func (s *RaceStrategy) FetchStrategyCarAndLocation(ctx context.Context, strategyID uuid.UUID) (*entities.Car, *entities.Track, *entities.TrackLayout, error)
- func (s *RaceStrategy) GeneratePitStrategies(ctx context.Context, strat *entities.RaceStrategy) error
- type Setup
- func (s *Setup) CanUserUpdate(setup *entities.Setup, user *entities.User) bool
- func (s *Setup) NormalizeForUpdate(reqSetup, savedSetup *entities.Setup)
- func (s *Setup) SetUser(setup *entities.Setup, user *entities.User)
- func (s *Setup) ShouldUpdateFileContent(setup *entities.Setup) bool
- func (s *Setup) StoreSetupFile(ctx context.Context, setup *entities.Setup, opts ...postgresdb.ExecOption) error
- type Stint
- func (s *Stint) AdjustStintsToFitRaceLength(ctx context.Context, info entities.RaceInfo, strat *entities.PitStrat)
- func (s *Stint) ApplyStintAdjustment(ctx context.Context, strat *entities.SavedStrategy, ...) error
- func (s *Stint) CreateStint(ctx context.Context, stintLaps, saveLaps float64, info entities.RaceInfo, ...) entities.Stint
- func (s *Stint) UpdateCompleteLaps(ctx context.Context, strat *entities.SavedStrategy, stint *entities.Stint, ...) float64
- type StintService
- type Track
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventPublisher ¶
type Pitstop ¶
type Pitstop struct {
// contains filtered or unexported fields
}
func NewPitstop ¶
func NewPitstop( pitParamsRepo repositories.PitParameters, ) *Pitstop
func (*Pitstop) AveragePitLength ¶
func (p *Pitstop) AveragePitLength(ctx context.Context, pitDetails entities.PitstopDetails) (int64, error)
AveragePitLength calculates the averate pit length for the given pitDetails pit services, across all race classes, including pit lane drive loss on all tracks and layouts.
type PitstopService ¶
type RaceProgress ¶
type RaceProgress struct {
// contains filtered or unexported fields
}
func NewRaceProgress ¶
func NewRaceProgress( stintSvc StintService, ) *RaceProgress
func (*RaceProgress) UpdateStrategyWithRaceProgress ¶
func (p *RaceProgress) UpdateStrategyWithRaceProgress( ctx context.Context, strat *entities.SavedStrategy, progress *entities.RaceProgress, )
type RaceStrategy ¶
type RaceStrategy struct {
// contains filtered or unexported fields
}
func NewRaceStrategy ¶
func NewRaceStrategy( stratRepo repositories.Strategy, carRepo repositories.Car, trackRepo repositories.Track, trackLayoutRepo repositories.TrackLayout, stintSvc StintService, ) *RaceStrategy
func (*RaceStrategy) CalculateMaxTimeLoss ¶
func (s *RaceStrategy) CalculateMaxTimeLoss(saveStrat, flatoutStrat *entities.PitStrat)
CalculateMaxTimeLoss that the driver is allowed to lose per lap when driving in fuel saving mode, to save enough fuel in the race to avoiding having to take a pit stop for the savedStint.
func (*RaceStrategy) DefaultTrackLayoutFallback ¶
func (*RaceStrategy) EnsurePitLength ¶
func (s *RaceStrategy) EnsurePitLength(info *entities.RaceInfo)
func (*RaceStrategy) FetchStrategy ¶
func (s *RaceStrategy) FetchStrategy( ctx context.Context, id, userID uuid.UUID, passphrase string, ) (*entities.SavedStrategy, error)
func (*RaceStrategy) FetchStrategyCarAndLocation ¶
func (*RaceStrategy) GeneratePitStrategies ¶
func (s *RaceStrategy) GeneratePitStrategies( ctx context.Context, strat *entities.RaceStrategy, ) error
type Setup ¶
type Setup struct {
// contains filtered or unexported fields
}
func NewSetup ¶
func NewSetup( setupStore repositories.SetupStorage, ) *Setup
func (*Setup) CanUserUpdate ¶
func (*Setup) NormalizeForUpdate ¶
NormalizeForUpdate sets required fields to the previous values if the update request is not setting them.
func (*Setup) ShouldUpdateFileContent ¶
func (*Setup) StoreSetupFile ¶
func (s *Setup) StoreSetupFile(ctx context.Context, setup *entities.Setup, opts ...postgresdb.ExecOption) error
type Stint ¶
type Stint struct {
// contains filtered or unexported fields
}
func NewStint ¶
func NewStint( carRepo repositories.Car, pitstopSvc PitstopService, ) *Stint
func (*Stint) AdjustStintsToFitRaceLength ¶
func (s *Stint) AdjustStintsToFitRaceLength(ctx context.Context, info entities.RaceInfo, strat *entities.PitStrat)
AdjustStintsToFitRaceLength after applying changes to stints from race progress or manual edits, we may need to adjust the rest so that they still fit the race length.
TODO: Adjusting stints to fit race length can lead to invalid adjustments, no matter how the race length is determined, if it is by race length or by laps of the race. If a subset of race laps are driven at a much slower pace, i.e. under FCY or SC, or a badly damaged car, then the driven laps at the end of the race will not be the same as when driving at normal pace, nor will the laps driven counted at race pace reach the same time. https://gitlab.com/bitval/go-lmu-setup-api/-/issues/73
func (*Stint) ApplyStintAdjustment ¶
func (s *Stint) ApplyStintAdjustment( ctx context.Context, strat *entities.SavedStrategy, stintAdj *entities.StintAdjustment, ) error
func (*Stint) CreateStint ¶
func (*Stint) UpdateCompleteLaps ¶
func (s *Stint) UpdateCompleteLaps( ctx context.Context, strat *entities.SavedStrategy, stint *entities.Stint, lapsComplete, maxStintLaps float64, ) float64
UpdateCompleteLaps updates the stints with the number of complete laps and adjusts its length based on the remaining fuel/energy in the tank, as well as adjusting the fuel/energy target consumption.
type StintService ¶
type StintService interface {
UpdateCompleteLaps(context.Context, *entities.SavedStrategy, *entities.Stint, float64, float64) float64
AdjustStintsToFitRaceLength(context.Context, entities.RaceInfo, *entities.PitStrat)
CreateStint(context.Context, float64, float64, entities.RaceInfo, uint) entities.Stint
ApplyStintAdjustment(context.Context, *entities.SavedStrategy, *entities.StintAdjustment) error
}
type Track ¶
type Track struct {
// contains filtered or unexported fields
}
func NewTrack ¶
func NewTrack(trackLayoutRepo repositories.TrackLayout) *Track