|
|
|
|
@ -47,6 +47,7 @@ func main() {
|
|
|
|
|
|
|
|
|
|
// Process events from the clock
|
|
|
|
|
go func() {
|
|
|
|
|
raceResults := make([]*derby.Result, 0)
|
|
|
|
|
for event := range clock.Events() {
|
|
|
|
|
switch event.Type {
|
|
|
|
|
case derby.EventRaceStart:
|
|
|
|
|
@ -56,14 +57,16 @@ func main() {
|
|
|
|
|
result := event.Result
|
|
|
|
|
fmt.Printf("🚗 Lane %d finished in place %d with time %.4f seconds\n",
|
|
|
|
|
result.Lane, result.FinishPlace, result.Time)
|
|
|
|
|
raceResults = append(raceResults, result)
|
|
|
|
|
|
|
|
|
|
case derby.EventRaceComplete:
|
|
|
|
|
fmt.Println("\n🏆 Race complete! Final results:")
|
|
|
|
|
for _, result := range clock.Results() {
|
|
|
|
|
for _, result := range raceResults {
|
|
|
|
|
fmt.Printf("Place %d: Lane %d - %.4f seconds\n",
|
|
|
|
|
result.FinishPlace, result.Lane, result.Time)
|
|
|
|
|
}
|
|
|
|
|
fmt.Println("\nEnter command (r/f/q/?):")
|
|
|
|
|
raceResults = nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|