poi-plugin-mcp 0.2.11 → 0.2.12
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/index.js +1 -0
- package/lib/bridge-controller.js +1 -0
- package/lib/poi-http-bridge.js +7 -0
- package/lib/poi-telemetry.js +40 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const controller = createBridgeController({
|
|
|
7
7
|
getQuestList: telemetry.getQuestList,
|
|
8
8
|
getQuestAction: telemetry.getQuestAction,
|
|
9
9
|
getEquipmentAction: telemetry.getEquipmentAction,
|
|
10
|
+
getFleetAction: telemetry.getFleetAction,
|
|
10
11
|
getBattleTelemetry: telemetry.getBattleTelemetry,
|
|
11
12
|
})
|
|
12
13
|
const settingsClass = createSettingsClass(controller)
|
package/lib/bridge-controller.js
CHANGED
|
@@ -33,6 +33,7 @@ function createBridgeController(options = {}) {
|
|
|
33
33
|
getQuestList: options.getQuestList,
|
|
34
34
|
getQuestAction: options.getQuestAction,
|
|
35
35
|
getEquipmentAction: options.getEquipmentAction,
|
|
36
|
+
getFleetAction: options.getFleetAction,
|
|
36
37
|
getBattleTelemetry: options.getBattleTelemetry,
|
|
37
38
|
inputEnabled: settings.inputEnabled,
|
|
38
39
|
inputToken,
|
package/lib/poi-http-bridge.js
CHANGED
|
@@ -37,6 +37,8 @@ function createPoiDataBridge(options = {}) {
|
|
|
37
37
|
const getQuestAction = options.getQuestAction || (() => ({ available: false, generation: 0 }))
|
|
38
38
|
const getEquipmentAction = options.getEquipmentAction ||
|
|
39
39
|
(() => ({ available: false, generation: 0 }))
|
|
40
|
+
const getFleetAction = options.getFleetAction ||
|
|
41
|
+
(() => ({ available: false, generation: 0 }))
|
|
40
42
|
const getBattleTelemetry = options.getBattleTelemetry ||
|
|
41
43
|
(() => ({ available: false, generation: 0 }))
|
|
42
44
|
const inputEnabled = options.inputEnabled === true
|
|
@@ -257,6 +259,11 @@ function createPoiDataBridge(options = {}) {
|
|
|
257
259
|
return
|
|
258
260
|
}
|
|
259
261
|
|
|
262
|
+
if (endpoint === '/fleet-action') {
|
|
263
|
+
sendJson(res, 200, getFleetAction())
|
|
264
|
+
return
|
|
265
|
+
}
|
|
266
|
+
|
|
260
267
|
const store = readStore()
|
|
261
268
|
const info = store.info
|
|
262
269
|
|
package/lib/poi-telemetry.js
CHANGED
|
@@ -9,6 +9,7 @@ const EQUIPMENT_ACTION_PATHS = new Set([
|
|
|
9
9
|
'/kcsapi/api_req_kaisou/slot_deprive',
|
|
10
10
|
'/kcsapi/api_req_kaisou/unsetslot_all',
|
|
11
11
|
])
|
|
12
|
+
const FLEET_ACTION_PATH = '/kcsapi/api_req_hensei/change'
|
|
12
13
|
const BATTLE_RESULT_PATHS = new Set([
|
|
13
14
|
'/kcsapi/api_req_practice/battle_result',
|
|
14
15
|
'/kcsapi/api_req_sortie/battleresult',
|
|
@@ -45,6 +46,8 @@ function createPoiTelemetry(options = {}) {
|
|
|
45
46
|
let questAction = null
|
|
46
47
|
let equipmentActionGeneration = 0
|
|
47
48
|
let equipmentAction = null
|
|
49
|
+
let fleetActionGeneration = 0
|
|
50
|
+
let fleetAction = null
|
|
48
51
|
let battleGeneration = 0
|
|
49
52
|
let battleTelemetry = null
|
|
50
53
|
|
|
@@ -64,6 +67,10 @@ function createPoiTelemetry(options = {}) {
|
|
|
64
67
|
captureEquipmentAction(detail)
|
|
65
68
|
return
|
|
66
69
|
}
|
|
70
|
+
if (detail.path === FLEET_ACTION_PATH) {
|
|
71
|
+
captureFleetAction(detail)
|
|
72
|
+
return
|
|
73
|
+
}
|
|
67
74
|
if (BATTLE_RESULT_PATHS.has(detail.path)) {
|
|
68
75
|
captureBattleResult(detail)
|
|
69
76
|
return
|
|
@@ -142,6 +149,23 @@ function createPoiTelemetry(options = {}) {
|
|
|
142
149
|
}
|
|
143
150
|
}
|
|
144
151
|
|
|
152
|
+
function captureFleetAction(detail) {
|
|
153
|
+
const apiResult = equipmentApiResult(detail)
|
|
154
|
+
if (apiResult === 0) return
|
|
155
|
+
const postBody = normalizeFleetPostBody(detail.postBody)
|
|
156
|
+
if (!postBody) return
|
|
157
|
+
|
|
158
|
+
fleetActionGeneration += 1
|
|
159
|
+
fleetAction = {
|
|
160
|
+
available: true,
|
|
161
|
+
generation: fleetActionGeneration,
|
|
162
|
+
capturedAt: now().toISOString(),
|
|
163
|
+
path: detail.path,
|
|
164
|
+
apiResult,
|
|
165
|
+
postBody,
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
145
169
|
function captureBattlePacket(detail) {
|
|
146
170
|
if (!battleTelemetry || battleTelemetry.status === 'settled') {
|
|
147
171
|
battleGeneration += 1
|
|
@@ -207,12 +231,28 @@ function createPoiTelemetry(options = {}) {
|
|
|
207
231
|
getEquipmentAction() {
|
|
208
232
|
return equipmentAction || { available: false, generation: 0 }
|
|
209
233
|
},
|
|
234
|
+
getFleetAction() {
|
|
235
|
+
return fleetAction || { available: false, generation: 0 }
|
|
236
|
+
},
|
|
210
237
|
getBattleTelemetry() {
|
|
211
238
|
return battleTelemetry || { available: false, generation: 0 }
|
|
212
239
|
},
|
|
213
240
|
}
|
|
214
241
|
}
|
|
215
242
|
|
|
243
|
+
function normalizeFleetPostBody(postBody) {
|
|
244
|
+
if (!postBody || typeof postBody !== 'object') return null
|
|
245
|
+
const fleetId = boundedInteger(postBody.api_id, 1, 4)
|
|
246
|
+
const shipIndex = boundedInteger(postBody.api_ship_idx, 0, 5)
|
|
247
|
+
const shipId = boundedInteger(postBody.api_ship_id, -1)
|
|
248
|
+
if (fleetId == null || shipIndex == null || shipId == null) return null
|
|
249
|
+
return {
|
|
250
|
+
api_id: fleetId,
|
|
251
|
+
api_ship_idx: shipIndex,
|
|
252
|
+
api_ship_id: shipId,
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
216
256
|
function normalizeEquipmentPostBody(path, postBody) {
|
|
217
257
|
if (!postBody || typeof postBody !== 'object') return null
|
|
218
258
|
if (path === '/kcsapi/api_req_kaisou/slotset') {
|