@@ -53,37 +53,48 @@ type TbaAlliance struct {
53
53
}
54
54
55
55
type TbaScoreBreakdown struct {
56
- MobilityRobot1 string `mapstructure:"mobilityRobot1"`
57
- MobilityRobot2 string `mapstructure:"mobilityRobot2"`
58
- MobilityRobot3 string `mapstructure:"mobilityRobot3"`
59
- AutoMobilityPoints int `mapstructure:"autoMobilityPoints"`
60
- AutoChargeStationRobot1 string `mapstructure:"autoChargeStationRobot1"`
61
- AutoChargeStationRobot2 string `mapstructure:"autoChargeStationRobot2"`
62
- AutoChargeStationRobot3 string `mapstructure:"autoChargeStationRobot3"`
63
- AutoBridgeState string `mapstructure:"autoBridgeState"`
64
- AutoCommunity map [string ][9 ]string `mapstructure:"autoCommunity"`
65
- AutoGamePieceCount int `mapstructure:"autoGamePieceCount"`
66
- AutoGamePiecePoints int `mapstructure:"autoGamePiecePoints"`
67
- AutoPoints int `mapstructure:"autoPoints"`
68
- TeleopCommunity map [string ][9 ]string `mapstructure:"teleopCommunity"`
69
- TeleopGamePieceCount int `mapstructure:"teleopGamePieceCount"`
70
- TeleopGamePiecePoints int `mapstructure:"teleopGamePiecePoints"`
71
- Links []TbaLink `mapstructure:"links"`
72
- LinkPoints int `mapstructure:"linkPoints"`
73
- ExtraGamePieceCount int `mapstructure:"extraGamePieceCount"`
74
- EndGameChargeStationRobot1 string `mapstructure:"endGameChargeStationRobot1"`
75
- EndGameChargeStationRobot2 string `mapstructure:"endGameChargeStationRobot2"`
76
- EndGameChargeStationRobot3 string `mapstructure:"endGameChargeStationRobot3"`
77
- EndGameBridgeState string `mapstructure:"endGameBridgeState"`
78
- TeleopPoints int `mapstructure:"teleopPoints"`
79
- CoopertitionCriteriaMet bool `mapstructure:"coopertitionCriteriaMet"`
80
- SustainabilityBonusAchieved bool `mapstructure:"sustainabilityBonusAchieved"`
81
- ActivationBonusAchieved bool `mapstructure:"activationBonusAchieved"`
82
- FoulCount int `mapstructure:"foulCount"`
83
- TechFoulCount int `mapstructure:"techFoulCount"`
84
- FoulPoints int `mapstructure:"foulPoints"`
85
- TotalPoints int `mapstructure:"totalPoints"`
86
- RP int `mapstructure:"rp"`
56
+ AutoLineRobot1 string `mapstructure:"autoLineRobot1"`
57
+ AutoLineRobot2 string `mapstructure:"autoLineRobot2"`
58
+ AutoLineRobot3 string `mapstructure:"autoLineRobot3"`
59
+ AutoLeavePoints int `mapstructure:"autoLeavePoints"`
60
+ AutoAmpNoteCount int `mapstructure:"autoAmpNoteCount"`
61
+ AutoAmpNotePoints int `mapstructure:"autoAmpNotePoints"`
62
+ AutoSpeakerNoteCount int `mapstructure:"autoSpeakerNoteCount"`
63
+ AutoSpeakerNotePoints int `mapstructure:"autoSpeakerNotePoints"`
64
+ AutoTotalNotePoints int `mapstructure:"autoTotalNotePoints"`
65
+ AutoPoints int `mapstructure:"autoPoints"`
66
+ TeleopAmpNoteCount int `mapstructure:"teleopAmpNoteCount"`
67
+ TeleopAmpNotePoints int `mapstructure:"teleopAmpNotePoints"`
68
+ TeleopSpeakerNoteCount int `mapstructure:"teleopSpeakerNoteCount"`
69
+ TeleopSpeakerNotePoints int `mapstructure:"teleopSpeakerNotePoints"`
70
+ TeleopSpeakerNoteAmplifiedCount int `mapstructure:"teleopSpeakerNoteAmplifiedCount"`
71
+ TeleopSpeakerNoteAmplifiedPoints int `mapstructure:"teleopSpeakerNoteAmplifiedPoints"`
72
+ TeleopTotalNotePoints int `mapstructure:"teleopTotalNotePoints"`
73
+ EndGameRobot1 string `mapstructure:"endGameRobot1"`
74
+ EndGameRobot2 string `mapstructure:"endGameRobot2"`
75
+ EndGameRobot3 string `mapstructure:"endGameRobot3"`
76
+ EndGameParkPoints int `mapstructure:"endGameParkPoints"`
77
+ EndGameOnStagePoints int `mapstructure:"endGameOnStagePoints"`
78
+ EndGameHarmonyPoints int `mapstructure:"endGameHarmonyPoints"`
79
+ MicStageLeft bool `mapstructure:"micStageLeft"`
80
+ MicCenterStage bool `mapstructure:"micCenterStage"`
81
+ MicStageRight bool `mapstructure:"micStageRight"`
82
+ EndGameSpotLightBonusPoints int `mapstructure:"endGameSpotLightBonusPoints"`
83
+ TrapStageLeft bool `mapstructure:"trapStageLeft"`
84
+ TrapCenterStage bool `mapstructure:"trapCenterStage"`
85
+ TrapStageRight bool `mapstructure:"trapStageRight"`
86
+ EndGameNoteInTrapPoints int `mapstructure:"endGameNoteInTrapPoints"`
87
+ EndGameTotalStagePoints int `mapstructure:"endGameTotalStagePoints"`
88
+ TeleopPoints int `mapstructure:"teleopPoints"`
89
+ CoopertitionCriteriaMet bool `mapstructure:"coopertitionCriteriaMet"`
90
+ MelodyBonusAchieved bool `mapstructure:"melodyBonusAchieved"`
91
+ EnsembleBonusAchieved bool `mapstructure:"ensembleBonusAchieved"`
92
+ FoulCount int `mapstructure:"foulCount"`
93
+ TechFoulCount int `mapstructure:"techFoulCount"`
94
+ G424Penalty bool `mapstructure:"g424Penalty"`
95
+ FoulPoints int `mapstructure:"foulPoints"`
96
+ TotalPoints int `mapstructure:"totalPoints"`
97
+ RP int `mapstructure:"rp"`
87
98
}
88
99
89
100
type TbaLink struct {
@@ -148,17 +159,14 @@ type TbaPublishedAward struct {
148
159
Awardee string `json:"awardee"`
149
160
}
150
161
151
- var mobilityMapping = map [bool ]string {false : "No" , true : "Yes" }
152
- var autoChargeStationMapping = map [bool ]string {false : "None" , true : "Docked" }
153
- var endGameChargeStationMapping = map [game.EndgameStatus ]string {
162
+ var leaveMapping = map [bool ]string {false : "No" , true : "Yes" }
163
+ var endGameStatusMapping = map [game.EndgameStatus ]string {
154
164
game .EndgameNone : "None" ,
155
165
game .EndgameParked : "Parked" ,
156
166
game .EndgameStageLeft : "StageLeft" ,
157
167
game .EndgameCenterStage : "CenterStage" ,
158
168
game .EndgameStageRight : "StageRight" ,
159
169
}
160
- var chargeStationLevelMapping = map [bool ]string {false : "NotLevel" , true : "Level" }
161
- var gridRowMapping = map [int ]string {0 : "Bottom" , 1 : "Mid" , 2 : "Top" }
162
170
163
171
func NewTbaClient (eventCode , secretId , secret string ) * TbaClient {
164
172
return & TbaClient {BaseUrl : tbaBaseUrl , eventCode : eventCode , secretId : secretId , secret : secret ,
@@ -459,6 +467,26 @@ func (client *TbaClient) PublishAlliances(database *model.Database) error {
459
467
body , _ := io .ReadAll (resp .Body )
460
468
return fmt .Errorf ("Got status code %d from TBA: %s" , resp .StatusCode , body )
461
469
}
470
+
471
+ // Also set the playoff type so that TBA renders the correct bracket.
472
+ eventSettings , err := database .GetEventSettings ()
473
+ if err != nil {
474
+ return err
475
+ }
476
+ playoffType := 0
477
+ if eventSettings .PlayoffType == model .DoubleEliminationPlayoff {
478
+ playoffType = 10
479
+ }
480
+ resp , err = client .postRequest ("info" , "update" , []byte (fmt .Sprintf ("{\" playoff_type\" :%d}" , playoffType )))
481
+ if err != nil {
482
+ return err
483
+ }
484
+ if resp .StatusCode != 200 {
485
+ defer resp .Body .Close ()
486
+ body , _ := io .ReadAll (resp .Body )
487
+ return fmt .Errorf ("Got status code %d from TBA: %s" , resp .StatusCode , body )
488
+ }
489
+
462
490
return nil
463
491
}
464
492
@@ -604,59 +632,52 @@ func createTbaScoringBreakdown(
604
632
opponentScoreSummary = matchResult .RedScoreSummary ()
605
633
}
606
634
607
- breakdown .MobilityRobot1 = mobilityMapping [score .LeaveStatuses [0 ]]
608
- breakdown .MobilityRobot2 = mobilityMapping [score .LeaveStatuses [1 ]]
609
- breakdown .MobilityRobot3 = mobilityMapping [score .LeaveStatuses [2 ]]
610
- breakdown .AutoMobilityPoints = scoreSummary .LeavePoints
611
- // TODO(pat): Update for 2024.
612
- //breakdown.AutoChargeStationRobot1 = autoChargeStationMapping[score.AutoDockStatuses[0]]
613
- //breakdown.AutoChargeStationRobot2 = autoChargeStationMapping[score.AutoDockStatuses[1]]
614
- //breakdown.AutoChargeStationRobot3 = autoChargeStationMapping[score.AutoDockStatuses[2]]
615
- //breakdown.AutoBridgeState = chargeStationLevelMapping[score.AutoChargeStationLevel]
616
- //breakdown.AutoCommunity = make(map[string][9]string)
617
- //breakdown.TeleopCommunity = make(map[string][9]string)
618
- //for rowIndex, rowName := range gridRowMapping {
619
- // shortRowName := string([]rune(rowName)[0])
620
- // breakdown.AutoCommunity[shortRowName] = createTbaGridRow(&score.Grid, rowIndex, true)
621
- // breakdown.TeleopCommunity[shortRowName] = createTbaGridRow(&score.Grid, rowIndex, false)
622
- //}
623
- //for i := 0; i < 3; i++ {
624
- // for j := 0; j < 9; j++ {
625
- // if score.Grid.Nodes[i][j] != game.Empty {
626
- // if score.Grid.AutoScoring[i][j] {
627
- // breakdown.AutoGamePieceCount++
628
- // }
629
- // breakdown.TeleopGamePieceCount++
630
- // }
631
- // }
632
- //}
633
- //breakdown.Links = make([]TbaLink, 0)
634
- //for _, link := range score.Grid.Links() {
635
- // tbaLink := TbaLink{
636
- // Nodes: [3]int{link.StartColumn, link.StartColumn + 1, link.StartColumn + 2},
637
- // Row: gridRowMapping[int(link.Row)],
638
- // }
639
- // breakdown.Links = append(breakdown.Links, tbaLink)
640
- //}
641
- //breakdown.LinkPoints = score.Grid.LinkPoints()
642
- //breakdown.AutoGamePiecePoints = score.Grid.AutoGamePiecePoints()
643
- //breakdown.TeleopGamePiecePoints = score.Grid.TeleopGamePiecePoints() + score.Grid.SuperchargedPoints()
644
- //breakdown.AutoPoints = scoreSummary.AutoPoints
645
- //breakdown.ExtraGamePieceCount = score.Grid.NumSuperchargedNodes()
646
- //breakdown.EndGameChargeStationRobot1 = endGameChargeStationMapping[score.EndgameStatuses[0]]
647
- //breakdown.EndGameChargeStationRobot2 = endGameChargeStationMapping[score.EndgameStatuses[1]]
648
- //breakdown.EndGameChargeStationRobot3 = endGameChargeStationMapping[score.EndgameStatuses[2]]
649
- //breakdown.EndGameBridgeState = chargeStationLevelMapping[score.EndgameChargeStationLevel]
650
- //breakdown.TeleopPoints = breakdown.TeleopGamePiecePoints + scoreSummary.StagePoints
651
- //breakdown.CoopertitionCriteriaMet = score.Grid.IsCoopertitionThresholdAchieved()
652
- breakdown .SustainabilityBonusAchieved = scoreSummary .MelodyBonusRankingPoint
653
- breakdown .ActivationBonusAchieved = scoreSummary .EnsembleBonusRankingPoint
635
+ breakdown .AutoLineRobot1 = leaveMapping [score .LeaveStatuses [0 ]]
636
+ breakdown .AutoLineRobot2 = leaveMapping [score .LeaveStatuses [1 ]]
637
+ breakdown .AutoLineRobot3 = leaveMapping [score .LeaveStatuses [2 ]]
638
+ breakdown .AutoLeavePoints = scoreSummary .LeavePoints
639
+ breakdown .AutoAmpNoteCount = score .AmpSpeaker .AutoAmpNotes
640
+ breakdown .AutoAmpNotePoints = 2 * breakdown .AutoAmpNoteCount
641
+ breakdown .AutoSpeakerNoteCount = score .AmpSpeaker .AutoSpeakerNotes
642
+ breakdown .AutoSpeakerNotePoints = 5 * breakdown .AutoSpeakerNoteCount
643
+ breakdown .AutoTotalNotePoints = breakdown .AutoAmpNotePoints + breakdown .AutoSpeakerNotePoints
644
+ breakdown .AutoPoints = scoreSummary .AutoPoints
645
+ breakdown .TeleopAmpNoteCount = score .AmpSpeaker .TeleopAmpNotes
646
+ breakdown .TeleopAmpNotePoints = 1 * breakdown .TeleopAmpNoteCount
647
+ breakdown .TeleopSpeakerNoteCount = score .AmpSpeaker .TeleopUnamplifiedSpeakerNotes
648
+ breakdown .TeleopSpeakerNotePoints = 2 * breakdown .TeleopSpeakerNoteCount
649
+ breakdown .TeleopSpeakerNoteAmplifiedCount = score .AmpSpeaker .TeleopAmplifiedSpeakerNotes
650
+ breakdown .TeleopSpeakerNoteAmplifiedPoints = 5 * breakdown .TeleopSpeakerNoteAmplifiedCount
651
+ breakdown .TeleopTotalNotePoints = breakdown .TeleopAmpNotePoints + breakdown .TeleopSpeakerNotePoints +
652
+ breakdown .TeleopSpeakerNoteAmplifiedPoints
653
+ breakdown .EndGameRobot1 = endGameStatusMapping [score .EndgameStatuses [0 ]]
654
+ breakdown .EndGameRobot2 = endGameStatusMapping [score .EndgameStatuses [1 ]]
655
+ breakdown .EndGameRobot3 = endGameStatusMapping [score .EndgameStatuses [2 ]]
656
+ breakdown .EndGameParkPoints = scoreSummary .ParkPoints
657
+ breakdown .EndGameOnStagePoints = scoreSummary .OnStagePoints
658
+ breakdown .EndGameHarmonyPoints = scoreSummary .HarmonyPoints
659
+ breakdown .MicStageLeft = score .MicrophoneStatuses [0 ]
660
+ breakdown .MicCenterStage = score .MicrophoneStatuses [1 ]
661
+ breakdown .MicStageRight = score .MicrophoneStatuses [2 ]
662
+ breakdown .EndGameSpotLightBonusPoints = scoreSummary .SpotlightPoints
663
+ breakdown .TrapStageLeft = score .TrapStatuses [0 ]
664
+ breakdown .TrapCenterStage = score .TrapStatuses [1 ]
665
+ breakdown .TrapStageRight = score .TrapStatuses [2 ]
666
+ breakdown .EndGameNoteInTrapPoints = scoreSummary .TrapPoints
667
+ breakdown .EndGameTotalStagePoints = scoreSummary .StagePoints
668
+ breakdown .TeleopPoints = breakdown .TeleopTotalNotePoints + breakdown .EndGameTotalStagePoints
669
+ breakdown .CoopertitionCriteriaMet = scoreSummary .CoopertitionCriteriaMet
670
+ breakdown .MelodyBonusAchieved = scoreSummary .MelodyBonusRankingPoint
671
+ breakdown .EnsembleBonusAchieved = scoreSummary .EnsembleBonusRankingPoint
654
672
for _ , foul := range score .Fouls {
655
673
if foul .IsTechnical {
656
674
breakdown .TechFoulCount ++
657
675
} else {
658
676
breakdown .FoulCount ++
659
677
}
678
+ if foul .Rule () != nil && foul .Rule ().IsRankingPoint {
679
+ breakdown .G424Penalty = true
680
+ }
660
681
}
661
682
breakdown .FoulPoints = scoreSummary .FoulPoints
662
683
breakdown .TotalPoints = scoreSummary .Score
0 commit comments