forked from jordanmchavez/kdm-tts
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Expansion.ttslua
119 lines (100 loc) · 4.08 KB
/
Expansion.ttslua
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
local Check = require("Kdm/Util/Check")
---------------------------------------------------------------------------------------------------
local Core = require("Kdm/Expansion/Core")
local CommunityEdition = require("Kdm/Expansion/CommunityEdition")
local DragonKing = require("Kdm/Expansion/DragonKing")
local DungBeetleKnight = require("Kdm/Expansion/DungBeetleKnight")
local FlowerKnight = require("Kdm/Expansion/FlowerKnight")
local Gorm = require("Kdm/Expansion/Gorm")
local LionGod = require("Kdm/Expansion/LionGod")
local LionKnight = require("Kdm/Expansion/LionKnight")
local LonelyTree = require("Kdm/Expansion/LonelyTree")
local Manhunter = require("Kdm/Expansion/Manhunter")
local Slenderman = require("Kdm/Expansion/Slenderman")
local Spidicules = require("Kdm/Expansion/Spidicules")
local Sunstalker = require("Kdm/Expansion/Sunstalker")
local CcgHomebrew = require("Kdm/Expansion/CcgHomebrew")
local ForsakerSisters = require("Kdm/Expansion/ForsakerSisters")
local StormKnight = require("Kdm/Expansion/StormKnight")
local KingsCoin = require("Kdm/Expansion/KingsCoin")
local DrifterKnight = require("Kdm/Expansion/DrifterKnight")
local AllisonTheTwilightKnight = require("Kdm/Expansion/AllisonTheTwilightKnight")
local TracksOfDeath = require("Kdm/Expansion/TracksOfDeath")
local HarvesterWorm = require("Kdm/Expansion/HarvesterWorm")
---------------------------------------------------------------------------------------------------
local Expansion = {}
---------------------------------------------------------------------------------------------------
function Expansion.Init(saveState)
Expansion.allExpansions = {
Core,
CommunityEdition,
DragonKing,
DungBeetleKnight,
FlowerKnight,
Gorm,
LionGod,
LionKnight,
LonelyTree,
Manhunter,
Slenderman,
Spidicules,
Sunstalker,
CcgHomebrew,
ForsakerSisters,
StormKnight,
KingsCoin,
DrifterKnight,
AllisonTheTwilightKnight,
TracksOfDeath,
HarvesterWorm,
}
Expansion.expansionsByName = {}
for _, expansion in ipairs(Expansion.allExpansions) do
Expansion.expansionsByName[expansion.name] = expansion
end
Expansion.enabledByExpansionName = {}
for _, name in ipairs(saveState or {}) do
local expansion = Expansion.expansionsByName[name]
assert(Check(expansion, "Expansion save state had unknown expansion %s", name))
Expansion.enabledByExpansionName[name] = true
end
Expansion.enabledByExpansionName["Core"] = true
end
---------------------------------------------------------------------------------------------------
function Expansion.Save()
local enabledExpansions = {}
for name, enabled in pairs(Expansion.enabledByExpansionName) do
if enabled then
table.insert(enabledExpansions, name)
end
end
return enabledExpansions
end
---------------------------------------------------------------------------------------------------
function Expansion.All()
return Expansion.allExpansions
end
---------------------------------------------------------------------------------------------------
function Expansion.SetEnabled(enabledByExpansionName)
Expansion.enabledByExpansionName = {}
assert(Check.Table(enabledByExpansionName))
for expansionName, enabled in pairs(enabledByExpansionName) do
assert(Check.Str(expansionName))
assert(Check.BooleanOrNil(enabled))
Expansion.enabledByExpansionName[expansionName] = enabled
end
Expansion.enabledByExpansionName["Core"] = true
end
---------------------------------------------------------------------------------------------------
function Expansion.IsEnabled(expansionName)
assert(Check.Str(expansionName))
return Expansion.enabledByExpansionName[expansionName]
end
---------------------------------------------------------------------------------------------------
return {
Init = Expansion.Init,
Save = Expansion.Save,
All = Expansion.All,
SetEnabled = Expansion.SetEnabled,
IsEnabled = Expansion.IsEnabled,
}