Refactor stigmata data
This commit is contained in:
@@ -1,25 +1,16 @@
|
|||||||
/** @jsxImportSource theme-ui */
|
/** @jsxImportSource theme-ui */
|
||||||
import { Box, Card, Text, Flex } from '@theme-ui/components'
|
import { Box, Card, Text, Flex } from '@theme-ui/components'
|
||||||
import { useRouter } from 'next/router'
|
|
||||||
import { assetsBucketBaseUrl } from '../../lib/consts'
|
import { assetsBucketBaseUrl } from '../../lib/consts'
|
||||||
import { StigmataData } from '../../lib/honkai3rd/stigmata'
|
import { StigmataData } from '../../lib/honkai3rd/stigmata'
|
||||||
import { translate } from '../../lib/i18n'
|
|
||||||
import PageLink from '../atoms/PageLink'
|
import PageLink from '../atoms/PageLink'
|
||||||
import SquareImageBox from '../atoms/SquareImageBox'
|
import SquareImageBox from '../atoms/SquareImageBox'
|
||||||
|
|
||||||
interface StigmataCardProps {
|
interface StigmataCardProps {
|
||||||
stigmata: Pick<StigmataData, 'id' | 'name' | 'rarity' | 'krName'>
|
stigmata: Pick<StigmataData, 'id' | 'name' | 'rarity'>
|
||||||
size?: 'sm' | 'default'
|
size?: 'sm' | 'default'
|
||||||
}
|
}
|
||||||
|
|
||||||
const StigmataCard = ({ stigmata, size }: StigmataCardProps) => {
|
const StigmataCard = ({ stigmata, size }: StigmataCardProps) => {
|
||||||
const { locale } = useRouter()
|
|
||||||
const stigmataName = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmata.krName },
|
|
||||||
stigmata.name
|
|
||||||
)
|
|
||||||
|
|
||||||
if (size === 'sm') {
|
if (size === 'sm') {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
@@ -36,7 +27,7 @@ const StigmataCard = ({ stigmata, size }: StigmataCardProps) => {
|
|||||||
<Flex>
|
<Flex>
|
||||||
<SquareImageBox
|
<SquareImageBox
|
||||||
mr={2}
|
mr={2}
|
||||||
alt={stigmataName}
|
alt={stigmata.name}
|
||||||
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${stigmata.id}.png`}
|
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${stigmata.id}.png`}
|
||||||
size={30}
|
size={30}
|
||||||
/>
|
/>
|
||||||
@@ -49,7 +40,7 @@ const StigmataCard = ({ stigmata, size }: StigmataCardProps) => {
|
|||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text sx={{ lineHeight: '30px' }}>{stigmataName}</Text>
|
<Text sx={{ lineHeight: '30px' }}>{stigmata.name}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
</PageLink>
|
</PageLink>
|
||||||
@@ -68,7 +59,7 @@ const StigmataCard = ({ stigmata, size }: StigmataCardProps) => {
|
|||||||
<PageLink href={`/honkai3rd/stigmata/${stigmata.id}`}>
|
<PageLink href={`/honkai3rd/stigmata/${stigmata.id}`}>
|
||||||
<SquareImageBox
|
<SquareImageBox
|
||||||
size={[75, 100]}
|
size={[75, 100]}
|
||||||
alt={stigmataName}
|
alt={stigmata.name}
|
||||||
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${stigmata.id}.png`}
|
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${stigmata.id}.png`}
|
||||||
/>
|
/>
|
||||||
<Box
|
<Box
|
||||||
@@ -80,7 +71,7 @@ const StigmataCard = ({ stigmata, size }: StigmataCardProps) => {
|
|||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text>{stigmataName}</Text>
|
<Text>{stigmata.name}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ fontSize: 1, textAlign: 'center' }}>
|
<Box sx={{ fontSize: 1, textAlign: 'center' }}>
|
||||||
{'⭐'.repeat(stigmata.rarity)}
|
{'⭐'.repeat(stigmata.rarity)}
|
||||||
|
|||||||
@@ -1,24 +1,15 @@
|
|||||||
/** @jsxImportSource theme-ui */
|
/** @jsxImportSource theme-ui */
|
||||||
import { Box, Card, Flex, Text } from '@theme-ui/components'
|
import { Box, Card, Flex, Text } from '@theme-ui/components'
|
||||||
import { useRouter } from 'next/router'
|
|
||||||
import { assetsBucketBaseUrl } from '../../lib/consts'
|
import { assetsBucketBaseUrl } from '../../lib/consts'
|
||||||
import { StigmataSet } from '../../lib/honkai3rd/stigmata'
|
import { StigmataSet } from '../../lib/honkai3rd/stigmata'
|
||||||
import { translate } from '../../lib/i18n'
|
|
||||||
import PageLink from '../atoms/PageLink'
|
import PageLink from '../atoms/PageLink'
|
||||||
import SquareImageBox from '../atoms/SquareImageBox'
|
import SquareImageBox from '../atoms/SquareImageBox'
|
||||||
|
|
||||||
interface StigmataSetCardProps {
|
interface StigmataSetCardProps {
|
||||||
stigmataSet: Pick<StigmataSet, 'id' | 'name' | 'krName' | 'rarity'>
|
stigmataSet: Pick<StigmataSet, 'id' | 'name' | 'rarity'>
|
||||||
}
|
}
|
||||||
|
|
||||||
const StigmataSetCard = ({ stigmataSet }: StigmataSetCardProps) => {
|
const StigmataSetCard = ({ stigmataSet }: StigmataSetCardProps) => {
|
||||||
const { locale } = useRouter()
|
|
||||||
const stigmataSetName = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.krName },
|
|
||||||
stigmataSet.name
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
sx={{
|
sx={{
|
||||||
@@ -31,17 +22,17 @@ const StigmataSetCard = ({ stigmataSet }: StigmataSetCardProps) => {
|
|||||||
<Flex sx={{ justifyContent: 'space-around' }}>
|
<Flex sx={{ justifyContent: 'space-around' }}>
|
||||||
<SquareImageBox
|
<SquareImageBox
|
||||||
size={[80, 100]}
|
size={[80, 100]}
|
||||||
alt={`${stigmataSet.id} Top`}
|
alt={`${stigmataSet.name} Top`}
|
||||||
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${stigmataSet.id}-top.png`}
|
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${stigmataSet.id}-top.png`}
|
||||||
/>
|
/>
|
||||||
<SquareImageBox
|
<SquareImageBox
|
||||||
size={[80, 100]}
|
size={[80, 100]}
|
||||||
alt={`${stigmataSet.id} Mid`}
|
alt={`${stigmataSet.name} Mid`}
|
||||||
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${stigmataSet.id}-mid.png`}
|
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${stigmataSet.id}-mid.png`}
|
||||||
/>
|
/>
|
||||||
<SquareImageBox
|
<SquareImageBox
|
||||||
size={[80, 100]}
|
size={[80, 100]}
|
||||||
alt={`${stigmataSet.id} Bottom`}
|
alt={`${stigmataSet.name} Bottom`}
|
||||||
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${stigmataSet.id}-bot.png`}
|
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${stigmataSet.id}-bot.png`}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
@@ -54,7 +45,7 @@ const StigmataSetCard = ({ stigmataSet }: StigmataSetCardProps) => {
|
|||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text>{stigmataSetName}</Text>
|
<Text>{stigmataSet.name}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ fontSize: 1, textAlign: 'center' }}>
|
<Box sx={{ fontSize: 1, textAlign: 'center' }}>
|
||||||
{'⭐'.repeat(stigmataSet.rarity)}
|
{'⭐'.repeat(stigmataSet.rarity)}
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ import PageLink from '../../components/atoms/PageLink'
|
|||||||
import StigmataCard from '../../components/molecules/StigmataCard'
|
import StigmataCard from '../../components/molecules/StigmataCard'
|
||||||
import Breadcrumb from '../../components/organisms/Breadcrumb'
|
import Breadcrumb from '../../components/organisms/Breadcrumb'
|
||||||
import SecondaryLabel from '../atoms/SecondaryLabel'
|
import SecondaryLabel from '../atoms/SecondaryLabel'
|
||||||
import { useRouter } from 'next/router'
|
import { useTranslation } from '../../lib/i18n'
|
||||||
import { translate, useTranslation } from '../../lib/i18n'
|
|
||||||
import Head from '../atoms/Head'
|
import Head from '../atoms/Head'
|
||||||
import { assetsBucketBaseUrl } from '../../lib/consts'
|
import { assetsBucketBaseUrl } from '../../lib/consts'
|
||||||
import Honkai3rdLayout from '../layouts/Honkai3rdLayout'
|
import Honkai3rdLayout from '../layouts/Honkai3rdLayout'
|
||||||
@@ -30,27 +29,12 @@ const SingleStigmataPage = ({
|
|||||||
stigmataSet,
|
stigmataSet,
|
||||||
stigmataSetList,
|
stigmataSetList,
|
||||||
}: SingleStigmataPageProps) => {
|
}: SingleStigmataPageProps) => {
|
||||||
const { locale } = useRouter()
|
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const stigmataName = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataData.krName },
|
|
||||||
stigmataData.name
|
|
||||||
)
|
|
||||||
|
|
||||||
const stigmataSkillDescription = translate(
|
|
||||||
locale,
|
|
||||||
{
|
|
||||||
'ko-KR': stigmataData.skill.krDescription,
|
|
||||||
},
|
|
||||||
stigmataData.skill.description
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Honkai3rdLayout>
|
<Honkai3rdLayout>
|
||||||
<Head
|
<Head
|
||||||
title={`${stigmataName} - ${t('common.honkai-3rd')} - ${t(
|
title={`${stigmataData.name} - ${t('common.honkai-3rd')} - ${t(
|
||||||
'common.abyss-lab'
|
'common.abyss-lab'
|
||||||
)}`}
|
)}`}
|
||||||
description={`${t('common.honkai-3rd')} ${t('stigmata-show.stigmata')} /
|
description={`${t('common.honkai-3rd')} ${t('stigmata-show.stigmata')} /
|
||||||
@@ -67,12 +51,12 @@ const SingleStigmataPage = ({
|
|||||||
{ href: '/honkai3rd/stigmata', label: t('common.stigmata') },
|
{ href: '/honkai3rd/stigmata', label: t('common.stigmata') },
|
||||||
{
|
{
|
||||||
href: `/honkai3rd/stigmata/${stigmataData.id}`,
|
href: `/honkai3rd/stigmata/${stigmataData.id}`,
|
||||||
label: stigmataName,
|
label: stigmataData.name,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Heading as='h1'>{stigmataName}</Heading>
|
<Heading as='h1'>{stigmataData.name}</Heading>
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
mb={3}
|
mb={3}
|
||||||
@@ -85,7 +69,7 @@ const SingleStigmataPage = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
alt={stigmataName}
|
alt={stigmataData.name}
|
||||||
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/${stigmataData.id}.png`}
|
src={`${assetsBucketBaseUrl}/honkai3rd/stigmata/${stigmataData.id}.png`}
|
||||||
width={400}
|
width={400}
|
||||||
height={400}
|
height={400}
|
||||||
@@ -103,7 +87,7 @@ const SingleStigmataPage = ({
|
|||||||
HP : {stigmataData.hp} / ATK : {stigmataData.atk} / DEF :{' '}
|
HP : {stigmataData.hp} / ATK : {stigmataData.atk} / DEF :{' '}
|
||||||
{stigmataData.def} / CRT : {stigmataData.crt}
|
{stigmataData.def} / CRT : {stigmataData.crt}
|
||||||
</Box>
|
</Box>
|
||||||
<Paragraph p={2}>{stigmataSkillDescription}</Paragraph>
|
<Paragraph p={2}>{stigmataData.skill.description}</Paragraph>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{stigmataSet != null && (
|
{stigmataSet != null && (
|
||||||
@@ -111,20 +95,10 @@ const SingleStigmataPage = ({
|
|||||||
<Box sx={{ p: 2, borderBottom: 'default' }}>
|
<Box sx={{ p: 2, borderBottom: 'default' }}>
|
||||||
<Heading as='h2' mb={1}>
|
<Heading as='h2' mb={1}>
|
||||||
<PageLink href={`/honkai3rd/stigmata/${stigmataSet.id}-set`}>
|
<PageLink href={`/honkai3rd/stigmata/${stigmataSet.id}-set`}>
|
||||||
{translate(
|
{stigmataSet.name}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.krName },
|
|
||||||
stigmataSet.name
|
|
||||||
)}
|
|
||||||
</PageLink>
|
</PageLink>
|
||||||
</Heading>
|
</Heading>
|
||||||
<SecondaryLabel>
|
<SecondaryLabel>{stigmataSet.altName}</SecondaryLabel>
|
||||||
{translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.krAltName },
|
|
||||||
stigmataSet.altName
|
|
||||||
)}
|
|
||||||
</SecondaryLabel>
|
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
@@ -146,32 +120,16 @@ const SingleStigmataPage = ({
|
|||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Heading as='h3' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
<Heading as='h3' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
||||||
{translate(
|
{stigmataSet.twoSetSkill.name}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.twoSetSkill.krName },
|
|
||||||
stigmataSet.twoSetSkill.name
|
|
||||||
)}
|
|
||||||
</Heading>
|
</Heading>
|
||||||
<Paragraph m={0} p={2} sx={{ borderBottom: 'default' }}>
|
<Paragraph m={0} p={2} sx={{ borderBottom: 'default' }}>
|
||||||
{translate(
|
{stigmataSet.twoSetSkill.description}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.twoSetSkill.krDescription },
|
|
||||||
stigmataSet.twoSetSkill.description
|
|
||||||
)}
|
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Heading as='h3' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
<Heading as='h3' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
||||||
{translate(
|
{stigmataSet.threeSetSkill.name}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.threeSetSkill.krName },
|
|
||||||
stigmataSet.threeSetSkill.name
|
|
||||||
)}
|
|
||||||
</Heading>
|
</Heading>
|
||||||
<Paragraph m={0} p={2}>
|
<Paragraph m={0} p={2}>
|
||||||
{translate(
|
{stigmataSet.threeSetSkill.description}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.threeSetSkill.krDescription },
|
|
||||||
stigmataSet.threeSetSkill.description
|
|
||||||
)}
|
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import StigmataCard from '../../components/molecules/StigmataCard'
|
|||||||
import Breadcrumb from '../../components/organisms/Breadcrumb'
|
import Breadcrumb from '../../components/organisms/Breadcrumb'
|
||||||
import { StigmataData, StigmataSet } from '../../lib/honkai3rd/stigmata'
|
import { StigmataData, StigmataSet } from '../../lib/honkai3rd/stigmata'
|
||||||
import SecondaryLabel from '../atoms/SecondaryLabel'
|
import SecondaryLabel from '../atoms/SecondaryLabel'
|
||||||
import { translate, useTranslation } from '../../lib/i18n'
|
import { useTranslation } from '../../lib/i18n'
|
||||||
import { useRouter } from 'next/router'
|
|
||||||
import Head from '../atoms/Head'
|
import Head from '../atoms/Head'
|
||||||
import Honkai3rdLayout from '../layouts/Honkai3rdLayout'
|
import Honkai3rdLayout from '../layouts/Honkai3rdLayout'
|
||||||
|
|
||||||
@@ -22,28 +21,16 @@ const StigmataSetPage = ({
|
|||||||
stigmataSetList,
|
stigmataSetList,
|
||||||
}: StigmataSetProps) => {
|
}: StigmataSetProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { locale } = useRouter()
|
|
||||||
|
|
||||||
const stigmataSetName = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.krName },
|
|
||||||
stigmataSet.name
|
|
||||||
)
|
|
||||||
const stigmataSetAltName = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.krAltName },
|
|
||||||
stigmataSet.altName
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Honkai3rdLayout>
|
<Honkai3rdLayout>
|
||||||
<Head
|
<Head
|
||||||
title={`${stigmataSetName} ${t('stigmata-show.stigmata-set')} - ${t(
|
title={`${stigmataSet.name} ${t('stigmata-show.stigmata-set')} - ${t(
|
||||||
'common.honkai-3rd'
|
'common.honkai-3rd'
|
||||||
)} - ${t('common.abyss-lab')}`}
|
)} - ${t('common.abyss-lab')}`}
|
||||||
description={`${t('common.honkai-3rd')} ${t(
|
description={`${t('common.honkai-3rd')} ${t(
|
||||||
'stigmata-show.stigmata-set'
|
'stigmata-show.stigmata-set'
|
||||||
)} / ${'⭐'.repeat(stigmataSet.rarity)} / ${stigmataSetAltName}`}
|
)} / ${'⭐'.repeat(stigmataSet.rarity)} / ${stigmataSet.altName}`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Box p={3}>
|
<Box p={3}>
|
||||||
@@ -59,16 +46,16 @@ const StigmataSetPage = ({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: `/honkai3rd/stigmata/${stigmataSet.id}-set`,
|
href: `/honkai3rd/stigmata/${stigmataSet.id}-set`,
|
||||||
label: stigmataSetName,
|
label: stigmataSet.name,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Box mb={3}>
|
<Box mb={3}>
|
||||||
<Heading as='h1' mb={0}>
|
<Heading as='h1' mb={0}>
|
||||||
{stigmataSetName}
|
{stigmataSet.name}
|
||||||
</Heading>
|
</Heading>
|
||||||
<SecondaryLabel>{stigmataSetAltName}</SecondaryLabel>
|
<SecondaryLabel>{stigmataSet.altName}</SecondaryLabel>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Card mb={3}>
|
<Card mb={3}>
|
||||||
@@ -90,16 +77,6 @@ const StigmataSetPage = ({
|
|||||||
})}
|
})}
|
||||||
</Flex>
|
</Flex>
|
||||||
{stigmataSetList.map((stigmataSetItem) => {
|
{stigmataSetList.map((stigmataSetItem) => {
|
||||||
const stigmataName = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSetItem.krName },
|
|
||||||
stigmataSetItem.name
|
|
||||||
)
|
|
||||||
const stigmataSkillDescrpition = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSetItem.skill.krDescription },
|
|
||||||
stigmataSetItem.skill.description
|
|
||||||
)
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={stigmataSetItem.id}>
|
<React.Fragment key={stigmataSetItem.id}>
|
||||||
<Box sx={{ p: 2, borderBottom: 'default' }}>
|
<Box sx={{ p: 2, borderBottom: 'default' }}>
|
||||||
@@ -107,7 +84,7 @@ const StigmataSetPage = ({
|
|||||||
<PageLink
|
<PageLink
|
||||||
href={`/honkai3rd/stigmata/${stigmataSetItem.id}`}
|
href={`/honkai3rd/stigmata/${stigmataSetItem.id}`}
|
||||||
>
|
>
|
||||||
{stigmataName}
|
{stigmataSetItem.name}
|
||||||
</PageLink>
|
</PageLink>
|
||||||
</Heading>
|
</Heading>
|
||||||
<SecondaryLabel>
|
<SecondaryLabel>
|
||||||
@@ -126,7 +103,7 @@ const StigmataSetPage = ({
|
|||||||
'&:last-child': { borderBottom: 'none' },
|
'&:last-child': { borderBottom: 'none' },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{stigmataSkillDescrpition}
|
{stigmataSetItem.skill.description}
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
@@ -135,34 +112,16 @@ const StigmataSetPage = ({
|
|||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<Heading as='h2' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
<Heading as='h2' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
||||||
{translate(
|
{stigmataSet.twoSetSkill.name}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.twoSetSkill.krName },
|
|
||||||
stigmataSet.twoSetSkill.name
|
|
||||||
)}
|
|
||||||
</Heading>
|
</Heading>
|
||||||
<Paragraph m={0} p={2} sx={{ borderBottom: 'default' }}>
|
<Paragraph m={0} p={2} sx={{ borderBottom: 'default' }}>
|
||||||
{translate(
|
{stigmataSet.twoSetSkill.description}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.twoSetSkill.krDescription },
|
|
||||||
stigmataSet.twoSetSkill.description
|
|
||||||
)}
|
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Heading as='h2' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
<Heading as='h2' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
||||||
{translate(
|
{stigmataSet.threeSetSkill.name}
|
||||||
locale,
|
|
||||||
{
|
|
||||||
'ko-KR': stigmataSet.threeSetSkill.krName,
|
|
||||||
},
|
|
||||||
stigmataSet.threeSetSkill.name
|
|
||||||
)}
|
|
||||||
</Heading>
|
</Heading>
|
||||||
<Paragraph m={0} p={2}>
|
<Paragraph m={0} p={2}>
|
||||||
{translate(
|
{stigmataSet.threeSetSkill.description}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.threeSetSkill.krDescription },
|
|
||||||
stigmataSet.threeSetSkill.description
|
|
||||||
)}
|
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
</Card>
|
</Card>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
export interface StigmataSkill {
|
export interface StigmataSkill {
|
||||||
name: string
|
name: string
|
||||||
krName?: string
|
|
||||||
description: string
|
description: string
|
||||||
krDescription?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StigmataData {
|
export interface StigmataData {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
krName?: string
|
|
||||||
skill: StigmataSkill
|
skill: StigmataSkill
|
||||||
atk: number
|
atk: number
|
||||||
def: number
|
def: number
|
||||||
@@ -24,9 +21,7 @@ export interface StigmataData {
|
|||||||
export interface StigmataSet {
|
export interface StigmataSet {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
krName?: string
|
|
||||||
altName: string
|
altName: string
|
||||||
krAltName?: string
|
|
||||||
twoSetSkill: StigmataSkill
|
twoSetSkill: StigmataSkill
|
||||||
threeSetSkill: StigmataSkill
|
threeSetSkill: StigmataSkill
|
||||||
rarity: 3 | 4 | 5
|
rarity: 3 | 4 | 5
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ export async function getStaticProps({
|
|||||||
)
|
)
|
||||||
const weaponMap = getWeaponMapByIds(weaponIds, locale)
|
const weaponMap = getWeaponMapByIds(weaponIds, locale)
|
||||||
|
|
||||||
const stigmataMap = getStigmataMapByIds(stigmataIds)
|
const stigmataMap = getStigmataMapByIds(stigmataIds, locale)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -229,9 +229,9 @@ export async function getStaticProps({
|
|||||||
},
|
},
|
||||||
{ weaponIds: [], stigmataIds: [] }
|
{ weaponIds: [], stigmataIds: [] }
|
||||||
)
|
)
|
||||||
const weaponMap = getWeaponMapByIds(weaponIds)
|
const weaponMap = getWeaponMapByIds(weaponIds, locale)
|
||||||
|
|
||||||
const stigmataMap = getStigmataMapByIds(stigmataIds)
|
const stigmataMap = getStigmataMapByIds(stigmataIds, locale)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -6,47 +6,35 @@ import { StigmataSetProps } from '../../../../components/pages/StigmataSetPage'
|
|||||||
import { generateI18NPaths, getI18NProps } from '../../../../server/i18n'
|
import { generateI18NPaths, getI18NProps } from '../../../../server/i18n'
|
||||||
import {
|
import {
|
||||||
listStigmata,
|
listStigmata,
|
||||||
getStigmataById,
|
|
||||||
getStigmataListBySetId,
|
getStigmataListBySetId,
|
||||||
getStigmataSetBySetId,
|
getStigmataSetBySetId,
|
||||||
listStigmataSet,
|
listStigmataSet,
|
||||||
|
getStigmaById,
|
||||||
} from '../../../../server/data/honkai3rd/stigmata'
|
} from '../../../../server/data/honkai3rd/stigmata'
|
||||||
import { Box, Card, Flex, Heading, Paragraph } from 'theme-ui'
|
import { Box, Card, Flex, Heading, Paragraph } from 'theme-ui'
|
||||||
import SecondaryLabel from '../../../../components/atoms/SecondaryLabel'
|
import SecondaryLabel from '../../../../components/atoms/SecondaryLabel'
|
||||||
import StigmataCard from '../../../../components/molecules/StigmataCard'
|
import StigmataCard from '../../../../components/molecules/StigmataCard'
|
||||||
import { translate, useTranslation } from '../../../../lib/i18n'
|
import { useTranslation } from '../../../../lib/i18n'
|
||||||
import { useRouter } from 'next/router'
|
|
||||||
import { SingleStigmataPageProps } from '../../../../components/pages/SingleStigmataPage'
|
import { SingleStigmataPageProps } from '../../../../components/pages/SingleStigmataPage'
|
||||||
|
|
||||||
type StigmataShowPageProps = StigmataSetProps | SingleStigmataPageProps
|
type StigmataShowPageProps = StigmataSetProps | SingleStigmataPageProps
|
||||||
|
|
||||||
const StigmataListPage = (props: StigmataShowPageProps) => {
|
const StigmataListPage = (props: StigmataShowPageProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { locale } = useRouter()
|
|
||||||
|
|
||||||
if (props.type === 'single') {
|
if (props.type === 'single') {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const { stigmataSet, stigmataSetList } = props
|
const { stigmataSet, stigmataSetList } = props
|
||||||
const stigmataSetName = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.krName },
|
|
||||||
stigmataSet.name
|
|
||||||
)
|
|
||||||
const stigmataSetAltName = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.krAltName },
|
|
||||||
stigmataSet.altName
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box p={3}>
|
<Box p={3}>
|
||||||
<Box mb={3}>
|
<Box mb={3}>
|
||||||
<Heading as='h1' mb={0}>
|
<Heading as='h1' mb={0}>
|
||||||
{stigmataSetName}
|
{stigmataSet.name}
|
||||||
</Heading>
|
</Heading>
|
||||||
<SecondaryLabel>{stigmataSetAltName}</SecondaryLabel>
|
<SecondaryLabel>{stigmataSet.altName}</SecondaryLabel>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Card mb={3}>
|
<Card mb={3}>
|
||||||
@@ -68,22 +56,12 @@ const StigmataListPage = (props: StigmataShowPageProps) => {
|
|||||||
})}
|
})}
|
||||||
</Flex>
|
</Flex>
|
||||||
{stigmataSetList.map((stigmataSetItem) => {
|
{stigmataSetList.map((stigmataSetItem) => {
|
||||||
const stigmataName = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSetItem.krName },
|
|
||||||
stigmataSetItem.name
|
|
||||||
)
|
|
||||||
const stigmataSkillDescrpition = translate(
|
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSetItem.skill.krDescription },
|
|
||||||
stigmataSetItem.skill.description
|
|
||||||
)
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={stigmataSetItem.id}>
|
<React.Fragment key={stigmataSetItem.id}>
|
||||||
<Box sx={{ p: 2, borderBottom: 'default' }}>
|
<Box sx={{ p: 2, borderBottom: 'default' }}>
|
||||||
<Heading as='h2' mb={1}>
|
<Heading as='h2' mb={1}>
|
||||||
<PageLink href={`/honkai3rd/stigmata/${stigmataSetItem.id}`}>
|
<PageLink href={`/honkai3rd/stigmata/${stigmataSetItem.id}`}>
|
||||||
{stigmataName}
|
{stigmataSetItem.name}
|
||||||
</PageLink>
|
</PageLink>
|
||||||
</Heading>
|
</Heading>
|
||||||
<SecondaryLabel>
|
<SecondaryLabel>
|
||||||
@@ -102,7 +80,7 @@ const StigmataListPage = (props: StigmataShowPageProps) => {
|
|||||||
'&:last-child': { borderBottom: 'none' },
|
'&:last-child': { borderBottom: 'none' },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{stigmataSkillDescrpition}
|
{stigmataSetItem.skill.description}
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
@@ -111,34 +89,16 @@ const StigmataListPage = (props: StigmataShowPageProps) => {
|
|||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<Heading as='h2' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
<Heading as='h2' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
||||||
{translate(
|
{stigmataSet.twoSetSkill.name}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.twoSetSkill.krName },
|
|
||||||
stigmataSet.twoSetSkill.name
|
|
||||||
)}
|
|
||||||
</Heading>
|
</Heading>
|
||||||
<Paragraph m={0} p={2} sx={{ borderBottom: 'default' }}>
|
<Paragraph m={0} p={2} sx={{ borderBottom: 'default' }}>
|
||||||
{translate(
|
{stigmataSet.twoSetSkill.description}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.twoSetSkill.krDescription },
|
|
||||||
stigmataSet.twoSetSkill.description
|
|
||||||
)}
|
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Heading as='h2' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
<Heading as='h2' m={0} p={2} sx={{ borderBottom: 'default' }}>
|
||||||
{translate(
|
{stigmataSet.threeSetSkill.name}
|
||||||
locale,
|
|
||||||
{
|
|
||||||
'ko-KR': stigmataSet.threeSetSkill.krName,
|
|
||||||
},
|
|
||||||
stigmataSet.threeSetSkill.name
|
|
||||||
)}
|
|
||||||
</Heading>
|
</Heading>
|
||||||
<Paragraph m={0} p={2}>
|
<Paragraph m={0} p={2}>
|
||||||
{translate(
|
{stigmataSet.threeSetSkill.description}
|
||||||
locale,
|
|
||||||
{ 'ko-KR': stigmataSet.threeSetSkill.krDescription },
|
|
||||||
stigmataSet.threeSetSkill.description
|
|
||||||
)}
|
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
</Card>
|
</Card>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -151,29 +111,29 @@ export async function getStaticProps({
|
|||||||
params,
|
params,
|
||||||
locale,
|
locale,
|
||||||
}: NextPageContext & { params: { stigmataId: string } }) {
|
}: NextPageContext & { params: { stigmataId: string } }) {
|
||||||
const stigmataData = getStigmataById(params.stigmataId)!
|
const stigmataData = getStigmaById(params.stigmataId, locale)!
|
||||||
if (stigmataData != null) {
|
if (stigmataData != null) {
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
type: 'single',
|
type: 'single',
|
||||||
stigmataData: stigmataData,
|
stigmataData: stigmataData,
|
||||||
stigmataSetList: (getStigmataListBySetId(stigmataData.set!) || []).sort(
|
stigmataSetList: (
|
||||||
(a, b) => -a.type.localeCompare(b.type)
|
getStigmataListBySetId(stigmataData.set!, locale) || []
|
||||||
),
|
).sort((a, b) => -a.type.localeCompare(b.type)),
|
||||||
stigmataSet: getStigmataSetBySetId(stigmataData.set!) || null,
|
stigmataSet: getStigmataSetBySetId(stigmataData.set!, locale) || null,
|
||||||
...(await getI18NProps(locale)),
|
...(await getI18NProps(locale)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const [stigmataSetId] = params.stigmataId.split('-set')
|
const [stigmataSetId] = params.stigmataId.split('-set')
|
||||||
const stigmataSet = getStigmataSetBySetId(stigmataSetId)!
|
const stigmataSet = getStigmataSetBySetId(stigmataSetId, locale)!
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
type: 'set',
|
type: 'set',
|
||||||
stigmataSet,
|
stigmataSet,
|
||||||
stigmataSetList: (getStigmataListBySetId(stigmataSet.id) || []).sort(
|
stigmataSetList: (
|
||||||
(a, b) => -a.type.localeCompare(b.type)
|
getStigmataListBySetId(stigmataSet.id, locale) || []
|
||||||
),
|
).sort((a, b) => -a.type.localeCompare(b.type)),
|
||||||
...(await getI18NProps(locale)),
|
...(await getI18NProps(locale)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import StigmataSetPage, {
|
|||||||
import { generateI18NPaths, getI18NProps } from '../../../server/i18n'
|
import { generateI18NPaths, getI18NProps } from '../../../server/i18n'
|
||||||
import {
|
import {
|
||||||
listStigmata,
|
listStigmata,
|
||||||
getStigmataById,
|
getStigmaById,
|
||||||
getStigmataListBySetId,
|
getStigmataListBySetId,
|
||||||
getStigmataSetBySetId,
|
getStigmataSetBySetId,
|
||||||
listStigmataSet,
|
listStigmataSet,
|
||||||
@@ -31,29 +31,29 @@ export async function getStaticProps({
|
|||||||
params,
|
params,
|
||||||
locale,
|
locale,
|
||||||
}: NextPageContext & { params: { stigmataId: string } }) {
|
}: NextPageContext & { params: { stigmataId: string } }) {
|
||||||
const stigmataData = getStigmataById(params.stigmataId)!
|
const stigmataData = getStigmaById(params.stigmataId, locale)!
|
||||||
if (stigmataData != null) {
|
if (stigmataData != null) {
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
type: 'single',
|
type: 'single',
|
||||||
stigmataData: stigmataData,
|
stigmataData: stigmataData,
|
||||||
stigmataSetList: (getStigmataListBySetId(stigmataData.set!) || []).sort(
|
stigmataSetList: (
|
||||||
(a, b) => -a.type.localeCompare(b.type)
|
getStigmataListBySetId(stigmataData.set!, locale) || []
|
||||||
),
|
).sort((a, b) => -a.type.localeCompare(b.type)),
|
||||||
stigmataSet: getStigmataSetBySetId(stigmataData.set!) || null,
|
stigmataSet: getStigmataSetBySetId(stigmataData.set!, locale) || null,
|
||||||
...(await getI18NProps(locale)),
|
...(await getI18NProps(locale)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const [stigmataSetId] = params.stigmataId.split('-set')
|
const [stigmataSetId] = params.stigmataId.split('-set')
|
||||||
const stigmataSet = getStigmataSetBySetId(stigmataSetId)!
|
const stigmataSet = getStigmataSetBySetId(stigmataSetId, locale)!
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
type: 'set',
|
type: 'set',
|
||||||
stigmataSet,
|
stigmataSet,
|
||||||
stigmataSetList: (getStigmataListBySetId(stigmataSet.id) || []).sort(
|
stigmataSetList: (
|
||||||
(a, b) => -a.type.localeCompare(b.type)
|
getStigmataListBySetId(stigmataSet.id, locale) || []
|
||||||
),
|
).sort((a, b) => -a.type.localeCompare(b.type)),
|
||||||
...(await getI18NProps(locale)),
|
...(await getI18NProps(locale)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import Head from '../../../components/atoms/Head'
|
|||||||
import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout'
|
import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout'
|
||||||
|
|
||||||
interface StigmataListPageProps {
|
interface StigmataListPageProps {
|
||||||
stigmataDataList: Pick<StigmataData, 'id' | 'name' | 'rarity' | 'krName'>[]
|
stigmataDataList: Pick<StigmataData, 'id' | 'name' | 'rarity'>[]
|
||||||
stigmataSetList: Pick<StigmataSet, 'id' | 'name' | 'rarity' | 'krName'>[]
|
stigmataSetList: Pick<StigmataSet, 'id' | 'name' | 'rarity'>[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const StigmataListPage = ({
|
const StigmataListPage = ({
|
||||||
@@ -102,11 +102,11 @@ export default StigmataListPage
|
|||||||
export async function getStaticProps({ locale }: NextPageContext) {
|
export async function getStaticProps({ locale }: NextPageContext) {
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
stigmataDataList: listStigmata().map((stigmata) =>
|
stigmataDataList: listStigmata(locale).map((stigmata) =>
|
||||||
pick(['id', 'name', 'rarity', 'krName'], stigmata)
|
pick(['id', 'name', 'rarity'], stigmata)
|
||||||
),
|
),
|
||||||
stigmataSetList: listStigmataSet().map((stigmataSet) =>
|
stigmataSetList: listStigmataSet(locale).map((stigmataSet) =>
|
||||||
pick(['id', 'name', 'rarity', 'krName'], stigmataSet)
|
pick(['id', 'name', 'rarity'], stigmataSet)
|
||||||
),
|
),
|
||||||
...(await getI18NProps(locale)),
|
...(await getI18NProps(locale)),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
import { runScript } from '../lib/utils'
|
|
||||||
import fs from 'fs'
|
|
||||||
import path from 'path'
|
|
||||||
import yaml from 'yaml'
|
|
||||||
import { listStigmataSet } from '../../server/data/honkai3rd/stigmata'
|
|
||||||
import sortKeys from 'sort-keys'
|
|
||||||
|
|
||||||
const order = [
|
|
||||||
'id',
|
|
||||||
'version',
|
|
||||||
'name',
|
|
||||||
'krName',
|
|
||||||
'altName',
|
|
||||||
'krAltName',
|
|
||||||
'type',
|
|
||||||
'rarity',
|
|
||||||
'twoSetSkill',
|
|
||||||
'threeSetSkill',
|
|
||||||
'description',
|
|
||||||
'krDescription',
|
|
||||||
]
|
|
||||||
|
|
||||||
async function migrateStigmataSets() {
|
|
||||||
const stigmataSetList = listStigmataSet()
|
|
||||||
const newDataDir = path.join(__dirname, '../../../data/honkai3rd')
|
|
||||||
|
|
||||||
const sortedData = sortKeys(stigmataSetList, {
|
|
||||||
deep: true,
|
|
||||||
compare: (a, b) => {
|
|
||||||
return order.indexOf(a) - order.indexOf(b)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(newDataDir, 'stigmata-sets.yaml'),
|
|
||||||
yaml.stringify(sortedData)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
runScript(migrateStigmataSets)
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
import { runScript } from '../lib/utils'
|
|
||||||
import fs from 'fs'
|
|
||||||
import path from 'path'
|
|
||||||
import yaml from 'yaml'
|
|
||||||
import { listStigmata } from '../../server/data/honkai3rd/stigmata'
|
|
||||||
import sortKeys from 'sort-keys'
|
|
||||||
|
|
||||||
const order = [
|
|
||||||
'id',
|
|
||||||
'version',
|
|
||||||
'name',
|
|
||||||
'krName',
|
|
||||||
'type',
|
|
||||||
'rarity',
|
|
||||||
'hp',
|
|
||||||
'atk',
|
|
||||||
'def',
|
|
||||||
'crt',
|
|
||||||
'set',
|
|
||||||
'skill',
|
|
||||||
'description',
|
|
||||||
'krDescription',
|
|
||||||
]
|
|
||||||
|
|
||||||
async function migrateStigmata() {
|
|
||||||
const stigmataList = listStigmata()
|
|
||||||
const newDataDir = path.join(__dirname, '../../../data/honkai3rd')
|
|
||||||
|
|
||||||
const sortedData = sortKeys(stigmataList, {
|
|
||||||
deep: true,
|
|
||||||
compare: (a, b) => {
|
|
||||||
return order.indexOf(a) - order.indexOf(b)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(newDataDir, 'stigmata.yaml'),
|
|
||||||
yaml.stringify(sortedData)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
runScript(migrateStigmata)
|
|
||||||
@@ -1,26 +1,29 @@
|
|||||||
import { readdirSync, readFileSync, readJsonFileSync } from '../fs'
|
|
||||||
import { compareVersion } from '../../../lib/string'
|
import { compareVersion } from '../../../lib/string'
|
||||||
import { StigmataData, StigmataSet } from '../../../lib/honkai3rd/stigmata'
|
import { StigmataData } from '../../../lib/honkai3rd/stigmata'
|
||||||
|
import yaml from 'yaml'
|
||||||
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
import { omit } from 'ramda'
|
||||||
|
|
||||||
const stigmataDataFileNameList = readdirSync('honkai3rd/stigmata')
|
let cachedStigmataData: any = null
|
||||||
const stigmataList = stigmataDataFileNameList
|
|
||||||
.map((fileName) => {
|
|
||||||
const filePathname = 'honkai3rd/stigmata/' + fileName
|
|
||||||
const data = readJsonFileSync(filePathname) as StigmataData
|
|
||||||
|
|
||||||
const krDataFilePath = `honkai3rd/ko-KR/stigmata/${data.id}.md`
|
export function listStigmata(locale?: string): StigmataData[] {
|
||||||
try {
|
if (cachedStigmataData == null) {
|
||||||
const krData = parseStigmataData(readFileSync(krDataFilePath).toString())
|
cachedStigmataData = yaml.parse(
|
||||||
|
fs
|
||||||
data.krName = krData.name
|
.readFileSync(path.join(process.cwd(), 'data/honkai3rd/stigmata.yaml'))
|
||||||
data.skill.krName = krData.skill.name
|
.toString('utf-8')
|
||||||
data.skill.krDescription = krData.skill.description
|
)
|
||||||
} catch (error) {
|
|
||||||
// console.warn('Failed to read', krDataFilePath)
|
|
||||||
// console.warn(error)
|
|
||||||
}
|
}
|
||||||
|
const stigmata = cachedStigmataData
|
||||||
|
|
||||||
return data
|
const localized = (stigmata as any[])
|
||||||
|
.map((stigma) => {
|
||||||
|
return {
|
||||||
|
...omit(['krName', 'krDescription'], stigma),
|
||||||
|
name: locale === 'ko-KR' ? stigma.krName : stigma.name,
|
||||||
|
skill: localizeSkill(stigma.skill),
|
||||||
|
} as any
|
||||||
})
|
})
|
||||||
.filter((stigmataData) => !stigmataData.hidden)
|
.filter((stigmataData) => !stigmataData.hidden)
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
@@ -46,47 +49,44 @@ const stigmataList = stigmataDataFileNameList
|
|||||||
|
|
||||||
return compareResult
|
return compareResult
|
||||||
})
|
})
|
||||||
const stigmataMap = stigmataList.reduce((map, stigmata) => {
|
return localized
|
||||||
map.set(stigmata.id, stigmata)
|
|
||||||
return map
|
|
||||||
}, new Map<string, StigmataData>())
|
|
||||||
|
|
||||||
const stigmataSetStigmataDataListMap = stigmataList.reduce((map, stigmata) => {
|
function localizeSkill(skill: any) {
|
||||||
if (stigmata.set != null) {
|
return {
|
||||||
let stigmataList = map.get(stigmata.set)
|
...omit(['krName', 'krDescription'], skill),
|
||||||
if (stigmataList == null) {
|
name: locale === 'ko-KR' ? skill.krName : skill.name,
|
||||||
stigmataList = []
|
description: locale === 'ko-KR' ? skill.krDescription : skill.description,
|
||||||
map.set(stigmata.set, stigmataList)
|
|
||||||
}
|
}
|
||||||
stigmataList.push(stigmata)
|
|
||||||
}
|
}
|
||||||
return map
|
}
|
||||||
}, new Map<string, StigmataData[]>())
|
|
||||||
|
|
||||||
const stigmataSetFileNameList = readdirSync('honkai3rd/stigmata-sets')
|
export function getStigmaById(id: string, locale?: string) {
|
||||||
const stigmataSetList = stigmataSetFileNameList
|
return listStigmata(locale).find((stigma) => stigma.id === id, locale)
|
||||||
.map((fileName) => {
|
}
|
||||||
const filePathname = 'honkai3rd/stigmata-sets/' + fileName
|
|
||||||
const data = readJsonFileSync(filePathname) as StigmataSet
|
|
||||||
|
|
||||||
const krDataFilePath = `honkai3rd/ko-KR/stigmata-sets/${data.id}.md`
|
let cachedStigmataSetsData: any = null
|
||||||
try {
|
|
||||||
const krData = parseStigmataSetData(
|
export function listStigmataSet(locale?: string): StigmataData[] {
|
||||||
readFileSync(krDataFilePath).toString()
|
if (cachedStigmataSetsData == null) {
|
||||||
|
cachedStigmataSetsData = yaml.parse(
|
||||||
|
fs
|
||||||
|
.readFileSync(
|
||||||
|
path.join(process.cwd(), 'data/honkai3rd/stigmata-sets.yaml')
|
||||||
|
)
|
||||||
|
.toString('utf-8')
|
||||||
)
|
)
|
||||||
|
|
||||||
data.krName = krData.name
|
|
||||||
data.krAltName = krData.altName
|
|
||||||
data.twoSetSkill.krName = krData.twoSetSkill.name
|
|
||||||
data.twoSetSkill.krDescription = krData.twoSetSkill.description
|
|
||||||
data.threeSetSkill.krName = krData.threeSetSkill.name
|
|
||||||
data.threeSetSkill.krDescription = krData.threeSetSkill.description
|
|
||||||
} catch (error) {
|
|
||||||
// console.warn('Failed to read', krDataFilePath)
|
|
||||||
// console.warn(error)
|
|
||||||
}
|
}
|
||||||
|
const stigmataSets = cachedStigmataSetsData as any[]
|
||||||
return data
|
const localized = stigmataSets
|
||||||
|
.map((stigmataSet) => {
|
||||||
|
return {
|
||||||
|
...omit(['krName', 'krDescription'], stigmataSet),
|
||||||
|
name: locale === 'ko-KR' ? stigmataSet.krName : stigmataSet.name,
|
||||||
|
altName:
|
||||||
|
locale === 'ko-KR' ? stigmataSet.krAltName : stigmataSet.altName,
|
||||||
|
twoSetSkill: localizeSkill(stigmataSet.twoSetSkill),
|
||||||
|
threeSetSkill: localizeSkill(stigmataSet.threeSetSkill),
|
||||||
|
} as any
|
||||||
})
|
})
|
||||||
.filter((stigmataSet) => !stigmataSet.hidden)
|
.filter((stigmataSet) => !stigmataSet.hidden)
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
@@ -104,80 +104,33 @@ const stigmataSetList = stigmataSetFileNameList
|
|||||||
|
|
||||||
return compareResult
|
return compareResult
|
||||||
})
|
})
|
||||||
|
return localized
|
||||||
|
|
||||||
const stigmataSetMap = stigmataSetList.reduce((map, stigmataSet) => {
|
function localizeSkill(skill: any) {
|
||||||
map.set(stigmataSet.id, stigmataSet)
|
return {
|
||||||
return map
|
...omit(['krName', 'krDescription'], skill),
|
||||||
}, new Map<string, StigmataSet>())
|
name: locale === 'ko-KR' ? skill.krName : skill.name,
|
||||||
|
description: locale === 'ko-KR' ? skill.krDescription : skill.description,
|
||||||
export function listStigmata() {
|
}
|
||||||
return stigmataList
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getStigmataById(id: string) {
|
export function getStigmataSetBySetId(setId: string, locale?: string) {
|
||||||
return stigmataMap.get(id)
|
return listStigmataSet(locale).find((set) => set.id === setId, locale)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listStigmataSet() {
|
export function getStigmataListBySetId(setId: string, locale?: string) {
|
||||||
return stigmataSetList
|
return ['top', 'mid', 'bot'].map((type) => {
|
||||||
|
return getStigmaById(setId + '-' + type, locale)!
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getStigmataListBySetId(setId: string) {
|
export function getStigmataMapByIds(idList: string[], locale?: string) {
|
||||||
return stigmataSetStigmataDataListMap.get(setId) || []
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getStigmataSetBySetId(setId: string) {
|
|
||||||
return stigmataSetMap.get(setId)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getStigmataMapByIds(idList: string[]) {
|
|
||||||
return idList.reduce<{ [key: string]: StigmataData }>((map, id) => {
|
return idList.reduce<{ [key: string]: StigmataData }>((map, id) => {
|
||||||
const stigmata = getStigmataById(id)
|
const stigmata = getStigmaById(id, locale)
|
||||||
if (stigmata != null) {
|
if (stigmata != null) {
|
||||||
map[id] = stigmata
|
map[id] = stigmata
|
||||||
}
|
}
|
||||||
return map
|
return map
|
||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStigmataData(rawData: string) {
|
|
||||||
const [name, skillName, skillDescription] = rawData
|
|
||||||
.replace(/\\\*/g, '*')
|
|
||||||
.split('\n\n')
|
|
||||||
.map((data) => data.replace(/#+\s/, '').trim())
|
|
||||||
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
skill: {
|
|
||||||
name: skillName,
|
|
||||||
description: skillDescription,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseStigmataSetData(rawData: string) {
|
|
||||||
const [
|
|
||||||
name,
|
|
||||||
altName,
|
|
||||||
twoSetSkillName,
|
|
||||||
twoSetSkillDescription,
|
|
||||||
threeSetSkillName,
|
|
||||||
threeSetSkillDescription,
|
|
||||||
] = rawData
|
|
||||||
.replace(/\\\*/g, '*')
|
|
||||||
.split('\n\n')
|
|
||||||
.map((data) => data.replace(/#+\s/, '').trim())
|
|
||||||
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
altName,
|
|
||||||
twoSetSkill: {
|
|
||||||
name: twoSetSkillName,
|
|
||||||
description: twoSetSkillDescription,
|
|
||||||
},
|
|
||||||
threeSetSkill: {
|
|
||||||
name: threeSetSkillName,
|
|
||||||
description: threeSetSkillDescription,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user