poi-plugin-quest-info-2 0.11.0 → 0.12.0

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # poi-plugin-quest-info-2
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7ba3993: Check the quest chain full completed
8
+
9
+ ### Patch Changes
10
+
11
+ - d80267b: Update quest data
12
+
3
13
  ## 0.11.0
4
14
 
5
15
  ### Minor Changes
@@ -1 +1 @@
1
- ff326d93a76cbfef36a1f3c9b4a8e3be4ac50583
1
+ 53b0db6d5a521bcf934878d07918e06b9fceaef1
@@ -4,4 +4,4 @@ export const KcwikiQuestData = {
4
4
  'zh-CN': zh_CN,
5
5
  }
6
6
 
7
- export const version = 'ff326d93a76cbfef36a1f3c9b4a8e3be4ac50583'
7
+ export const version = '53b0db6d5a521bcf934878d07918e06b9fceaef1'
@@ -1,5 +1,10 @@
1
1
  [
2
2
  "314",
3
+ "370",
4
+ "962",
5
+ "963",
6
+ "964",
7
+ "965",
3
8
  "992",
4
9
  "994"
5
10
  ]
@@ -2503,6 +2503,16 @@
2503
2503
  ],
2504
2504
  "rewards": "奖励:以下奖励三选一: 伊良湖 高速修复材 ×3 开发资材 ×3 以下奖励三选一: 「12.7cm 连装炮 C 型改二」 新型兵装资材 ×2 「强化型舰本式缶」×3"
2505
2505
  },
2506
+ "370": {
2507
+ "code": "2311C2",
2508
+ "desc": "以包含「鹿岛」、「択捉」、「松轮」、「佐渡」、「福江」、「鹈来」、「岸波」、「早波」、「谷风」、「江风」、「山云」、「朝云」、「山汐丸」以及丁型海防舰中的至少 4 艘舰艇组成舰队,在本周内进行演习,取得 5 次【A 胜】以上!",
2509
+ "memo2": "每周任务 演习舰队中包括【鹿岛、択捉、松轮、佐渡、福江、鹈来、岸波、早波、谷风、江风、山云、朝云、山汐丸】以及丁型海防舰(第四、二十二、三〇号海防舰)中至少 4 艘,本周演习 A 胜以上 5 次。",
2510
+ "name": "【Xmas 限定】圣诞夜海上护卫队演习",
2511
+ "pre": [
2512
+ "B6"
2513
+ ],
2514
+ "rewards": "奖励:以下奖励二选一: 伊良湖 ×1 开发资材 ×3 以下奖励二选一: 改修资材 ×2 高速修复材 ×3"
2515
+ },
2506
2516
  "401": {
2507
2517
  "code": "D1",
2508
2518
  "desc": "舰队出发「远征」!",
@@ -5459,6 +5469,48 @@
5459
5469
  ],
5460
5470
  "rewards": "奖励:以下奖励三选一: 特制家具职人 新型火炮兵装资材 ×2 改修资材 ×5 \n以下奖励三选一:' 61cm 四連装 (酸素) 魚雷後期型 新型兵装资材 ×4 战斗详报"
5461
5471
  },
