poi-plugin-quest-info-2 0.6.3 → 0.6.7

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.
@@ -5,7 +5,7 @@ import { KcwikiQuestData } from '../build/kcQuestsData'
5
5
 
6
6
  const OUTPUT_PATH = path.resolve('build', 'questCategory.json')
7
7
 
8
- const questStartsFilter = (str: string) =>
8
+ const kcaQuestStartsFilter = (str: string) =>
9
9
  Object.entries(QuestData['zh-CN'])
10
10
  .filter(([, quest]) => quest.name.startsWith(str))
11
11
  .map(([gameId]) => gameId)
@@ -15,20 +15,20 @@ const mergeDataSelector = () =>
15
15
  Object.entries({ ...QuestData['zh-CN'], ...KcwikiQuestData['zh-CN'] })
16
16
 
17
17
  const main = () => {
18
- const dailyQuest = questStartsFilter('(日任)')
19
- const weeklyQuest = questStartsFilter('(周任)')
20
- const monthlyQuest = questStartsFilter('(月任)')
18
+ const dailyQuest = kcaQuestStartsFilter('(日任)')
19
+ const weeklyQuest = kcaQuestStartsFilter('(周任)')
20
+ const monthlyQuest = kcaQuestStartsFilter('(月任)')
21
21
  const quarterlyQuest = [
22
22
  ...new Set([
23
- ...questStartsFilter('(季任)'),
23
+ ...kcaQuestStartsFilter('(季任)'),
24
24
  ...kcwikiDataSelector()
25
- .filter(([, quest]) => quest.desc.includes('季常任务'))
25
+ .filter(([, quest]) => quest.memo2.includes('季常任务'))
26
26
  .map(([gameId]) => gameId),
27
27
  ]),
28
28
  ].sort((a, b) => +a - +b)
29
29
  // (年任) (年任 / x 月)
30
30
  const yearlyQuest = kcwikiDataSelector()
31
- .filter(([, quest]) => quest.desc.includes('❀备注:年常任务'))
31
+ .filter(([, quest]) => quest.memo2.includes('年常任务'))
32
32
  .map(([gameId]) => gameId)
33
33
  const singleQuest = mergeDataSelector()
34
34
  .filter(
package/src/Toolbar.tsx CHANGED
@@ -119,20 +119,21 @@ const Tags = () => {
119
119
  ))}
120
120
  </TagsWrapper>
121
121
  <TagsWrapper>
