poi-plugin-quest-info-2 0.7.4 → 0.8.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.
@@ -0,0 +1,418 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`questHelper should 101 locked quests match snapshot 1`] = `
4
+ Object {
5
+ "102": true,
6
+ "103": true,
7
+ "104": true,
8
+ "105": true,
9
+ "106": true,
10
+ "107": true,
11
+ "108": true,
12
+ "109": true,
13
+ "110": true,
14
+ "1103": true,
15
+ "1104": true,
16
+ "1106": true,
17
+ "111": true,
18
+ "112": true,
19
+ "113": true,
20
+ "114": true,
21
+ "115": true,
22
+ "116": true,
23
+ "117": true,
24
+ "118": true,
25
+ "119": true,
26
+ "120": true,
27
+ "121": true,
28
+ "122": true,
29
+ "123": true,
30
+ "124": true,
31
+ "125": true,
32
+ "126": true,
33
+ "127": true,
34
+ "128": true,
35
+ "129": true,
36
+ "130": true,
37
+ "131": true,
38
+ "132": true,
39
+ "133": true,
40
+ "134": true,
41
+ "135": true,
42
+ "136": true,
43
+ "137": true,
44
+ "138": true,
45
+ "139": true,
46
+ "140": true,
47
+ "141": true,
48
+ "142": true,
49
+ "143": true,
50
+ "144": true,
51
+ "145": true,
52
+ "146": true,
53
+ "147": true,
54
+ "148": true,
55
+ "149": true,
56
+ "150": true,
57
+ "151": true,
58
+ "152": true,
59
+ "153": true,
60
+ "154": true,
61
+ "155": true,
62
+ "156": true,
63
+ "157": true,
64
+ "158": true,
65
+ "161": true,
66
+ "162": true,
67
+ "163": true,
68
+ "164": true,
69
+ "165": true,
70
+ "166": true,
71
+ "167": true,
72
+ "168": true,
73
+ "169": true,
74
+ "170": true,
75
+ "171": true,
76
+ "172": true,
77
+ "173": true,
78
+ "174": true,
79
+ "175": true,
80
+ "176": true,
81
+ "177": true,
82
+ "178": true,
83
+ "179": true,
84
+ "180": true,
85
+ "181": true,
86
+ "182": true,
87
+ "183": true,
88
+ "184": true,
89
+ "185": true,
90
+ "186": true,
91
+ "187": true,
92
+ "188": true,
93
+ "189": true,
94
+ "190": true,
95
+ "191": true,
96
+ "192": true,
97
+ "193": true,
98
+ "194": true,
99
+ "195": true,
100
+ "196": true,
101
+ "197": true,
102
+ "215": true,
103
+ "217": true,
104
+ "219": true,
105
+ "222": true,
106
+ "223": true,
107
+ "224": true,
108
+ "225": true,
109
+ "227": true,
110
+ "231": true,
111
+ "232": true,
112
+ "233": true,
113
+ "236": true,
114
+ "239": true,
115
+ "240": true,
116
+ "244": true,
117
+ "245": true,
118
+ "246": true,
119
+ "247": true,
120
+ "248": true,
121
+ "249": true,
122
+ "250": true,
123
+ "251": true,
124
+ "252": true,
125
+ "253": true,
126
+ "254": true,
127
+ "258": true,
128
+ "259": true,
129
+ "260": true,
130
+ "261": true,
131
+ "262": true,
132
+ "263": true,
133
+ "264": true,
134
+ "265": true,
135
+ "266": true,
136
+ "267": true,
137
+ "268": true,
138
+ "269": true,
139
+ "270": true,
140
+ "271": true,
141
+ "273": true,
142
+ "274": true,
143
+ "275": true,
144
+ "276": true,
145
+ "277": true,
146
+ "278": true,
147
+ "279": true,
148
+ "281": true,
149
+ "282": true,
150
+ "285": true,
151
+ "287": true,
152
+ "288": true,
153
+ "289": true,
154
+ "290": true,
155
+ "291": true,
156
+ "292": true,
157
+ "293": true,
158
+ "294": true,
159
+ "295": true,
160
+ "296": true,
161
+ "297": true,
162
+ "298": true,
163
+ "306": true,
164
+ "307": true,
165
+ "308": true,
166
+ "309": true,
167
+ "312": true,
168
+ "316": true,
169
+ "318": true,
170
+ "319": true,
171
+ "323": true,
172
+ "324": true,
173
+ "325": true,
174
+ "328": true,
175
+ "330": true,
176
+ "331": true,
177
+ "339": true,
178
+ "346": true,
179
+ "347": true,
180
+ "355": true,
181
+ "401": true,
182
+ "402": true,
183
+ "403": true,
184
+ "404": true,
185
+ "405": true,
186
+ "406": true,
187
+ "408": true,
188
+ "409": true,
189
+ "410": true,
190
+ "411": true,
191
+ "412": true,
192
+ "413": true,
193
+ "414": true,
194
+ "415": true,
195
+ "418": true,
196
+ "419": true,
197
+ "420": true,
198
+ "422": true,
199
+ "423": true,
200
+ "424": true,
201
+ "425": true,
202
+ "429": true,
203
+ "431": true,
204
+ "433": true,
205
+ "434": true,
206
+ "437": true,
207
+ "440": true,
208
+ "442": true,
209
+ "443": true,
210
+ "444": true,
211
+ "445": true,
212
+ "610": true,
213
+ "611": true,
214
+ "612": true,
215
+ "614": true,
216
+ "615": true,
217
+ "616": true,
218
+ "618": true,
219
+ "619": true,
220
+ "620": true,
221
+ "622": true,
222
+ "623": true,
223
+ "624": true,
224
+ "625": true,
225
+ "626": true,
226
+ "627": true,
227
+ "628": true,
228
+ "629": true,
229
+ "630": true,
230
+ "631": true,
231
+ "632": true,
232
+ "633": true,
233
+ "635": true,
234
+ "636": true,
235
+ "638": true,
236
+ "639": true,
237
+ "641": true,
238
+ "642": true,
239
+ "643": true,
240
+ "644": true,
241
+ "645": true,
242
+ "646": true,
243
+ "647": true,
244
+ "648": true,
245
+ "649": true,
246
+ "650": true,
247
+ "651": true,
248
+ "652": true,
249
+ "654": true,
250
+ "655": true,
251
+ "656": true,
252
+ "658": true,
253
+ "659": true,
254
+ "660": true,
255
+ "661": true,
256
+ "662": true,
257
+ "663": true,
258
+ "664": true,
259
+ "665": true,
260
+ "666": true,
261
+ "667": true,
262
+ "669": true,
263
+ "670": true,
264
+ "671": true,
265
+ "676": true,
266
+ "681": true,
267
+ "683": true,
268
+ "684": true,
269
+ "685": true,
270
+ "686": true,
271
+ "687": true,
272
+ "689": true,
273
+ "690": true,
274
+ "695": true,
275
+ "696": true,
276
+ "698": true,
277
+ "704": true,
278
+ "705": true,
279
+ "718": true,
280
+ "719": true,
281
+ "805": true,
282
+ "806": true,
283
+ "807": true,
284
+ "808": true,
285
+ "809": true,
286
+ "812": true,
287
+ "813": true,
288
+ "814": true,
289
+ "815": true,
290
+ "816": true,
291
+ "817": true,
292
+ "818": true,
293
+ "819": true,
294
+ "820": true,
295
+ "821": true,
296
+ "822": true,
297
+ "823": true,
298
+ "826": true,
299
+ "827": true,
300
+ "828": true,
301
+ "829": true,
302
+ "833": true,
303
+ "835": true,
304
+ "836": true,
305
+ "837": true,
306
+ "838": true,
307
+ "839": true,
308
+ "842": true,
309
+ "844": true,
310
+ "845": true,
311
+ "846": true,
312
+ "847": true,
313
+ "848": true,
314
+ "850": true,
315
+ "851": true,
316
+ "852": true,
317
+ "854": true,
318
+ "856": true,
319
+ "858": true,
320
+ "859": true,
321
+ "860": true,
322
+ "861": true,
323
+ "862": true,
324
+ "863": true,
325
+ "864": true,
326
+ "865": true,
327
+ "870": true,
328
+ "871": true,
329
+ "872": true,
330
+ "875": true,
331
+ "877": true,
332
+ "879": true,
333
+ "881": true,
334
+ "884": true,
335
+ "885": true,
336
+ "886": true,
337
+ "887": true,
338
+ "888": true,
339
+ "890": true,
340
+ "891": true,
341
+ "892": true,
342
+ "896": true,
343
+ "897": true,
344
+ "901": true,
345
+ "902": true,
346
+ "903": true,
347
+ "904": true,
348
+ "911": true,
349
+ "913": true,
350
+ "916": true,
351
+ "917": true,
352
+ "918": true,
353
+ "924": true,
354
+ "925": true,
355
+ "926": true,
356
+ "927": true,
357
+ "929": true,
358
+ "930": true,
359
+ "933": true,
360
+ "934": true,
361
+ "935": true,
362
+ "936": true,
363
+ "937": true,
364
+ "940": true,
365
+ "943": true,
366
+ "947": true,
367
+ "948": true,
368
+ "949": true,
369
+ "961": true,
370
+ "966": true,
371
+ "967": true,
372
+ "968": true,
373
+ "969": true,
374
+ }
375
+ `;
376
+
377
+ exports[`questHelper should 196 getLockedQuest correct 1`] = `
378
+ Object {
379
+ "197": true,
380
+ "346": true,
381
+ "892": true,
382
+ "930": true,
383
+ }
384
+ `;
385
+
386
+ exports[`questHelper should 236 getCompletedQuest correct 1`] = `
387
+ Object {
388
+ "101": true,
389
+ "102": true,
390
+ "103": true,
391
+ "105": true,
392
+ "106": true,
393
+ "107": true,
394
+ "113": true,
395
+ "119": true,
396
+ "121": true,
397
+ "124": true,
398
+ "125": true,
399
+ "131": true,
400
+ "133": true,
401
+ "136": true,
402
+ "152": true,
403
+ "227": true,
404
+ "235": true,
405
+ "273": true,
406
+ "307": true,
407
+ }
408
+ `;
409
+
410
+ exports[`questHelper should getCompletedQuest quest match snapshot 1`] = `
411
+ Object {
412
+ "101": true,
413
+ "102": true,
414
+ "103": true,
415
+ "104": true,
416
+ "174": true,
417
+ }
418
+ `;
@@ -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
- `"433261cf82381efd22702e882ad359bf426695b5"`
7
+ `"fbee6ceb50a3acc9494978f1bb0adec1aaa5e30d"`
8
8
  )