5472
+ "962": {
5473
+ "code": "2311B6",
5474
+ "desc": "【圣诞限定任务】以包含「夕云」、「早波」、「浜波」、「卷波」、「朧」、「漣」、「潮」、「曙」中至少 4 艘舰艇组成的舰队,在镇守府正面海域、炼油厂地带沿岸、南西群岛防卫线及镇守府近海进行反复出击!驱逐敌人!",
5475
+ "memo2": "舰队包含【夕云 / 早波 / 滨波 / 卷波 / 胧 / 涟 / 潮 / 曙】中的 4 艘,取得 1-1、1-3、1-4、1-5 各 S 胜 2 次。",
5476
+ "name": "【圣诞快乐】驱逐舰队,出击!",
5477
+ "pre": [
5478
+ "B2",
5479
+ "D1"
5480
+ ],
5481
+ "rewards": "奖励:礼物箱 ×1 以下奖励三选一: 开发资材 ×10 改修资材 ×4 特制家具职人 ×1 "
5482
+ },
5483
+ "963": {
5484
+ "code": "2311B7",
5485
+ "desc": "【圣诞限定任务】以旗舰和僚舰为「大淀」「那珂」「酒匂」「矢矧改二 / 乙」「谢菲尔德」「德・鲁伊特」「哥特兰」的舰队,反复歼灭东部奥廖尔海和冲之岛海域的敌人!",
5486
+ "memo2": "在【大淀 / 那珂 / 酒匂 / 矢矧改二 (乙)/Sheffield/De Ruyter/Gotland】中任选 2 艘(并将其中之一设置为旗舰)。取得 2-3、2-4 各 S 胜 2 次。",
5487
+ "name": "【圣诞限定】圣夜的轻巡,拔锚!",
5488
+ "pre": [
5489
+ "2311B6"
5490
+ ],
5491
+ "rewards": "奖励:以下奖励三选一: 「新型高温高压缶」★+2 新型火炮兵装资材 ×2 高速修复材 ×6 以下奖励三选一: 「15.2cm 连装炮改」★+4 「8cm 高角炮」★+8 勋章 ×1 "
5492
+ },
5493
+ "964": {
5494
+ "code": "2311B8",
5495
+ "desc": "以旗舰和僚舰为「神威」「瑞穗」「迅鲸」「长鲸」「明石」「塔斯特司令官」「内华达」「鹿岛」「宗谷」的舰队,在爪姆岛近海、马绍尔群岛近海和古阿诺环礁海域海域反复取得 S 胜利!",
5496
+ "memo2": "在【神威 / 瑞穂 / 速吸 / 迅鯨 / 長鯨 / 明石 / 朝日 / Commandant Teste/Nevada/ 鹿島 / 宗谷】中任选 2 艘(并将其中之一设置为旗舰)。取得 4-1、6-2、6-3 各 S 胜 2 次。",
5497
+ "name": "【圣诞扩张作战 I】圣诞特务舰,作战开始!",
5498
+ "pre": [
5499
+ "2311B7",
5500
+ "D18"
5501
+ ],
5502
+ "rewards": "奖励:以下奖励三选一: 熟练搭乘员 ×2 「14cm 连装炮改二」 改修资材 ×6 以下奖励三选一: 新型火炮兵装资材 ×3 新型兵装资材 ×3 「Barracuda Mk.II」 "
5503
+ },
5504
+ "965": {
5505
+ "code": "2311B9",
5506
+ "desc": "以包含「厌战」「谢菲尔德」「休斯顿」「铃谷」「熊野」「衣笠」之中 3 艘以上的圣诞合同舰队,反复出击咖喱洋里兰卡岛海域、萨部岛近海海域和中部北海域孔雀岛近海!歼灭敌人!",
5507
+ "memo2": "舰队包括【Warspite/Sheffield/Houston/ 鈴谷 / 熊野 / 衣笠】中选择 3 艘,取得 4-5、5-3、6-4 各 S 胜 2 次。",
5508
+ "name": "【圣诞扩张作战 II】圣诞最终决战,发动!",
5509
+ "pre": [
5510
+ "2311B8"
5511
+ ],
5512
+ "rewards": "奖励:以下奖励三选一: 「一式陆攻二二型甲」×2 「银河」 「Barracuda Mk.II」×2 以下奖励三选一: 新型航空兵装资材 ×3 勋章 ×2 Ne 式引擎 "
5513
+ },
5462
5514
  "966": {
5463
5515
  "code": "B175",
5464
5516
  "desc": "击破南西诸岛近海,巴士海峡,东部奥廖尔海,槟榔屿深部的敌舰队!经由昭南本土航路于台湾停泊。准备「设营队」×1,在当地展开可用于空中掩护的南西海域「基地航空队」!",
@@ -884,7 +884,8 @@
884
884
  "post": [
885
885
  "B4",
886
886
  "E1",
887
- "E2"
887
+ "E2",
888
+ "2311B6"
888
889
  ]
889
890
  },
890
891
  "204": {
@@ -921,6 +922,7 @@
921
922
  "C15",
922
923
  "Cs5",
923
924
  "C32",
925
+ "2311C2",
924
926
  "F73",
925
927
  "B67",
926
928
  "B82",
@@ -2210,6 +2212,12 @@
2210
2212
  "2307B1"
2211
2213
  ]
2212
2214
  },
2215
+ "370": {
2216
+ "pre": [
2217
+ "B6"
2218
+ ],
2219
+ "post": []
2220
+ },
2213
2221
  "401": {
2214
2222
  "pre": [
2215
2223
  "A5"
@@ -2217,7 +2225,8 @@
2217
2225
  "post": [
2218
2226
  "Dd1",
2219
2227
  "Dw1",
2220
- "B107"
2228
+ "B107",
2229
+ "2311B6"
2221
2230
  ]
2222
2231
  },
2223
2232
  "402": {
@@ -2358,6 +2367,7 @@
2358
2367
  ],
2359
2368
  "post": [
2360
2369
  "Dm1",
2370
+ "2311B8",
2361
2371
  "B186"
2362
2372
  ]
2363
2373
  },
