Repository navigation
Expand file tree
/
Copy pathModifiers.lua
More file actions
158 lines (145 loc) · 4.55 KB
/
Copy pathModifiers.lua
File metadata and controls
158 lines (145 loc) · 4.55 KB
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
local ADDON_NAME, ns = ...
local Modifiers = {}
ns.Modifiers = Modifiers
local Utils = ns.Utils
local pairs = Utils.pairs
local ipairs = Utils.ipairs
-- No modifier is forced by difficulty. Difficulty comes from chart density and
-- speed, not gimmick modifiers, so every modifier stays purely optional. This
-- table is kept (empty) so the force-enable/required plumbing is inert, not
-- special-cased away.
local REQUIRED_MODIFIERS = {}
Modifiers.REQUIRED_MODIFIERS = REQUIRED_MODIFIERS
local MODIFIER_LIST = {
{
id = "fake",
name = "Fake",
desc = "Some notes show the wrong icon. Hitting a fake note costs points.",
unlockHint = "Beat Easy difficulty",
check = function()
local db = BoundToLearn.db.stats.difficultyBest
return db and db.Easy and db.Easy.highestScore > 0
end,
},
{
id = "angled",
name = "Angled",
desc = "Notes approach from random angles.",
unlockHint = "Beat Medium difficulty",
check = function()
local db = BoundToLearn.db.stats.difficultyBest
return db and db.Medium and db.Medium.highestScore > 0
end,
},
{
id = "squiggly",
name = "Squiggly",
desc = "Notes wave back and forth as they fall.",
unlockHint = "Reach a 20 combo",
check = function()
return BoundToLearn.db.stats.personalBest.longestCombo >= 20
end,
},
{
id = "fade",
name = "Fade",
desc = "Notes fade out as they approach the hit zone.",
unlockHint = "Earn Bronze rank on Hard",
check = function()
local db = BoundToLearn.db.stats.difficultyBest
return db and db.Hard and db.Hard.highestScore >= 100
end,
},
{
id = "accelerate",
name = "Accelerate",
desc = "Notes speed up as they fall.",
unlockHint = "Earn Silver rank on Hard",
check = function()
local db = BoundToLearn.db.stats.difficultyBest
return db and db.Hard and db.Hard.highestScore >= 300
end,
},
{
id = "doubles",
name = "Doubles",
desc = "Two notes can land at the same time, requiring simultaneous keypresses.",
descExtra = "Not available in Competitive mode (modifier keys conflict).",
unlockHint = "Earn Gold rank on Medium",
check = function()
local db = BoundToLearn.db.stats.difficultyBest
return db and db.Medium and db.Medium.highestScore >= 600
end,
},
{
id = "mirror",
name = "Mirror",
desc = "Lane order randomly flips during the round.",
unlockHint = "Earn Bronze rank on Extreme",
check = function()
local db = BoundToLearn.db.stats.difficultyBest
return db and db.Extreme and db.Extreme.highestScore >= 100
end,
},
}
Modifiers.MODIFIER_LIST = MODIFIER_LIST
local modifierByID = {}
for _, m in ipairs(MODIFIER_LIST) do
modifierByID[m.id] = m
end
function Modifiers:Get(id)
return modifierByID[id]
end
function Modifiers:IsUnlocked(id)
local m = modifierByID[id]
if not m then return false end
if m.check then return m.check() end
return false
end
function Modifiers:IsActive(id)
local active = self:GetActive()
return active[id] or false
end
-- Returns a set of active modifier IDs: { angled = true, fade = true }
function Modifiers:GetActive()
local saved = BoundToLearn.db.game.modifiers or {}
local active = {}
for id, enabled in pairs(saved) do
if enabled and self:IsUnlocked(id) then
active[id] = true
end
end
-- Force-enable required modifiers for current difficulty
local diff = BoundToLearn.db.game.difficulty
local required = REQUIRED_MODIFIERS[diff]
if required then
for _, id in ipairs(required) do
active[id] = true
end
end
return active
end
function Modifiers:IsRequired(id)
local diff = BoundToLearn.db.game.difficulty
local required = REQUIRED_MODIFIERS[diff]
if not required then return false end
for _, reqId in ipairs(required) do
if reqId == id then return true end
end
return false
end
function Modifiers:GetActiveCount()
local count = 0
for _ in pairs(self:GetActive()) do
count = count + 1
end
return count
end
function Modifiers:Toggle(id)
local saved = BoundToLearn.db.game.modifiers
if not saved then
saved = {}
BoundToLearn.db.game.modifiers = saved
end
saved[id] = not saved[id]
end