-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDifficultBulletinBoardVars.lua
188 lines (145 loc) · 10.1 KB
/
DifficultBulletinBoardVars.lua
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
DifficultBulletinBoardSavedVariables = DifficultBulletinBoardSavedVariables or {}
DifficultBulletinBoardVars = DifficultBulletinBoardVars or {}
DifficultBulletinBoardDefaults = DifficultBulletinBoardDefaults or {}
DifficultBulletinBoardVars.version = DifficultBulletinBoardDefaults.version
DifficultBulletinBoardVars.fontSize = DifficultBulletinBoardDefaults.defaultFontSize
DifficultBulletinBoardVars.timeFormat = DifficultBulletinBoardDefaults.defaultTimeFormat
DifficultBulletinBoardVars.numberOfGroupPlaceholders = DifficultBulletinBoardDefaults.defaultNumberOfGroupPlaceholders
DifficultBulletinBoardVars.numberOfProfessionPlaceholders = DifficultBulletinBoardDefaults.defaultNumberOfProfessionPlaceholders
DifficultBulletinBoardVars.numberOfHardcorePlaceholders = DifficultBulletinBoardDefaults.defaultNumberOfHardcorePlaceholders
DifficultBulletinBoardVars.allGroupTopics = {}
DifficultBulletinBoardVars.allProfessionTopics = {}
DifficultBulletinBoardVars.allHardcoreTopics = {}
DifficultBulletinBoardSavedVariables.playerList = DifficultBulletinBoardSavedVariables.playerList or {}
local function print(string)
--DEFAULT_CHAT_FRAME:AddMessage(string)
end
-- Function to add a player to the database
function DifficultBulletinBoardVars.GetPlayerClassFromDatabase(name)
local realmName = GetRealmName()
-- Add or update the player entry
print("Getting Class for: " .. name)
if DifficultBulletinBoardSavedVariables.playerList[realmName][name] then
return DifficultBulletinBoardSavedVariables.playerList[realmName][name].class
else
return nil
end
end
-- Function to add a player to the database
function DifficultBulletinBoardVars.AddPlayerToDatabase(name, class)
local realmName = GetRealmName()
-- Add or update the player entry
print("Adding: " .. name .. " " .. class)
DifficultBulletinBoardSavedVariables.playerList[realmName][name] = {
class = class
}
-- Debugging: Print the players table to verify
--print("Players data:")
--local index = 0
--for realm, realmPlayers in pairs(DifficultBulletinBoardSavedVariables.playerList) do
-- print("Realm:", realm)
-- for name, data in pairs(realmPlayers) do
-- print(index .. ": " .. name .. " Class:" .. data.class)
-- index = index + 1
-- end
--end
end
-- Function to load saved variables
function DifficultBulletinBoardVars.LoadSavedVariables()
print("Start Loading DifficultBulletinBoardVars")
-- Ensure the root table exists
DifficultBulletinBoardSavedVariables = DifficultBulletinBoardSavedVariables or {}
-- Ensure the playerList table exists
DifficultBulletinBoardSavedVariables.playerList = DifficultBulletinBoardSavedVariables.playerList or {}
-- Helper to get the current realm name
local realmName = GetRealmName()
-- Ensure the realm-specific table exists
DifficultBulletinBoardSavedVariables.playerList[realmName] = DifficultBulletinBoardSavedVariables.playerList[realmName] or {}
if DifficultBulletinBoardSavedVariables.version then
local savedVersion = DifficultBulletinBoardSavedVariables.version
print("version did exist " .. savedVersion)
-- update the saved activeTopics if a new version of the topic list was released
if savedVersion < DifficultBulletinBoardVars.version then
print("version is older than the current version. overwriting activeTopics")
DifficultBulletinBoardVars.allGroupTopics = DifficultBulletinBoardDefaults.deepCopy(DifficultBulletinBoardDefaults.defaultGroupTopics)
DifficultBulletinBoardSavedVariables.activeGroupTopics = DifficultBulletinBoardVars.allGroupTopics
DifficultBulletinBoardVars.allProfessionTopics = DifficultBulletinBoardDefaults.deepCopy(DifficultBulletinBoardDefaults.defaultProfessionTopics)
DifficultBulletinBoardSavedVariables.activeProfessionTopics = DifficultBulletinBoardVars.allProfessionTopics
DifficultBulletinBoardVars.allHardcoreTopics = DifficultBulletinBoardDefaults.deepCopy(DifficultBulletinBoardDefaults.defaultHardcoreTopics)
DifficultBulletinBoardSavedVariables.activeHardcoreTopics = DifficultBulletinBoardVars.allHardcoreTopics
DifficultBulletinBoardSavedVariables.version = DifficultBulletinBoardVars.version
print("version is now " .. DifficultBulletinBoardVars.version)
end
else
print("version did not exist. overwriting version")
DifficultBulletinBoardSavedVariables.version = DifficultBulletinBoardVars.version
print("overwriting activeTopics")
DifficultBulletinBoardVars.allGroupTopics = DifficultBulletinBoardDefaults.deepCopy(DifficultBulletinBoardDefaults.defaultGroupTopics)
DifficultBulletinBoardSavedVariables.activeGroupTopics = DifficultBulletinBoardVars.allGroupTopics
DifficultBulletinBoardVars.allProfessionTopics = DifficultBulletinBoardDefaults.deepCopy(DifficultBulletinBoardDefaults.defaultProfessionTopics)
DifficultBulletinBoardSavedVariables.activeProfessionTopics = DifficultBulletinBoardVars.allProfessionTopics
DifficultBulletinBoardVars.allHardcoreTopics = DifficultBulletinBoardDefaults.deepCopy(DifficultBulletinBoardDefaults.defaultHardcoreTopics)
DifficultBulletinBoardSavedVariables.activeHardcoreTopics = DifficultBulletinBoardVars.allHardcoreTopics
end
if DifficultBulletinBoardSavedVariables.fontSize and DifficultBulletinBoardSavedVariables.fontSize ~= "" then
DifficultBulletinBoardVars.fontSize = DifficultBulletinBoardSavedVariables.fontSize
else
DifficultBulletinBoardVars.fontSize = DifficultBulletinBoardDefaults.defaultFontSize
DifficultBulletinBoardSavedVariables.fontSize = DifficultBulletinBoardVars.fontSize
end
if DifficultBulletinBoardSavedVariables.timeFormat and DifficultBulletinBoardSavedVariables.timeFormat ~= "" then
DifficultBulletinBoardVars.timeFormat = DifficultBulletinBoardSavedVariables.timeFormat
else
DifficultBulletinBoardVars.timeFormat = DifficultBulletinBoardDefaults.defaultTimeFormat
DifficultBulletinBoardSavedVariables.timeFormat = DifficultBulletinBoardVars.timeFormat
end
if DifficultBulletinBoardSavedVariables.mainFrameSound and DifficultBulletinBoardSavedVariables.mainFrameSound ~= "" then
DifficultBulletinBoardVars.mainFrameSound = DifficultBulletinBoardSavedVariables.mainFrameSound
else
DifficultBulletinBoardVars.mainFrameSound = DifficultBulletinBoardDefaults.defaultMainFrameSound
DifficultBulletinBoardSavedVariables.mainFrameSound = DifficultBulletinBoardVars.mainFrameSound
end
if DifficultBulletinBoardSavedVariables.optionFrameSound and DifficultBulletinBoardSavedVariables.optionFrameSound ~= "" then
DifficultBulletinBoardVars.optionFrameSound = DifficultBulletinBoardSavedVariables.optionFrameSound
else
DifficultBulletinBoardVars.optionFrameSound = DifficultBulletinBoardDefaults.defaultOptionFrameSound
DifficultBulletinBoardSavedVariables.optionFrameSound = DifficultBulletinBoardVars.optionFrameSound
end
if DifficultBulletinBoardSavedVariables.numberOfGroupPlaceholders and DifficultBulletinBoardSavedVariables.numberOfGroupPlaceholders ~= "" then
DifficultBulletinBoardVars.numberOfGroupPlaceholders = DifficultBulletinBoardSavedVariables.numberOfGroupPlaceholders
else
DifficultBulletinBoardVars.numberOfGroupPlaceholders = DifficultBulletinBoardDefaults.defaultNumberOfGroupPlaceholders
DifficultBulletinBoardSavedVariables.numberOfGroupPlaceholders = DifficultBulletinBoardVars.numberOfGroupPlaceholders
end
if DifficultBulletinBoardSavedVariables.numberOfProfessionPlaceholders and DifficultBulletinBoardSavedVariables.numberOfProfessionPlaceholders ~= "" then
DifficultBulletinBoardVars.numberOfProfessionPlaceholders = DifficultBulletinBoardSavedVariables.numberOfProfessionPlaceholders
else
DifficultBulletinBoardVars.numberOfProfessionPlaceholders = DifficultBulletinBoardDefaults.defaultNumberOfProfessionPlaceholders
DifficultBulletinBoardSavedVariables.numberOfProfessionPlaceholders = DifficultBulletinBoardVars.numberOfProfessionPlaceholders
end
if DifficultBulletinBoardSavedVariables.numberOfHardcorePlaceholders and DifficultBulletinBoardSavedVariables.numberOfHardcorePlaceholders ~= "" then
DifficultBulletinBoardVars.numberOfHardcorePlaceholders = DifficultBulletinBoardSavedVariables.numberOfHardcorePlaceholders
else
DifficultBulletinBoardVars.numberOfHardcorePlaceholders = DifficultBulletinBoardDefaults.defaultNumberOfHardcorePlaceholders
DifficultBulletinBoardSavedVariables.numberOfHardcorePlaceholders = DifficultBulletinBoardVars.numberOfHardcorePlaceholders
end
if DifficultBulletinBoardSavedVariables.activeGroupTopics then
DifficultBulletinBoardVars.allGroupTopics = DifficultBulletinBoardSavedVariables.activeGroupTopics
else
DifficultBulletinBoardVars.allGroupTopics = DifficultBulletinBoardDefaults.deepCopy(DifficultBulletinBoardDefaults.defaultGroupTopics)
DifficultBulletinBoardSavedVariables.activeGroupTopics = DifficultBulletinBoardVars.allGroupTopics
end
if DifficultBulletinBoardSavedVariables.activeProfessionTopics then
DifficultBulletinBoardVars.allProfessionTopics = DifficultBulletinBoardSavedVariables.activeProfessionTopics
else
DifficultBulletinBoardVars.allProfessionTopics = DifficultBulletinBoardDefaults.deepCopy(DifficultBulletinBoardDefaults.defaultProfessionTopics)
DifficultBulletinBoardSavedVariables.activeProfessionTopics = DifficultBulletinBoardVars.allProfessionTopics
end
if DifficultBulletinBoardSavedVariables.activeHardcoreTopics then
DifficultBulletinBoardVars.allHardcoreTopics = DifficultBulletinBoardSavedVariables.activeHardcoreTopics
else
DifficultBulletinBoardVars.allHardcoreTopics = DifficultBulletinBoardDefaults.deepCopy(DifficultBulletinBoardDefaults.defaultHardcoreTopics)
DifficultBulletinBoardSavedVariables.activeHardcoreTopics = DifficultBulletinBoardVars.allHardcoreTopics
end
print("Finished Loading DifficultBulletinBoardVars")
end