9
9
  })
10
10
 
@@ -0,0 +1,40 @@
1
+ import {
2
+ getCompletedQuest,
3
+ getLockedQuest,
4
+ getPostQuestIds,
5
+ getPreQuestIds,
6
+ } from '../questHelper'
7
+
8
+ describe('questHelper', () => {
9
+ test('should getPreQuestIds correct', () => {
10
+ expect(getPreQuestIds(101)).toEqual([])
11
+ expect(getPreQuestIds(102)).toEqual([101])
12
+ expect(getPreQuestIds(236)).toEqual([235, 273])
13
+ })
14
+
15
+ test('should getPostQuestIds correct', () => {
16
+ expect(getPostQuestIds(101)).toEqual([102])
17
+ expect(getPostQuestIds(105)).toEqual([106, 108, 254, 401, 612, 816])
18
+ expect(getPostQuestIds(140)).toEqual([])
19
+ })
20
+
21
+ test('should 101 no completed quest', () => {
22
+ expect(getCompletedQuest([101])).toEqual({})
23
+ })
24
+
25
+ test('should getCompletedQuest quest match snapshot', () => {
26
+ expect(getCompletedQuest([817])).toMatchSnapshot()
27
+ })
28
+
29
+ test('should 236 getCompletedQuest correct', () => {
30
+ expect(getCompletedQuest([236])).toMatchSnapshot()
31
+ })
32
+
33
+ test('should 101 locked quests match snapshot', () => {
34
+ expect(getLockedQuest([101])).toMatchSnapshot()
35
+ })
36
+
37
+ test('should 196 getLockedQuest correct', () => {
38
+ expect(getLockedQuest([196])).toMatchSnapshot()
39
+ })
40
+ })
@@ -6,6 +6,9 @@ import type { QuestCardProps } from './index'
6
6
  import { CardBody, CardTail, CatIndicator, FlexCard } from './styles'
