forked from Team254/cheesy-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_settings.go
58 lines (53 loc) · 1.72 KB
/
event_settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2014 Team 254. All Rights Reserved.
// Author: [email protected] (Patrick Fairbank)
//
// Model and datastore read/write methods for event-level configuration.
package main
type EventSettings struct {
Id int
Name string
Code string
DisplayBackgroundColor string
NumElimAlliances int
SelectionRound2Order string
SelectionRound3Order string
TeamInfoDownloadEnabled bool
AllianceDisplayHotGoals bool
RedGoalLightsAddress string
BlueGoalLightsAddress string
TbaPublishingEnabled bool
TbaEventCode string
TbaSecretId string
TbaSecret string
NetworkSecurityEnabled bool
ApAddress string
ApUsername string
ApPassword string
SwitchAddress string
SwitchPassword string
}
const eventSettingsId = 0
func (database *Database) GetEventSettings() (*EventSettings, error) {
eventSettings := new(EventSettings)
err := database.eventSettingsMap.Get(eventSettings, eventSettingsId)
if err != nil {
// Database record doesn't exist yet; create it now.
eventSettings.Name = "Untitled Event"
eventSettings.Code = "UE"
eventSettings.DisplayBackgroundColor = "#00ff00"
eventSettings.NumElimAlliances = 8
eventSettings.SelectionRound2Order = "L"
eventSettings.SelectionRound3Order = ""
eventSettings.TeamInfoDownloadEnabled = true
err = database.eventSettingsMap.Insert(eventSettings)
if err != nil {
return nil, err
}
}
return eventSettings, nil
}
func (database *Database) SaveEventSettings(eventSettings *EventSettings) error {
eventSettings.Id = eventSettingsId
_, err := database.eventSettingsMap.Update(eventSettings)
return err
}