@@ -4529,6 +4539,38 @@
4529
4539
  "B184"
4530
4540
  ]
4531
4541
  },
4542
+ "962": {
4543
+ "pre": [
4544
+ "B2",
4545
+ "D1"
4546
+ ],
4547
+ "post": [
4548
+ "2311B7"
4549
+ ]
4550
+ },
4551
+ "963": {
4552
+ "pre": [
4553
+ "2311B6"
4554
+ ],
4555
+ "post": [
4556
+ "2311B8"
4557
+ ]
4558
+ },
4559
+ "964": {
4560
+ "pre": [
4561
+ "D18",
4562
+ "2311B7"
4563
+ ],
4564
+ "post": [
4565
+ "2311B9"
4566
+ ]
4567
+ },
4568
+ "965": {
4569
+ "pre": [
4570
+ "2311B8"
4571
+ ],
4572
+ "post": []
4573
+ },
4532
4574
  "966": {
4533
4575
  "pre": [
4534
4576
  "B113",
@@ -248,6 +248,7 @@
248
248
  "C75": 365,
249
249
  "C76": 366,
250
250
  "Cy11": 368,
251
+ "2311C2": 370,
251
252
  "D1": 401,
252
253
  "Dd1": 402,
253
254
  "Dd2": 403,
@@ -531,6 +532,10 @@
531
532
  "B172": 957,
532
533
  "B173": 958,
533
534
  "B174": 961,
535
+ "2311B6": 962,
536
+ "2311B7": 963,
537
+ "2311B8": 964,
538
+ "2311B9": 965,
534
539
  "B175": 966,
535
540
  "B176": 967,
536
541
  "B177": 968,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poi-plugin-quest-info-2",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "private": false,
5
5
  "description": "show quest info",
6
6
  "homepage": "https://github.com/lawvs/poi-plugin-quest-2/",
@@ -421,6 +421,10 @@ exports[`questHelper should 101 locked quests match snapshot 1`] = `
421
421
  "949": true,
422
422
  "958": true,
423
423
  "961": true,
424
+ "962": true,
425
+ "963": true,
426
+ "964": true,
427
+ "965": true,
424
428
  "966": true,
425
429
  "967": true,
426
430
  "968": true,
@@ -4,7 +4,7 @@ import newQuestData from '../../build/kcQuestsData/quests-scn-new.json'
4
4
  describe('should version correct', () => {
5
5
  test('should KcwikiQuestData Game data version correct', () => {
6
6
  expect(version).toMatchInlineSnapshot(
7
- `"ff326d93a76cbfef36a1f3c9b4a8e3be4ac50583"`,
7
+ `"53b0db6d5a521bcf934878d07918e06b9fceaef1"`,
8
8
  )
9
9
  })
10
10
 
@@ -1,11 +1,18 @@
1
1
  import {
2
+ calcQuestMap,
2
3
  getCompletedQuest,
3
4
  getLockedQuest,
4
5
  getPostQuestIds,
5
6
  getPreQuestIds,
7
+ getQuestCodeByGameId,
6
8
  } from '../questHelper'
7
9
 
8
10
  describe('questHelper', () => {
11
+ test('should getQuestCodeByGameId correct', () => {
12
+ expect(getQuestCodeByGameId(0)).toEqual(null)
13
+ expect(getQuestCodeByGameId(101)).toEqual('A1')
14
+ })
15
+
9
16
  test('should getPreQuestIds correct', () => {
10
17
  expect(getPreQuestIds(101)).toEqual([])
11
18
  expect(getPreQuestIds(102)).toEqual([101])
@@ -23,11 +30,11 @@ describe('questHelper', () => {
23
30
  })
24
31
 
25
32
  test('should getCompletedQuest quest match snapshot', () => {
26
- expect(getCompletedQuest([817])).toMatchSnapshot()
33
+ expect(calcQuestMap([817], getPreQuestIds)).toMatchSnapshot()
27
34
  })
28
35
 
29
36
  test('should 236 getCompletedQuest correct', () => {
30
- expect(getCompletedQuest([236])).toMatchSnapshot()
37
+ expect(calcQuestMap([236], getPreQuestIds)).toMatchSnapshot()
31
38
  })
32
39
 
33
40
  test('should 101 locked quests match snapshot', () => {
@@ -211,6 +211,24 @@ export const getQuestPrePost = (gameId: number) => {
211
211
  return prePostQuest[String(gameId) as keyof typeof prePostQuest]
212
212
  }
213
213
 
214
+ const getNoPostQuestIds = (): number[] => {
215
+ const noPostQuestIds = []
216
+ for (const [gameId, { post }] of Object.entries(prePostQuest)) {
217
+ if (!post.length) {
218
+ noPostQuestIds.push(+gameId)
219
+ }
220
+ }
221
+ return noPostQuestIds
222
+ }
223
+
224
+ /**
225
+ * Get quest id by quest code
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * getQuestIdByCode('A1') // 101
230
+ * ```
231
+ */
214
232
  export const getQuestIdByCode = (code: string) => {
215
233
  if (code in questCodeMap) {
216
234
  return questCodeMap[code as keyof typeof questCodeMap]
@@ -218,17 +236,62 @@ export const getQuestIdByCode = (code: string) => {
218
236
  return null
219
237
  }
220
238
 
239
+ export const getQuestCodeByGameId = (gameId: number) => {
240
+ const questCode = Object.entries(questCodeMap).find(([, id]) => id === gameId)
241
+ if (!questCode) {
242
+ return null
243
+ }
244
+ return questCode[0]
245
+ }
246
+
247
+ /**
248
+ * Get pre quest ids by quest id
249
+ *
250
+ * @example
251
+ * ```ts
252
+ * // Quest id A2's pre quest id is A1
253
+ * getPreQuestIds(102) // [101]
254
+ * ```
255
+ */
221
256
  export const getPreQuestIds = (gameId: number): number[] =>
222
257
  getQuestPrePost(gameId)
223
258
  .pre.map((code) => getQuestIdByCode(code))
224
259
  .filter(Boolean) as number[]
225
260
 
261
+ const getAllPreQuestIds = (gameId: number): number[] => {
262
+ const set = new Set<number>()
263
+ const queue = [gameId]
264
+ while (queue.length) {
265
+ const gameId = queue.shift()!
266
+ getPreQuestIds(gameId).forEach((preGameId) => {
267
+ if (set.has(preGameId)) {
268
+ return
269
+ }
270
+ set.add(preGameId)
271
+ queue.push(preGameId)
272
+ })
273
+ }
274
+ return Array.from(set)
275
+ }
276
+
277
+ /**
278
+ * Get post quest ids by quest id
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * // Quest id A1's post quest id is A2
283
+ * getPreQuestIds(101) // [102]
284
+ * ```
285
+ */
226
286
  export const getPostQuestIds = (gameId: number): number[] =>
227
287
  getQuestPrePost(gameId)
228
288
  .post.map((code) => getQuestIdByCode(code))
229
289
  .filter(Boolean) as number[]
230
290
 
231
- const calcQuestMap = (
291
+ /**
292
+ * @internal Export for test
293
+ */
294
+ export const calcQuestMap = (
232
295
  inProgressQuests: number[],
233
296
  next: (gameId: number) => number[],
234
297
  ) => {
@@ -251,6 +314,33 @@ const calcQuestMap = (
251
314
  export const getCompletedQuest = moize(
252
315
  (inProgressQuest: number[]) => {
253
316
  const completedQuest = calcQuestMap(inProgressQuest, getPreQuestIds)
317
+ // Check if the quest chain had completed
318
+ // See https://github.com/lawvs/poi-plugin-quest-2/issues/83
319
+ const noPostQuestIds = getNoPostQuestIds()
320
+ noPostQuestIds.forEach((gameId) => {
321
+ if (inProgressQuest.includes(gameId) || completedQuest[gameId]) {
322
+ return
323
+ }
324
+ const preQuestIds = getAllPreQuestIds(gameId)
325
+ const hasInProgressPreQuest = preQuestIds.some((preGameId) =>
326
+ inProgressQuest.includes(preGameId),
327
+ )
328
+ if (hasInProgressPreQuest) {
329
+ // The quest chain is not completed
330
+ return
331
+ }
332
+ const hasCompletedPreQuest = preQuestIds.some(
333
+ (preGameId) => completedQuest[preGameId],
334
+ )
335
+ if (!hasCompletedPreQuest) {
336
+ // The quest chain is not unlocked
337
+ return
338
+ }
339
+ preQuestIds.forEach((preGameId) => {
340
+ completedQuest[preGameId] = true
341
+ })
342
+ completedQuest[gameId] = true
343
+ })
254
344
  return completedQuest
255
345
  },
256
346
  {