forked from Team254/cheesy-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_settings.go
67 lines (60 loc) · 2.03 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
59
60
61
62
63
64
65
66
67
// 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
TBADownloadEnabled bool
TbaPublishingEnabled bool
TbaEventCode string
TbaSecretId string
TbaSecret string
NetworkSecurityEnabled bool
ApAddress string
ApUsername string
ApPassword string
SwitchAddress string
SwitchPassword string
BandwidthMonitoringEnabled bool
AdminPassword string
ReaderPassword string
RedDefenseLightsAddress string
BlueDefenseLightsAddress string
InitialTowerStrength int
StemTvPublishingEnabled bool
StemTvEventCode 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.TBADownloadEnabled = true
// Game-specific default settings.
eventSettings.InitialTowerStrength = 10
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
}