@quenty/scoredactionservice 16.53.0 → 16.53.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/deploy.nevermore.json +10 -0
- package/package.json +10 -7
- package/src/Client/InputList/InputListScoreHelper.spec.lua +306 -0
- package/src/Client/Picker/ScoredActionPicker.lua +5 -8
- package/src/Client/Picker/ScoredActionPicker.spec.lua +348 -0
- package/src/Client/Picker/ScoredActionPickerProvider.spec.lua +271 -0
- package/src/Client/Picker/TouchButtonScoredActionPicker.lua +22 -8
- package/src/Client/Picker/TouchButtonScoredActionPicker.spec.lua +278 -0
- package/src/Client/ScoredAction.spec.lua +262 -0
- package/src/Client/ScoredActionServiceClient.lua +9 -3
- package/src/Client/ScoredActionServiceClient.spec.lua +343 -0
- package/src/Client/ScoredActionUtils.spec.lua +187 -0
- package/src/Server/ScoredActionService.spec.lua +81 -0
- package/src/jest.config.lua +3 -0
- package/test/default.project.json +17 -0
- package/test/scripts/Server/ServerMain.server.lua +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [16.53.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@16.53.1...@quenty/scoredactionservice@16.53.2) (2026-07-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/scoredactionservice
|
|
9
|
+
|
|
10
|
+
## [16.53.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@16.53.0...@quenty/scoredactionservice@16.53.1) (2026-07-25)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- Fix things ([de8a3b5](https://github.com/Quenty/NevermoreEngine/commit/de8a3b5fbe2aa839f6fc928d4052405d3a13cd71))
|
|
15
|
+
|
|
6
16
|
# [16.53.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/scoredactionservice@16.52.0...@quenty/scoredactionservice@16.53.0) (2026-07-25)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @quenty/scoredactionservice
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/scoredactionservice",
|
|
3
|
-
"version": "16.53.
|
|
3
|
+
"version": "16.53.2",
|
|
4
4
|
"description": "Scores actions and picks the highest rated one every frame",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -30,20 +30,23 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@quenty/baseobject": "10.15.0",
|
|
33
|
-
"@quenty/brio": "14.35.
|
|
34
|
-
"@quenty/inputkeymaputils": "14.52.
|
|
35
|
-
"@quenty/inputmode": "13.40.
|
|
33
|
+
"@quenty/brio": "14.35.1",
|
|
34
|
+
"@quenty/inputkeymaputils": "14.52.2",
|
|
35
|
+
"@quenty/inputmode": "13.40.1",
|
|
36
36
|
"@quenty/loader": "10.11.0",
|
|
37
37
|
"@quenty/maid": "3.11.0",
|
|
38
|
+
"@quenty/nevermore-test-runner": "1.5.0",
|
|
38
39
|
"@quenty/rx": "13.33.0",
|
|
39
40
|
"@quenty/servicebag": "11.20.0",
|
|
40
41
|
"@quenty/signal": "7.13.1",
|
|
41
|
-
"@quenty/statestack": "14.37.
|
|
42
|
+
"@quenty/statestack": "14.37.1",
|
|
43
|
+
"@quenty/steputils": "3.7.1",
|
|
42
44
|
"@quenty/table": "3.9.2",
|
|
43
|
-
"@quenty/valueobject": "13.36.
|
|
45
|
+
"@quenty/valueobject": "13.36.1",
|
|
46
|
+
"@quentystudios/jest-lua": "3.10.0-quenty.2"
|
|
44
47
|
},
|
|
45
48
|
"publishConfig": {
|
|
46
49
|
"access": "public"
|
|
47
50
|
},
|
|
48
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b2fa2984c2ea6e83136e5a7cbf57b14038d9a265"
|
|
49
52
|
}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--[[
|
|
3
|
+
@class InputListScoreHelper.spec.lua
|
|
4
|
+
]]
|
|
5
|
+
|
|
6
|
+
local require = require(script.Parent.loader).load(script)
|
|
7
|
+
|
|
8
|
+
local InputKeyMap = require("InputKeyMap")
|
|
9
|
+
local InputKeyMapList = require("InputKeyMapList")
|
|
10
|
+
local InputListScoreHelper = require("InputListScoreHelper")
|
|
11
|
+
local InputModeServiceClient = require("InputModeServiceClient")
|
|
12
|
+
local InputModeType = require("InputModeType")
|
|
13
|
+
local InputModeTypes = require("InputModeTypes")
|
|
14
|
+
local Jest = require("Jest")
|
|
15
|
+
local Maid = require("Maid")
|
|
16
|
+
local ScoredAction = require("ScoredAction")
|
|
17
|
+
local ScoredActionPickerProvider = require("ScoredActionPickerProvider")
|
|
18
|
+
local ServiceBag = require("ServiceBag")
|
|
19
|
+
|
|
20
|
+
local describe = Jest.Globals.describe
|
|
21
|
+
local expect = Jest.Globals.expect
|
|
22
|
+
local it = Jest.Globals.it
|
|
23
|
+
|
|
24
|
+
local function setup(): any
|
|
25
|
+
local maid = Maid.new()
|
|
26
|
+
|
|
27
|
+
local serviceBag: any = maid:Add(ServiceBag.new())
|
|
28
|
+
local inputModeServiceClient = serviceBag:GetService(InputModeServiceClient)
|
|
29
|
+
serviceBag:Init()
|
|
30
|
+
serviceBag:Start()
|
|
31
|
+
|
|
32
|
+
local controller = {
|
|
33
|
+
serviceBag = serviceBag,
|
|
34
|
+
|
|
35
|
+
activate = function(inputModeType: InputModeType.InputModeType)
|
|
36
|
+
inputModeServiceClient:GetInputMode(inputModeType):Enable()
|
|
37
|
+
end,
|
|
38
|
+
|
|
39
|
+
newList = function(inputKeyMaps: { InputKeyMap.InputKeyMap })
|
|
40
|
+
return maid:Add(InputKeyMapList.new("SPEC_ACTION", inputKeyMaps, {
|
|
41
|
+
bindingName = "Spec Action",
|
|
42
|
+
rebindable = false,
|
|
43
|
+
})) :: any
|
|
44
|
+
end,
|
|
45
|
+
|
|
46
|
+
newProvider = function()
|
|
47
|
+
return maid:Add(ScoredActionPickerProvider.new()) :: any
|
|
48
|
+
end,
|
|
49
|
+
|
|
50
|
+
newLooseProvider = function()
|
|
51
|
+
return ScoredActionPickerProvider.new()
|
|
52
|
+
end,
|
|
53
|
+
|
|
54
|
+
newAction = function()
|
|
55
|
+
local action: ScoredAction.ScoredAction = maid:Add(ScoredAction.new()) :: any
|
|
56
|
+
action:SetScore(1)
|
|
57
|
+
return action
|
|
58
|
+
end,
|
|
59
|
+
|
|
60
|
+
newHelper = function(provider, action, list)
|
|
61
|
+
return maid:Add(InputListScoreHelper.new(serviceBag, provider, action, list)) :: any
|
|
62
|
+
end,
|
|
63
|
+
|
|
64
|
+
newLooseHelper = function(provider, action, list)
|
|
65
|
+
return InputListScoreHelper.new(serviceBag, provider, action, list)
|
|
66
|
+
end,
|
|
67
|
+
|
|
68
|
+
pickerHasActions = function(provider, inputType)
|
|
69
|
+
local picker: any = provider:FindPicker(inputType)
|
|
70
|
+
if not picker then
|
|
71
|
+
return nil
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
return picker:HasActions()
|
|
75
|
+
end,
|
|
76
|
+
|
|
77
|
+
destroy = function()
|
|
78
|
+
maid:DoCleaning()
|
|
79
|
+
end,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return controller
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe("InputListScoreHelper.new", function()
|
|
86
|
+
it("registers the action against the active input mode's keys", function()
|
|
87
|
+
local controller = setup()
|
|
88
|
+
controller.activate(InputModeTypes.Keyboard)
|
|
89
|
+
|
|
90
|
+
local provider = controller.newProvider()
|
|
91
|
+
local action = controller.newAction()
|
|
92
|
+
local list = controller.newList({
|
|
93
|
+
InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E }),
|
|
94
|
+
InputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.ButtonX }),
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
controller.newHelper(provider, action, list)
|
|
98
|
+
|
|
99
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(true)
|
|
100
|
+
expect(provider:FindPicker(Enum.KeyCode.ButtonX)).toBeNil()
|
|
101
|
+
expect(action:IsPreferred()).toBe(true)
|
|
102
|
+
|
|
103
|
+
controller.destroy()
|
|
104
|
+
end)
|
|
105
|
+
|
|
106
|
+
it("registers every key in the active input mode", function()
|
|
107
|
+
local controller = setup()
|
|
108
|
+
controller.activate(InputModeTypes.Keyboard)
|
|
109
|
+
|
|
110
|
+
local provider = controller.newProvider()
|
|
111
|
+
local list = controller.newList({
|
|
112
|
+
InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E, Enum.KeyCode.Q }),
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
controller.newHelper(provider, controller.newAction(), list)
|
|
116
|
+
|
|
117
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(true)
|
|
118
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.Q)).toBe(true)
|
|
119
|
+
|
|
120
|
+
controller.destroy()
|
|
121
|
+
end)
|
|
122
|
+
|
|
123
|
+
it("registers nothing for an empty key list", function()
|
|
124
|
+
local controller = setup()
|
|
125
|
+
controller.activate(InputModeTypes.Keyboard)
|
|
126
|
+
|
|
127
|
+
local provider = controller.newProvider()
|
|
128
|
+
local list = controller.newList({
|
|
129
|
+
InputKeyMap.new(InputModeTypes.Keyboard, {}),
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
controller.newHelper(provider, controller.newAction(), list)
|
|
133
|
+
|
|
134
|
+
expect(provider:FindPicker(Enum.KeyCode.E)).toBeNil()
|
|
135
|
+
|
|
136
|
+
controller.destroy()
|
|
137
|
+
end)
|
|
138
|
+
|
|
139
|
+
it("throws without a serviceBag", function()
|
|
140
|
+
local controller = setup()
|
|
141
|
+
local list = controller.newList({ InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E }) })
|
|
142
|
+
|
|
143
|
+
expect(function()
|
|
144
|
+
(InputListScoreHelper :: any).new(nil, controller.newProvider(), controller.newAction(), list)
|
|
145
|
+
end).toThrow()
|
|
146
|
+
|
|
147
|
+
controller.destroy()
|
|
148
|
+
end)
|
|
149
|
+
|
|
150
|
+
it("throws without a provider", function()
|
|
151
|
+
local controller = setup()
|
|
152
|
+
local list = controller.newList({ InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E }) })
|
|
153
|
+
|
|
154
|
+
expect(function()
|
|
155
|
+
(InputListScoreHelper :: any).new(controller.serviceBag, nil, controller.newAction(), list)
|
|
156
|
+
end).toThrow()
|
|
157
|
+
|
|
158
|
+
controller.destroy()
|
|
159
|
+
end)
|
|
160
|
+
|
|
161
|
+
it("throws without a scoredAction", function()
|
|
162
|
+
local controller = setup()
|
|
163
|
+
local list = controller.newList({ InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E }) })
|
|
164
|
+
|
|
165
|
+
expect(function()
|
|
166
|
+
(InputListScoreHelper :: any).new(controller.serviceBag, controller.newProvider(), nil, list)
|
|
167
|
+
end).toThrow()
|
|
168
|
+
|
|
169
|
+
controller.destroy()
|
|
170
|
+
end)
|
|
171
|
+
|
|
172
|
+
it("throws on something that is not an inputKeyMapList", function()
|
|
173
|
+
local controller = setup()
|
|
174
|
+
|
|
175
|
+
expect(function()
|
|
176
|
+
(InputListScoreHelper :: any).new(
|
|
177
|
+
controller.serviceBag,
|
|
178
|
+
controller.newProvider(),
|
|
179
|
+
controller.newAction(),
|
|
180
|
+
{}
|
|
181
|
+
)
|
|
182
|
+
end).toThrow()
|
|
183
|
+
|
|
184
|
+
controller.destroy()
|
|
185
|
+
end)
|
|
186
|
+
end)
|
|
187
|
+
|
|
188
|
+
describe("InputListScoreHelper input mode changes", function()
|
|
189
|
+
it("moves the action to the newly active input mode", function()
|
|
190
|
+
local controller = setup()
|
|
191
|
+
controller.activate(InputModeTypes.Keyboard)
|
|
192
|
+
|
|
193
|
+
local provider = controller.newProvider()
|
|
194
|
+
local action = controller.newAction()
|
|
195
|
+
local list = controller.newList({
|
|
196
|
+
InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E }),
|
|
197
|
+
InputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.ButtonX }),
|
|
198
|
+
})
|
|
199
|
+
controller.newHelper(provider, action, list)
|
|
200
|
+
|
|
201
|
+
controller.activate(InputModeTypes.Gamepads)
|
|
202
|
+
|
|
203
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(false)
|
|
204
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.ButtonX)).toBe(true)
|
|
205
|
+
|
|
206
|
+
controller.destroy()
|
|
207
|
+
end)
|
|
208
|
+
|
|
209
|
+
it("keeps a key that both input modes share", function()
|
|
210
|
+
local controller = setup()
|
|
211
|
+
controller.activate(InputModeTypes.Keyboard)
|
|
212
|
+
|
|
213
|
+
local provider = controller.newProvider()
|
|
214
|
+
local action = controller.newAction()
|
|
215
|
+
local list = controller.newList({
|
|
216
|
+
InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E }),
|
|
217
|
+
InputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.E }),
|
|
218
|
+
})
|
|
219
|
+
controller.newHelper(provider, action, list)
|
|
220
|
+
|
|
221
|
+
controller.activate(InputModeTypes.Gamepads)
|
|
222
|
+
|
|
223
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(true)
|
|
224
|
+
expect(action:IsPreferred()).toBe(true)
|
|
225
|
+
|
|
226
|
+
controller.destroy()
|
|
227
|
+
end)
|
|
228
|
+
|
|
229
|
+
it("follows a rebind of the active input mode", function()
|
|
230
|
+
local controller = setup()
|
|
231
|
+
controller.activate(InputModeTypes.Keyboard)
|
|
232
|
+
|
|
233
|
+
local provider = controller.newProvider()
|
|
234
|
+
local list = controller.newList({
|
|
235
|
+
InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E }),
|
|
236
|
+
})
|
|
237
|
+
controller.newHelper(provider, controller.newAction(), list)
|
|
238
|
+
|
|
239
|
+
list:SetInputTypesList(InputModeTypes.Keyboard, { Enum.KeyCode.Q })
|
|
240
|
+
|
|
241
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(false)
|
|
242
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.Q)).toBe(true)
|
|
243
|
+
|
|
244
|
+
controller.destroy()
|
|
245
|
+
end)
|
|
246
|
+
|
|
247
|
+
it("unregisters the action when the list loses its only input mode", function()
|
|
248
|
+
local controller = setup()
|
|
249
|
+
controller.activate(InputModeTypes.Keyboard)
|
|
250
|
+
|
|
251
|
+
local provider = controller.newProvider()
|
|
252
|
+
local action = controller.newAction()
|
|
253
|
+
local list = controller.newList({
|
|
254
|
+
InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E }),
|
|
255
|
+
})
|
|
256
|
+
controller.newHelper(provider, action, list)
|
|
257
|
+
|
|
258
|
+
list:RemoveInputModeType(InputModeTypes.Keyboard)
|
|
259
|
+
|
|
260
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(false)
|
|
261
|
+
expect(action:IsPreferred()).toBe(false)
|
|
262
|
+
|
|
263
|
+
controller.destroy()
|
|
264
|
+
end)
|
|
265
|
+
end)
|
|
266
|
+
|
|
267
|
+
describe("InputListScoreHelper.Destroy", function()
|
|
268
|
+
it("unregisters the action from every picker it registered", function()
|
|
269
|
+
local controller = setup()
|
|
270
|
+
controller.activate(InputModeTypes.Keyboard)
|
|
271
|
+
|
|
272
|
+
local provider = controller.newProvider()
|
|
273
|
+
local action = controller.newAction()
|
|
274
|
+
local list = controller.newList({
|
|
275
|
+
InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E, Enum.KeyCode.Q }),
|
|
276
|
+
})
|
|
277
|
+
local helper = controller.newLooseHelper(provider, action, list)
|
|
278
|
+
|
|
279
|
+
helper:Destroy()
|
|
280
|
+
|
|
281
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.E)).toBe(false)
|
|
282
|
+
expect(controller.pickerHasActions(provider, Enum.KeyCode.Q)).toBe(false)
|
|
283
|
+
expect(action:IsPreferred()).toBe(false)
|
|
284
|
+
|
|
285
|
+
controller.destroy()
|
|
286
|
+
end)
|
|
287
|
+
|
|
288
|
+
it("tolerates a provider destroyed first", function()
|
|
289
|
+
local controller = setup()
|
|
290
|
+
controller.activate(InputModeTypes.Keyboard)
|
|
291
|
+
|
|
292
|
+
local provider = controller.newLooseProvider()
|
|
293
|
+
local list = controller.newList({
|
|
294
|
+
InputKeyMap.new(InputModeTypes.Keyboard, { Enum.KeyCode.E }),
|
|
295
|
+
})
|
|
296
|
+
local helper = controller.newLooseHelper(provider, controller.newAction(), list)
|
|
297
|
+
|
|
298
|
+
provider:Destroy()
|
|
299
|
+
|
|
300
|
+
expect(function()
|
|
301
|
+
helper:Destroy()
|
|
302
|
+
end).never.toThrow()
|
|
303
|
+
|
|
304
|
+
controller.destroy()
|
|
305
|
+
end)
|
|
306
|
+
end)
|
|
@@ -46,11 +46,6 @@ function ScoredActionPicker.new()
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
function ScoredActionPicker.Update(self: ScoredActionPicker): ()
|
|
49
|
-
if not next(self._actionSet) then
|
|
50
|
-
self._currentPreferred.Value = nil
|
|
51
|
-
return
|
|
52
|
-
end
|
|
53
|
-
|
|
54
49
|
local actionList: { ScoredAction.ScoredAction } = {}
|
|
55
50
|
for action: any, _ in self._actionSet do
|
|
56
51
|
if not action.Destroy then
|
|
@@ -82,13 +77,15 @@ function ScoredActionPicker.Update(self: ScoredActionPicker): ()
|
|
|
82
77
|
)
|
|
83
78
|
end
|
|
84
79
|
|
|
80
|
+
local preferred: ScoredAction.ScoredAction? = nil
|
|
85
81
|
for _, action: any in actionList do
|
|
86
|
-
|
|
87
|
-
if
|
|
88
|
-
self._currentPreferred.Value = preferredAction
|
|
82
|
+
preferred = self:_tryGetValidPreferredAction(action)
|
|
83
|
+
if preferred then
|
|
89
84
|
break
|
|
90
85
|
end
|
|
91
86
|
end
|
|
87
|
+
|
|
88
|
+
self._currentPreferred.Value = preferred
|
|
92
89
|
end
|
|
93
90
|
|
|
94
91
|
function ScoredActionPicker._tryGetValidPreferredAction(
|