poi-plugin-quest-info-2 0.6.4 → 0.7.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/README.md +15 -1
- package/build/kcQuestsData/DATA_VERSION +1 -1
- package/build/kcQuestsData/index.ts +1 -1
- package/build/kcQuestsData/quests-scn-new.json +1 -4
- package/build/kcQuestsData/quests-scn.json +1149 -572
- package/build/kcanotifyGamedata/DATA_VERSION +1 -1
- package/build/kcanotifyGamedata/index.ts +1 -1
- package/build/kcanotifyGamedata/quests-en.json +19 -19
- package/build/kcanotifyGamedata/quests-jp.json +19 -19
- package/build/kcanotifyGamedata/quests-ko.json +19 -19
- package/build/kcanotifyGamedata/quests-scn.json +19 -19
- package/build/kcanotifyGamedata/quests-tcn.json +19 -19
- package/build/questCategory.json +3 -1
- package/package.json +1 -1
- package/scripts/downloadKcQuestsData.ts +5 -1
- package/scripts/genQuestCategory.ts +7 -7
- package/src/Toolbar.tsx +28 -15
- package/src/__tests__/kcanotifyData.spec.ts +1 -1
- package/src/__tests__/kcwikiData.spec.ts +1 -1
- package/src/__tests__/questCategory.spec.ts +1 -1
- package/src/components/QuestCard/MinimalQuestCard.tsx +2 -2
- package/src/components/QuestCard/index.tsx +7 -4
- package/src/components/QuestList.tsx +3 -2
- package/src/patch.ts +9 -7
- package/src/poi/hooks.ts +10 -1
- package/src/poi/types.ts +11 -8
- package/src/questHelper.ts +7 -0
- package/src/reducer.ts +4 -2
- package/src/store/filterTags.ts +49 -1
- package/src/store/quest.ts +2 -4
- package/src/tags.ts +5 -5
|
@@ -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
|
-
|
|
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.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
/**
|
package/src/poi/hooks.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'
|
|
|
2
2
|
import { useTranslation } from 'react-i18next'
|
|
3
3
|
import { observePluginStore, observePoiStore } from './store'
|
|
4
4
|
import { name as PACKAGE_NAME } from '../../package.json'
|
|
5
|
-
import
|
|
5
|
+
import { GameQuest, PoiQuestState, PoiState, QuestTab } from './types'
|
|
6
6
|
|
|
7
7
|
export const useActiveQuest = () => {
|
|
8
8
|
const [activeQuests, setActiveQuests] = useState<PoiQuestState>({})
|
|
@@ -34,6 +34,15 @@ export const useGameQuest = () => {
|
|
|
34
34
|
return quests
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export const useGameTab = () => {
|
|
38
|
+
const [tab, setTab] = useState<QuestTab>(QuestTab.ALL)
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const listener = (tabId: QuestTab | null) => setTab(tabId ?? QuestTab.ALL)
|
|
41
|
+
return observePluginStore(listener, (i) => i?._?.tabId)
|
|
42
|
+
}, [])
|
|
43
|
+
return tab
|
|
44
|
+
}
|
|
45
|
+
|
|
37
46
|
const UNKNOWN_TAB = 'unknown'
|
|
38
47
|
const useActiveTab = () => {
|
|
39
48
|
const [activeMainTab, setActiveMainTab] = useState<string>(UNKNOWN_TAB)
|
package/src/poi/types.ts
CHANGED
|
@@ -60,19 +60,22 @@ export type GameQuest = {
|
|
|
60
60
|
api_bonus_flag: 1
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
export enum QuestTab {
|
|
64
|
+
ALL = '0',
|
|
65
|
+
IN_PROGRESS = '9',
|
|
66
|
+
DAILY = '1',
|
|
67
|
+
WEEKLY = '2',
|
|
68
|
+
MONTHLY = '3',
|
|
69
|
+
ONCE = '4',
|
|
70
|
+
OTHERS = '5',
|
|
71
|
+
}
|
|
72
|
+
|
|
63
73
|
type QuestListAction = {
|
|
64
74
|
type: '@@Response/kcsapi/api_get_member/questlist'
|
|
65
75
|
path: '/kcsapi/api_get_member/questlist'
|
|
66
76
|
postBody: {
|
|
67
77
|
api_verno: '1'
|
|
68
|
-
api_tab_id:
|
|
69
|
-
| '0' // All
|
|
70
|
-
| '9' // In progress
|
|
71
|
-
| '1' // Daily
|
|
72
|
-
| '2' // Weekly
|
|
73
|
-
| '3' // Monthly
|
|
74
|
-
| '4' // Once
|
|
75
|
-
| '5' // Others
|
|
78
|
+
api_tab_id: QuestTab
|
|
76
79
|
}
|
|
77
80
|
body: {
|
|
78
81
|
api_completed_kind: number
|
package/src/questHelper.ts
CHANGED
package/src/reducer.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GameQuest, PoiAction, QuestTab } from './poi/types'
|
|
2
2
|
|
|
3
3
|
const initState = {
|
|
4
4
|
questList: null as null | GameQuest[],
|
|
5
|
+
tabId: QuestTab.ALL,
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
export type PluginState = { _: typeof initState }
|
|
@@ -12,11 +13,12 @@ export const reducer = (
|
|
|
12
13
|
): typeof initState => {
|
|
13
14
|
switch (action.type) {
|
|
14
15
|
case '@@Response/kcsapi/api_get_member/questlist': {
|
|
15
|
-
const { body } = action
|
|
16
|
+
const { body, postBody } = action
|
|
16
17
|
|
|
17
18
|
return {
|
|
18
19
|
...state,
|
|
19
20
|
questList: body.api_list,
|
|
21
|
+
tabId: postBody.api_tab_id,
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
default:
|
package/src/store/filterTags.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { useCallback } from 'react'
|
|
2
|
+
import { useUpdateEffect } from 'react-use'
|
|
3
|
+
import { useGameTab } from '../poi/hooks'
|
|
4
|
+
import { QuestTab } from '../poi/types'
|
|
2
5
|
import {
|
|
3
6
|
ALL_CATEGORY_TAG,
|
|
4
7
|
ALL_TYPE_TAG,
|
|
5
8
|
CATEGORY_TAGS,
|
|
6
9
|
TYPE_TAGS,
|
|
7
10
|
} from '../tags'
|
|
8
|
-
import { useStore } from './store'
|
|
11
|
+
import { useStore, useSyncWithGame } from './store'
|
|
9
12
|
|
|
10
13
|
export const useFilterTags = () => {
|
|
11
14
|
const {
|
|
@@ -29,6 +32,13 @@ export const useFilterTags = () => {
|
|
|
29
32
|
},
|
|
30
33
|
[updateStore]
|
|
31
34
|
)
|
|
35
|
+
const manualSetTypeTags = useCallback(
|
|
36
|
+
(data: Record<string, boolean>) => {
|
|
37
|
+
updateStore({ typeTags: data })
|
|
38
|
+
},
|
|
39
|
+
[updateStore]
|
|
40
|
+
)
|
|
41
|
+
|
|
32
42
|
const setTypeTagsAll = useCallback(() => {
|
|
33
43
|
setTypeTags(ALL_TYPE_TAG.name)
|
|
34
44
|
}, [setTypeTags])
|
|
@@ -39,6 +49,44 @@ export const useFilterTags = () => {
|
|
|
39
49
|
setCategoryTags,
|
|
40
50
|
setCategoryTagsAll,
|
|
41
51
|
setTypeTags,
|
|
52
|
+
manualSetTypeTags,
|
|
42
53
|
setTypeTagsAll,
|
|
43
54
|
}
|
|
44
55
|
}
|
|
56
|
+
|
|
57
|
+
export const useSyncGameTagEffect = () => {
|
|
58
|
+
const { syncWithGame } = useSyncWithGame()
|
|
59
|
+
const filterTags = useFilterTags()
|
|
60
|
+
const tab = useGameTab()
|
|
61
|
+
|
|
62
|
+
useUpdateEffect(() => {
|
|
63
|
+
if (!syncWithGame) {
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
switch (tab) {
|
|
67
|
+
case QuestTab.ALL:
|
|
68
|
+
filterTags.setTypeTagsAll()
|
|
69
|
+
break
|
|
70
|
+
case QuestTab.DAILY:
|
|
71
|
+
filterTags.setTypeTags('Daily')
|
|
72
|
+
break
|
|
73
|
+
case QuestTab.WEEKLY:
|
|
74
|
+
filterTags.setTypeTags('Weekly')
|
|
75
|
+
break
|
|
76
|
+
case QuestTab.MONTHLY:
|
|
77
|
+
filterTags.setTypeTags('Monthly')
|
|
78
|
+
break
|
|
79
|
+
case QuestTab.IN_PROGRESS:
|
|
80
|
+
filterTags.setTypeTags('In Progress')
|
|
81
|
+
break
|
|
82
|
+
case QuestTab.OTHERS:
|
|
83
|
+
filterTags.manualSetTypeTags({ Quarterly: true, Yearly: true })
|
|
84
|
+
break
|
|
85
|
+
case QuestTab.ONCE:
|
|
86
|
+
filterTags.setTypeTags('One-time')
|
|
87
|
+
break
|
|
88
|
+
default:
|
|
89
|
+
break
|
|
90
|
+
}
|
|
91
|
+
}, [syncWithGame, tab])
|
|
92
|
+
}
|
package/src/store/quest.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { useGameQuest, usePluginTranslation } from '../poi/hooks'
|
|
|
4
4
|
import { getCategory } from '../questHelper'
|
|
5
5
|
import type { UnionQuest } from '../questHelper'
|
|
6
6
|
import { useKcwikiData, checkIsKcwikiSupportedLanguages } from './kcwiki'
|
|
7
|
-
import { useStore } from './store'
|
|
7
|
+
import { useStore, useSyncWithGame } from './store'
|
|
8
8
|
|
|
9
9
|
const DEFAULT_LANG = 'ja-JP'
|
|
10
10
|
|
|
@@ -40,9 +40,7 @@ const useQuestMap = () => {
|
|
|
40
40
|
export const useQuest = (): UnionQuest[] => {
|
|
41
41
|
const docQuestMap = useQuestMap()
|
|
42
42
|
const gameQuest = useGameQuest()
|
|
43
|
-
const {
|
|
44
|
-
store: { syncWithGame },
|
|
45
|
-
} = useStore()
|
|
43
|
+
const { syncWithGame } = useSyncWithGame()
|
|
46
44
|
|
|
47
45
|
if (syncWithGame && gameQuest.length) {
|
|
48
46
|
return gameQuest.map((quest) => {
|
package/src/tags.ts
CHANGED
|
@@ -49,18 +49,18 @@ export const CATEGORY_TAGS = [
|
|
|
49
49
|
|
|
50
50
|
export const TYPE_TAGS = [
|
|
51
51
|
ALL_TYPE_TAG,
|
|
52
|
-
...(IN_POI
|
|
52
|
+
...(IN_POI
|
|
53
|
+
? ([{ name: 'In Progress', filter: isInProgressQuest }] as const)
|
|
54
|
+
: []),
|
|
53
55
|
...(hasNewQuest
|
|
54
|
-
? [{ name: 'New', filter: isNewQuest, suffix: newQuestNumber }]
|
|
56
|
+
? ([{ name: 'New', filter: isNewQuest, suffix: newQuestNumber }] as const)
|
|
55
57
|
: []),
|
|
56
58
|
{ name: 'Daily', filter: isDailyQuest },
|
|
57
59
|
{ name: 'Weekly', filter: isWeeklyQuest },
|
|
58
60
|
{ name: 'Monthly', filter: isMonthlyQuest },
|
|
61
|
+
{ name: 'One-time', filter: isSingleQuest },
|
|
59
62
|
{ name: 'Quarterly', filter: isQuarterlyQuest },
|
|
60
63
|
{ name: 'Yearly', filter: isYearlyQuest },
|
|
61
|
-
{ name: 'One-time', filter: isSingleQuest },
|
|
62
64
|
] as const
|
|
63
65
|
|
|
64
66
|
// TODO tag In Progress / Lock / Completed
|
|
65
|
-
|
|
66
|
-
export const ALL_TAGS = [...CATEGORY_TAGS, ...TYPE_TAGS]
|