diff --git a/public/locales/en-US/common.json b/public/locales/en-US/common.json index ff1c5275..add6ac15 100644 --- a/public/locales/en-US/common.json +++ b/public/locales/en-US/common.json @@ -1,5 +1,6 @@ { "nav": { + "abyss-lab": "Abyss Lab", "honkai-3rd": "Honkai 3rd", "versions": "Versions", "battlesuits": "Battlesuits", diff --git a/public/locales/ko-KR/common.json b/public/locales/ko-KR/common.json index d189284c..10c9bb3b 100644 --- a/public/locales/ko-KR/common.json +++ b/public/locales/ko-KR/common.json @@ -1,5 +1,6 @@ { "nav": { + "abyss-lab": "어비스랩", "honkai-3rd": "붕괴 3rd", "versions": "업데이트", "battlesuits": "발키리", diff --git a/src/components/pages/SingleStigmataPage.tsx b/src/components/pages/SingleStigmataPage.tsx index 6c5674e0..7c42bfd9 100644 --- a/src/components/pages/SingleStigmataPage.tsx +++ b/src/components/pages/SingleStigmataPage.tsx @@ -43,7 +43,9 @@ const SingleStigmataPage = ({ return ( { return ( { diff --git a/src/pages/honkai3rd/elfs/[elfId].tsx b/src/pages/honkai3rd/elfs/[elfId].tsx index d31c8477..ad370bdf 100644 --- a/src/pages/honkai3rd/elfs/[elfId].tsx +++ b/src/pages/honkai3rd/elfs/[elfId].tsx @@ -28,7 +28,9 @@ const ElfShowPage = ({ elf }: ElfShowPageProps) => { return ( { return ( diff --git a/src/pages/honkai3rd/enemies/index.tsx b/src/pages/honkai3rd/enemies/index.tsx new file mode 100644 index 00000000..c8c61c6f --- /dev/null +++ b/src/pages/honkai3rd/enemies/index.tsx @@ -0,0 +1,181 @@ +/** @jsxImportSource theme-ui */ +import { Box, Heading } from '@theme-ui/components' +import Breadcrumb from '../../../components/organisms/Breadcrumb' +import Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator' +import { NextPageContext } from 'next' +import { getI18NProps } from '../../../server/i18n' +import { useTranslation } from '../../../lib/i18n' +import Head from '../../../components/atoms/Head' +import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { times } from 'ramda' + +const enemyIdList = [ + ...times((i) => i + 0, 1000).map((i) => { + const stringified = i.toString() + return `BOSS_${'0'.repeat(3 - stringified.length) + stringified}` + }), + // ...times((i) => i + 65, 26) + // .reduce<[number, number][]>((array, first) => { + // array.push( + // ...times((i) => i + 65, 26).map<[number, number]>((second) => [ + // first, + // second, + // ]) + // ) + // return array + // }, []) + // .map(([first, second]) => { + // return String.fromCharCode(first) + String.fromCharCode(second) + // }) + // .reduce((idList, prefix) => { + // idList.push( + // ...times((i) => i + 12, 1).map((i) => { + // const stringified = i.toString() + // return `${prefix}_${'0'.repeat(3 - stringified.length) + stringified}` + // }) + // ) + // return idList + // }, []), +] + +console.log( + times((i) => i + 65, 26) + .reduce<[number, number][]>((array, first) => { + array.push( + ...times((i) => i + 65, 26).map<[number, number]>((second) => [ + first, + second, + ]) + ) + return array + }, []) + .map(([first, second]) => { + return String.fromCharCode(first) + String.fromCharCode(second) + }) + .reduce((idList, prefix) => { + idList.push( + ...times((i) => i + 10, 1).map((i) => { + const stringified = i.toString() + return `${prefix}_${'0'.repeat(3 - stringified.length) + stringified}` + }) + ) + return idList + }, []) +) + +// console.log( +// times(i => i + 65, 26).map(code => { +// return [...times((i) => i + 10, 10).map((i) => { +// const stringified = i.toString() +// return `_${'0'.repeat(3 - stringified.length) + stringified}` +// })] +// }) +// ) + +const Honkai3rdIndexPage = () => { + const { t } = useTranslation() + const [validList, setValidList] = useState([]) + const validMap = useMemo(() => { + return new Map(validList.map((id) => [id, id])) + }, [validList]) + const initializedRef = useRef(false) + + const appendValidList = useCallback((enemyId: string) => { + setValidList((previousList) => { + return [...previousList, enemyId] + }) + }, []) + + useEffect(() => { + let data = validList + if (!initializedRef.current) { + initializedRef.current = true + let rawValidEnemyIdList = localStorage.getItem('valid-enemy-id-list') + try { + console.log('load') + data = JSON.parse(rawValidEnemyIdList || '[]') + if (!Array.isArray(data)) { + throw new Error('data must be array') + } + } catch (error) { + console.warn(error) + data = [] + } + setValidList(data) + return + } + + console.log('save') + localStorage.setItem('valid-enemy-id-list', JSON.stringify(data)) + }, [validList]) + + return ( + + + + + + + Enemies + + + + {enemyIdList + .filter((enemyId) => !validMap.get(enemyId)) + .map((enemyId) => { + return ( + + {enemyId} + + + ) + })} + +

Valid

+ + {validList.map((enemyId) => { + return ( + + {enemyId} + {enemyId} + + + ) + })} + +
+ ) +} + +export async function getStaticProps({ locale }: NextPageContext) { + return { + props: { + ...(await getI18NProps(locale)), + }, + } +} + +export default Honkai3rdIndexPage diff --git a/src/pages/honkai3rd/index.tsx b/src/pages/honkai3rd/index.tsx index 76699533..8fe929ad 100644 --- a/src/pages/honkai3rd/index.tsx +++ b/src/pages/honkai3rd/index.tsx @@ -45,7 +45,7 @@ const Honkai3rdIndexPage = () => { return ( diff --git a/src/pages/honkai3rd/stigmata/index.tsx b/src/pages/honkai3rd/stigmata/index.tsx index 99ce06bc..a384c50a 100644 --- a/src/pages/honkai3rd/stigmata/index.tsx +++ b/src/pages/honkai3rd/stigmata/index.tsx @@ -42,7 +42,7 @@ const StigmataListPage = ({ diff --git a/src/pages/honkai3rd/versions/[versionId].tsx b/src/pages/honkai3rd/versions/[versionId].tsx index ba38a8ec..864460ef 100644 --- a/src/pages/honkai3rd/versions/[versionId].tsx +++ b/src/pages/honkai3rd/versions/[versionId].tsx @@ -45,9 +45,9 @@ const VersionShowPage = ({ return ( diff --git a/src/pages/honkai3rd/weapons/[weaponId].tsx b/src/pages/honkai3rd/weapons/[weaponId].tsx index bc4a1c4e..a6e4a42f 100644 --- a/src/pages/honkai3rd/weapons/[weaponId].tsx +++ b/src/pages/honkai3rd/weapons/[weaponId].tsx @@ -29,7 +29,9 @@ const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => { return ( { return (