7
7
  import { questStatusMap } from './utils'
8
8
 
9
+ /**
10
+ * @deprecated
11
+ */
9
12
  export const MinimalQuestCard = forwardRef<
10
13
  Card,
11
14
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -1,8 +1,13 @@
1
- import { Card, Elevation, H5, Text } from '@blueprintjs/core'
1
+ import { Card, Elevation, H5 } from '@blueprintjs/core'
2
2
  import React, { forwardRef } from 'react'
3
3
  import type { StyledComponentProps } from 'styled-components'
4
4
  import { usePluginTranslation } from '../../poi/hooks'
5
- import { getPrePost, guessQuestCategory, QUEST_STATUS } from '../../questHelper'
5
+ import {
6
+ getQuestPrePost,
7
+ guessQuestCategory,
8
+ QUEST_STATUS,
9
+ } from '../../questHelper'
10
+ import { useQuestStatus } from '../../store/quest'
6
11
  import { QuestTag } from '../QuestTag'
7
12
  import {
8
13
  CardActionWrapper,
@@ -14,6 +19,7 @@ import {
14
19
  TagsWrapper,
15
20
  } from './styles'
16
21
  import { questIconMap, questStatusMap } from './utils'
22
+ import { IN_POI } from '../../poi/env'
17
23
 
18
24
  export type QuestCardProps = {
19
25
  gameId: number
@@ -29,15 +35,15 @@ export type QuestCardProps = {
29
35
  const CardAction = ({ gameId }: { gameId: number }) => {
30
36
  const { t } = usePluginTranslation()
31
37
 
32
- const preQuests = getPrePost(gameId)
38
+ const prePostQuests = getQuestPrePost(gameId)
33
39
 
34
40
  return (
35
41
  <CardActionWrapper>
36
42
  <TagsWrapper>
37
- {!!preQuests.pre.length && (
43
+ {!!prePostQuests.pre.length && (
38
44
  <>
39
45
  <SpanText>{t('Requires')}</SpanText>
40
- {preQuests.pre.map((i) => (
46
+ {prePostQuests.pre.map((i) => (
41
47
  <QuestTag key={i} code={i}></QuestTag>
42
48
  ))}
43
49
  </>
@@ -45,10 +51,10 @@ const CardAction = ({ gameId }: { gameId: number }) => {
45
51
  </TagsWrapper>
46
52
 
47
53
  <TagsWrapper>
48
- {!!preQuests.post.length && (
54
+ {!!prePostQuests.post.length && (
49
55
  <>
50
56
  <SpanText>{t('Unlocks')}</SpanText>
51
- {preQuests.post.map((i) => (
57
+ {prePostQuests.post.map((i) => (
52
58
  <QuestTag key={i} code={i}></QuestTag>
53
59
  ))}
54
60
  </>
@@ -62,44 +68,30 @@ export const QuestCard = forwardRef<
62
68
  Card,
63
69
  // eslint-disable-next-line @typescript-eslint/ban-types
64
70
  QuestCardProps & StyledComponentProps<typeof Card, any, {}, never>
65
- >(
66
- (
67
- {
68
- gameId,
69
- code,
70
- name,
71
- desc,
72
- tip,
73
- tip2,
74
- status = QUEST_STATUS.DEFAULT,
75
- ...props
76
- },
77
- ref
78
- ) => {
79
- const headIcon = questIconMap[guessQuestCategory(code).type]
80
- const TailIcon = questStatusMap[status]
71
+ >(({ gameId, code, name, desc, tip, tip2, ...props }, ref) => {
72
+ const status = useQuestStatus(gameId)
73
+ const headIcon = questIconMap[guessQuestCategory(code).type]
74
+ const TailIcon = questStatusMap[status]
75
+ const inPoi = IN_POI
81
76
 
82
- return (
83
- <FlexCard
84
- ref={ref}
85
- elevation={Elevation.ZERO}
86
- interactive={false}
87
- {...props}
88
- >
89
- <CardMedia src={headIcon}></CardMedia>
90
- <CardBody>
91
- <H5>{[code, name].filter((i) => i != undefined).join(' - ')}</H5>
92
- <Text>{desc}</Text>
93
- {tip2 && <b>{tip2}</b>}
94
- {tip && <i>{tip}</i>}
77
+ return (
78
+ <FlexCard
79
+ ref={ref}
80
+ elevation={Elevation.ZERO}
81
+ interactive={false}
82
+ {...props}
83
+ >
84
+ <CardMedia src={headIcon}></CardMedia>
85
+ <CardBody>
86
+ <H5>{[code, name].filter((i) => i != undefined).join(' - ')}</H5>
87
+ <div>{desc}</div>
88
+ {tip2 && <b>{tip2}</b>}
89
+ {tip && <i>{tip}</i>}
95
90
 
96
- <CardAction gameId={gameId}></CardAction>
97
- </CardBody>
91
+ <CardAction gameId={gameId}></CardAction>
92
+ </CardBody>
98
93
 
99
- <CardTail>
100
- <TailIcon />
101
- </CardTail>
102
- </FlexCard>
103
- )
104
- }
105
- )
94
+ <CardTail>{inPoi && <TailIcon />}</CardTail>
95
+ </FlexCard>
96
+ )
97
+ })
@@ -50,6 +50,14 @@ export const questStatusMap: Record<QUEST_STATUS, React.FC> = {
50
50
  </Tooltip>
51
51
  )
52
52
  },
53
+ [QUEST_STATUS.UNKNOWN]: function AlreadyCompleted() {
54
+ const { t } = usePluginTranslation()
55
+ return (
56
+ <Tooltip content={t('Unknown')}>
57
+ <Icon icon={IconNames.HELP} iconSize={Icon.SIZE_LARGE}></Icon>
58
+ </Tooltip>
59
+ )
60
+ },
53
61
  }
54
62
 
55
63
  // transparent GIF pixel
@@ -1,4 +1,5 @@
1
- import React, { useRef, useEffect, useCallback } from 'react'
1
+ import React, { useCallback, useEffect, useRef } from 'react'
2
+ import type { ListRowProps } from 'react-virtualized'
2
3
  // See https://github.com/bvaughn/react-virtualized
3
4
  import {
4
5
  AutoSizer,
@@ -7,13 +8,10 @@ import {
7
8
  List,
8
9
  ListRowRenderer,
9
10
  } from 'react-virtualized'
10
- import type { ListRowProps } from 'react-virtualized'
11
11
  import styled from 'styled-components'
12
- import { QUEST_STATUS } from '../questHelper'
12
+ import { useIsQuestPluginTab } from '../poi/hooks'
13
13
  import type { UnionQuest } from '../questHelper'
14
14
  import { QuestCard } from './QuestCard'
15
- import { useIsQuestPluginTab } from '../poi/hooks'
16
- import { QUEST_API_STATE } from '../poi/types'
17
15
 
18
16
  const QuestListWrapper = styled.div`
19
17
  flex: 1;
@@ -26,28 +24,12 @@ const cache = new CellMeasurerCache({
26
24
  fixedWidth: true,
27
25
  })
28
26
 
29
- const questStateToQuestStatus = (
30
- state: QUEST_API_STATE | undefined
31
- ): QUEST_STATUS => {
32
- switch (state) {
33
- case QUEST_API_STATE.DEFAULT:
34
- return QUEST_STATUS.DEFAULT
35
- case QUEST_API_STATE.COMPLETED:
36
- return QUEST_STATUS.COMPLETED
37
- case QUEST_API_STATE.IN_PROGRESS:
38
- return QUEST_STATUS.IN_PROGRESS
39
- default:
40
- return QUEST_STATUS.DEFAULT
41
- }
42
- }
43
-
44
27
  const useQuestsRowRenderer = (quests: UnionQuest[]) => {
45
28
  const rowRenderer = useCallback(
46
29
  ({ key, index, style, parent }: ListRowProps) => {
47
30
  const quest = quests[index]
48
31
  const { gameId } = quest
49
32
  const { code, name, desc, memo, memo2, pre } = quest.docQuest
50
- const questStatus = questStateToQuestStatus(quest.gameQuest?.api_state)
51
33
 
52
34
  return (
53
35
  <CellMeasurer
@@ -67,7 +49,6 @@ const useQuestsRowRenderer = (quests: UnionQuest[]) => {
67
49
  tip={memo}
68
50
  tip2={memo2}
69
51
  preQuest={pre}
70
- status={questStatus}
71
52
  ></QuestCard>
72
53
  </div>
73
54
  </CellMeasurer>
@@ -78,7 +59,7 @@ const useQuestsRowRenderer = (quests: UnionQuest[]) => {
78
59
  return rowRenderer
79
60
  }
80
61
 
81
- export const QuestList: React.FC<{ quests: UnionQuest[] }> = ({ quests }) => {
62
+ export const QuestList = ({ quests }: { quests: UnionQuest[] }) => {
82
63
  const activeTab = useIsQuestPluginTab()
83
64
  const listRef = useRef<List>(null)
84
65
  const rowRenderer: ListRowRenderer = useQuestsRowRenderer(quests)