122
- {TYPE_TAGS.map(({ name }) => (
122
+ {TYPE_TAGS.map((tag) => (
123
123
  <Tag
124
- onClick={() => setTypeTags(name)}
124
+ onClick={() => setTypeTags(tag.name)}
125
125
  intent={
126
- typeTags[name]
127
- ? name === ALL_TYPE_TAG.name
126
+ typeTags[tag.name]
127
+ ? tag.name === ALL_TYPE_TAG.name
128
128
  ? 'success'
129
129
  : 'primary'
130
130
  : 'none'
131
131
  }
132
132
  interactive={true}
133
- key={name}
133
+ key={tag.name}
134
134
  >
135
- {t(name)}
135
+ {t(tag.name)}
136
+ {'suffix' in tag && ' ' + tag.suffix}
136
137
  </Tag>
137
138
  ))}
138
139
  </TagsWrapper>
@@ -159,17 +160,19 @@ const useToolbarFilter = () => {
159
160
 
160
161
  const throttledSearchInput = useThrottle(searchInput)
161
162
  const searchKeywords = throttledSearchInput
162
- ?.split(' ')
163
+ .split(' ')
164
+ // Remove empty string
165
+ .filter((i) => !!i)
163
166
  .map((i) => i.toUpperCase())
164
167
 
165
168
  const stringFilter = useCallback(
166
169
  (quest: UnionQuest) => {
170
+ if (!searchKeywords || !searchKeywords.length) {
171
+ return true
172
+ }
167
173
  const text = `${quest.docQuest.code} ${quest.docQuest.name} ${
168
174
  quest.docQuest.desc
169
175
  } ${quest.docQuest.memo ?? ''}`
170
- if (!searchKeywords) {
171
- return true
172
- }
173
176
  return searchKeywords.some((keyword) =>
174
177
  text.toUpperCase().includes(keyword)
175
178
  )
@@ -1,7 +1,7 @@
1
1
  import { version, QuestData } from '../../build/kcanotifyGamedata'
2
2
 
3
3
  test('should Kcanotify Game data version correct', () => {
4
- expect(version).toMatchInlineSnapshot(`"2022020101"`)
4
+ expect(version).toMatchInlineSnapshot(`"2022040401"`)
5
5
  })
6
6
 
7
7
  test('should Kcanotify Game data keys correct', () => {
@@ -3,16 +3,16 @@ import { version, KcwikiQuestData } from '../../build/kcQuestsData'
3
3
  describe('should version correct', () => {
4
4
  test('should KcwikiQuestData Game data version correct', () => {
5
5
  expect(version).toMatchInlineSnapshot(
6
- `"9c5a15512d59eaad02e09fe717defba581c4e4a3"`
6
+ `"98f428c28296c17f81d27e2717be6c6ac50f2c36"`
7
7
  )
8
8
  })
9
9
 
10
10
  test('should KcwikiQuestData Game data keys correct', () => {
11
11
  expect(Object.keys(KcwikiQuestData)).toMatchInlineSnapshot(`
12
- Array [
13
- "zh-CN",
14
- ]
15
- `)
12
+ Array [
13
+ "zh-CN",
14
+ ]
15
+ `)
16
16
  })
17
17
  })
18
18
 
@@ -9,7 +9,7 @@ describe('should questCategory correct', () => {
9
9
  expect(questCategory.monthlyQuest.length).toMatchInlineSnapshot(`11`)
10
10
  expect(questCategory.quarterlyQuest.length).toMatchInlineSnapshot(`25`)
11
11
  expect(questCategory.yearlyQuest.length).toMatchInlineSnapshot(`37`)
12
- expect(questCategory.singleQuest.length).toMatchInlineSnapshot(`473`)
12
+ expect(questCategory.singleQuest.length).toMatchInlineSnapshot(`475`)
13
13
  })
14
14
 
15
15
  test('snapshot', () => {
@@ -9,7 +9,7 @@ export const MinimalQuestCard: React.FC<QuestCardProps> = ({
9
9
  code,
10
10
  name,
11
11
  desc,
12
- tips,
12
+ tip,
13
13
  status = QUEST_STATUS.DEFAULT,
14
14
  onClick,
15
15
  style,
@@ -24,7 +24,7 @@ export const MinimalQuestCard: React.FC<QuestCardProps> = ({
24
24
  <>
25
25
  {desc}
26
26
  <br />
27
- {tips}
27
+ {tip}
28
28
  </>
29
29
  }
30
30
  >
@@ -11,7 +11,8 @@ export type QuestCardProps = {
11
11
  code: string
12
12
  name: string
13
13
  desc: string | JSX.Element
14
- tips?: string
14
+ tip?: string
15
+ tip2?: string
15
16
  status?: QUEST_STATUS
16
17
  preTask?: string[]
17
18
  onClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
@@ -27,7 +28,8 @@ export const LargeQuestCard = ({
27
28
  code,
28
29
  name,
29
30
  desc,
30
- tips,
31
+ tip,
32
+ tip2,
31
33
  preTask,
32
34
  status = QUEST_STATUS.DEFAULT,
33
35
  onClick,
@@ -48,9 +50,10 @@ export const LargeQuestCard = ({
48
50
  <CardBody>
49
51
  <H5>{[code, name].filter((i) => i != undefined).join(' - ')}</H5>
50
52
  <Text>{desc}</Text>
51
- {tips && <Text tagName="i">{tips}</Text>}
53
+ {tip2 && <b>{tip2}</b>}
54
+ {tip && <i>{tip}</i>}
52
55
  <PreTaskTagWrapper>
53
- {!!preTask?.length && <Text tagName="span">{t('Requires')}</Text>}
56
+ {!!preTask?.length && <span>{t('Requires')}</span>}
54
57
  {preTask?.map((i) => (
55
58
  <PreTaskTag key={i} code={i}></PreTaskTag>
56
59
  ))}
@@ -47,7 +47,7 @@ const useQuestsRowRenderer = (quests: UnionQuest[]) => {
47
47
  ({ key, index, style, parent }: ListRowProps) => {
48
48
  const quest = quests[index]
49
49
  const { gameId } = quest
50
- const { code, name, desc, memo, pre } = quest.docQuest
50
+ const { code, name, desc, memo, memo2, pre } = quest.docQuest
51
51
  const questStatus = questStateToQuestStatus(quest.gameQuest?.api_state)
52
52
 
53
53
  return (
@@ -65,7 +65,8 @@ const useQuestsRowRenderer = (quests: UnionQuest[]) => {
65
65
  code={code}
66
66
  name={name}
67
67
  desc={desc}
68
- tips={memo}
68
+ tip={memo}
69
+ tip2={memo2}
69
70
  preTask={pre}
70
71
  status={questStatus}
71
72
  ></QuestCard>
package/src/patch.ts CHANGED
@@ -40,13 +40,15 @@ const getQuestState = (maybeLanguage: string) => {
40
40
  ? KcwikiQuestData[maybeLanguage]
41
41
  : QuestData[maybeLanguage]
42
42
 
43
- return Object.entries(data).reduce((acc, [apiNo, { code, desc }]) => {
44
- acc[apiNo] = {
45
- wiki_id: code,
46
- condition: desc,
47
- }
48
- return acc
49
- }, {} as Record<string, { wiki_id: string; condition: string }>)
43
+ return Object.fromEntries(
44
+ Object.entries(data).map(([apiNo, data]) => [
45
+ apiNo,
46
+ {
47
+ wiki_id: data.code,
48
+ condition: [(data as any).memo2, data.desc].filter(Boolean).join(' | '),
49
+ },
50
+ ])
51
+ )
50
52
  }
51
53
 
52
54
  /**
@@ -6,7 +6,14 @@ type DocQuest = {
6
6
  code: string
7
7
  name: string
8
8
  desc: string
9
+ /**
10
+ * Quest rewards
11
+ */
9
12
  memo?: string
13
+ /**
14
+ * Quest details, only in KcWiki
15
+ */
16
+ memo2?: string
10
17
  /**
11
18
  * Only in kcanotify
12
19
  */
@@ -38,6 +45,7 @@ const newQuest = new Set(newQuestData)
38
45
  export const isInProgressQuest = (quest: UnionQuest) =>
39
46
  quest.gameQuest?.api_state === QUEST_API_STATE.IN_PROGRESS ||
40
47
  quest.gameQuest?.api_state === QUEST_API_STATE.COMPLETED
48
+
41
49
  export const isDailyQuest = (quest: UnionQuest) => dailyQuest.has(quest.gameId)
42
50
  export const isWeeklyQuest = (quest: UnionQuest) =>
43
51
  weeklyQuest.has(quest.gameId)
@@ -52,6 +60,7 @@ export const isSingleQuest = (quest: UnionQuest) =>
52
60
 
53
61
  export const hasNewQuest = newQuestData.length > 0
54
62
  export const isNewQuest = (quest: UnionQuest) => newQuest.has(quest.gameId)
63
+ export const newQuestNumber = newQuestData.length
55
64
 
56
65
  export enum QUEST_CATEGORY {
57
66
  Composition = '1',
package/src/tags.ts CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  isSingleQuest,
18
18
  hasNewQuest,
19
19
  isNewQuest,
20
+ newQuestNumber,
20
21
  } from './questHelper'
21
22
  import type { UnionQuest } from './questHelper'
22
23
 
@@ -49,7 +50,9 @@ export const CATEGORY_TAGS = [
49
50
  export const TYPE_TAGS = [
50
51
  ALL_TYPE_TAG,
51
52
  ...(IN_POI ? [{ name: 'In Progress', filter: isInProgressQuest }] : []),
52
- ...(hasNewQuest ? [{ name: 'New', filter: isNewQuest }] : []),
53
+ ...(hasNewQuest
54
+ ? [{ name: 'New', filter: isNewQuest, suffix: newQuestNumber }]
55
+ : []),
53
56
  { name: 'Daily', filter: isDailyQuest },
54
57
  { name: 'Weekly', filter: isWeeklyQuest },
55
58
  { name: 'Monthly', filter: isMonthlyQuest },