Add locale
This commit is contained in:
@@ -16,11 +16,15 @@ const FormattedText = ({ children }: FormattedTextProps) => {
|
||||
function renderTokens(tokens: FormattedTextToken[]) {
|
||||
return tokens.map((token, index) => {
|
||||
if (token.type === 'element') {
|
||||
if (token.tagName === 'color') {
|
||||
return (
|
||||
<Text key={index} style={{ color: adjustColor(token.attributes.color) }}>
|
||||
{renderTokens(token.children)}
|
||||
</Text>
|
||||
)
|
||||
} else {
|
||||
return <Text key={index}>{renderTokens(token.children)}</Text>
|
||||
}
|
||||
}
|
||||
|
||||
return token.text
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { tokenize } from './tokenize'
|
||||
|
||||
describe('tokenize', () => {
|
||||
it('still tokenize even when a closing tag is missing', () => {
|
||||
it('tokenizes malformed value', () => {
|
||||
const rawString = '<color=#FFC741FF>분기'
|
||||
|
||||
const result = tokenize(rawString)
|
||||
@@ -22,7 +22,7 @@ describe('tokenize', () => {
|
||||
}
|
||||
])
|
||||
})
|
||||
it('tokenize', () => {
|
||||
it('tokenizes nested tags', () => {
|
||||
const rawString =
|
||||
'기본 공격 또는 분기 공격이 적에게 연소 게이지를 <color=#FEDF4CFF><color=#23B2E3FF>4.0</color>pt 누적한다.</color> 발동 간격: <color=#23B2E3FF>6.0</color>초. 기본 공격과 분기 공격이 가하는 화염 원소 대미지가 <color=#23B2E3FF>30.0%</color> 증가한다.'
|
||||
|
||||
@@ -84,4 +84,26 @@ describe('tokenize', () => {
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('tokenizes size tag', () => {
|
||||
const rawString = '<size=14>Hello</size>'
|
||||
|
||||
const result = tokenize(rawString)
|
||||
|
||||
expect(result).toEqual([
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'size',
|
||||
attributes: {
|
||||
size: '14'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'Hello'
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -18,7 +18,7 @@ export function tokenize(value: string) {
|
||||
let currentValue = value.replace(/{{/g, '').replace(/}}/g, '')
|
||||
|
||||
while (currentValue.length > 0) {
|
||||
const openingBracketStartIndex = currentValue.indexOf('<color')
|
||||
const openingBracketStartIndex = currentValue.search(/<(color|size)/)
|
||||
if (openingBracketStartIndex < 0) {
|
||||
tokens.push({ type: 'text', text: currentValue })
|
||||
eat(openingBracketStartIndex)
|
||||
@@ -48,7 +48,7 @@ export function tokenize(value: string) {
|
||||
type: 'element',
|
||||
tagName,
|
||||
attributes: {
|
||||
color: attr
|
||||
[tagName]: attr
|
||||
},
|
||||
children
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ import { compileBattlesuitData } from './compileBattlesuitData'
|
||||
|
||||
describe('compileBattlesuitData', () => {
|
||||
it('converts tags', () => {
|
||||
const list = compileBattlesuitData()
|
||||
const list = compileBattlesuitData('en-US')
|
||||
|
||||
expect(list[0]).toMatchObject({
|
||||
id: expect.any(String),
|
||||
|
||||
@@ -12,9 +12,10 @@ import { getRawAvatarDataMap } from '../raw/avatarData'
|
||||
import { getRawAvatarSkillDataMap } from '../raw/avatarSkillData'
|
||||
import { getRawAvatarSubSkillDataMap } from '../raw/avatarSubSkillData'
|
||||
import { getRawAvatarTagUnLockDataMap } from '../raw/avatarTagUnLockData'
|
||||
import { convertWeaponType as convertWeaponType, convertTagType, getText } from './utils'
|
||||
import { convertWeaponType as convertWeaponType, convertTagType, createGetText } from './utils'
|
||||
|
||||
export function compileBattlesuitData(): Battlesuit[] {
|
||||
export function compileBattlesuitData(locale: string): Battlesuit[] {
|
||||
const getText = createGetText(locale)
|
||||
const rawAvatarDataMap = getRawAvatarDataMap()
|
||||
const rawSkillDataMap = getRawAvatarSkillDataMap()
|
||||
const rawSubSkillDataMap = getRawAvatarSubSkillDataMap()
|
||||
@@ -63,7 +64,7 @@ export function compileBattlesuitData(): Battlesuit[] {
|
||||
paramAdd1: rawSubSkillData.ParamAdd_1,
|
||||
paramAdd2: rawSubSkillData.ParamAdd_2,
|
||||
paramAdd3: rawSubSkillData.ParamAdd_3,
|
||||
tags: rawSubSkillData.TagList.map(convertRawSkillTag),
|
||||
tags: rawSubSkillData.TagList.map(tag => convertRawSkillTag(tag, locale)),
|
||||
toggle: rawSubSkillData.SkillToggle,
|
||||
unlockStar: convertStar(rawSubSkillData.UnlockStar, rawSubSkillData.UnlockSubStar)
|
||||
})
|
||||
@@ -78,7 +79,7 @@ export function compileBattlesuitData(): Battlesuit[] {
|
||||
info: getText(rawSkillData.Info),
|
||||
icon: skillIcon || '',
|
||||
skillType: convertShowOrderToSkillType(rawSkillData.ShowOrder),
|
||||
tags: rawSkillData.TagList.map(convertRawSkillTag),
|
||||
tags: rawSkillData.TagList.map(tag => convertRawSkillTag(tag, locale)),
|
||||
paramSubId1: rawSkillData.ParamSubID_1,
|
||||
paramSubId2: rawSkillData.ParamSubID_2,
|
||||
paramSubId3: rawSkillData.ParamSubID_3,
|
||||
@@ -246,7 +247,11 @@ function convertShowOrderToSkillType(rawShowOrder: number): SkillType {
|
||||
}
|
||||
}
|
||||
|
||||
function convertRawSkillTag(rawSkillTag: { Strength: number; TagID: number; TagComment: number }): SkillTagItem {
|
||||
function convertRawSkillTag(
|
||||
rawSkillTag: { Strength: number; TagID: number; TagComment: number },
|
||||
locale: string
|
||||
): SkillTagItem {
|
||||
const getText = createGetText(locale)
|
||||
const comment = getText(rawSkillTag.TagComment)
|
||||
return {
|
||||
type: convertRawStrengthToType(rawSkillTag.Strength),
|
||||
|
||||
@@ -2,11 +2,12 @@ import { ListMap } from '../../../utils'
|
||||
import { Elf, ElfSkill } from '../../data/types'
|
||||
import { getRawElfDataMap } from '../raw/elfData'
|
||||
import { getRawElfSkillDataMap } from '../raw/elfSkillData'
|
||||
import { convertTagType, getText } from './utils'
|
||||
import { convertTagType, createGetText } from './utils'
|
||||
|
||||
export function compileElfData() {
|
||||
export function compileElfData(locale: string) {
|
||||
const rawElfDataMap = getRawElfDataMap()
|
||||
const rawElfSkillDataMap = getRawElfSkillDataMap()
|
||||
const getText = createGetText(locale)
|
||||
|
||||
const rawElfSkillMap = Object.entries(rawElfSkillDataMap).reduce<ListMap<string, ElfSkill>>(
|
||||
(map, [id, rawSkillData]) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { compileGodWarData } from './compileGodWarData'
|
||||
|
||||
describe('compileGodWarData', () => {
|
||||
it('compiles main battlesuit abilities and signets', () => {
|
||||
const { mainAvatarList } = compileGodWarData()
|
||||
const { mainAvatarList } = compileGodWarData('en-US')
|
||||
|
||||
const targetItem = mainAvatarList[11]
|
||||
expect(targetItem).toMatchObject({
|
||||
@@ -26,7 +26,7 @@ describe('compileGodWarData', () => {
|
||||
})
|
||||
|
||||
it('compiles buff list per suit', () => {
|
||||
const { buffSuitBuffListMap } = compileGodWarData()
|
||||
const { buffSuitBuffListMap } = compileGodWarData('en-US')
|
||||
|
||||
const targetItem = buffSuitBuffListMap.get('3')
|
||||
|
||||
|
||||
@@ -4,14 +4,15 @@ import { getRawGodWarBuffMap } from '../raw/godWarBuff'
|
||||
import { getRawGodWarExtraItemMap } from '../raw/godWarExxtraItem'
|
||||
import { getRawGodWarMainAvatarMap } from '../raw/godWarMainAvatar'
|
||||
import { getRawGodWarSupportAvatarMap } from '../raw/godWarSupportAvatar'
|
||||
import { getText } from './utils'
|
||||
import { createGetText } from './utils'
|
||||
|
||||
export function compileGodWarData() {
|
||||
export function compileGodWarData(locale: string) {
|
||||
const rawMainAvatarMap = getRawGodWarMainAvatarMap()['1']
|
||||
const rawGodWarAvatarAbilityMap = getRawGodWarAvatarAbilityMap()
|
||||
const rawGodWarBuffMap = getRawGodWarBuffMap()
|
||||
const rawGodWarSupportAvatarMap = getRawGodWarSupportAvatarMap()['1']
|
||||
const rawGodWarExtraItemMap = getRawGodWarExtraItemMap()
|
||||
const getText = createGetText(locale)
|
||||
|
||||
const battlesuitIdRawBuffListMap = new Map<string, ErSignet[]>()
|
||||
const buffSuitBuffListMap = new Map<string, ErSignet[]>()
|
||||
|
||||
@@ -2,14 +2,15 @@ import { EquipmentSkill, RootStigma, StigmataSet, StigmaType } from '../../data/
|
||||
import { getRawEquipmentSetDataMap } from '../raw/equipmentSetData'
|
||||
import { getRawEquipmentSkillDataMap } from '../raw/equipmentSkillData'
|
||||
import { getRawStigmataDataMap } from '../raw/stigmataData'
|
||||
import { convertEquipmentSkill, getText } from './utils'
|
||||
import { convertEquipmentSkill, createGetText } from './utils'
|
||||
|
||||
export function compileStigmataData() {
|
||||
export function compileStigmataData(locale: string) {
|
||||
const rawStigmataDataMap = getRawStigmataDataMap()
|
||||
const rawStigmataDataMapEntries = Object.entries(rawStigmataDataMap)
|
||||
const rawEquipmentSkillDataMap = getRawEquipmentSkillDataMap()
|
||||
const rawEquipmentSetDataMap = getRawEquipmentSetDataMap()
|
||||
const stigmaSetIdMainIdListMap = new Map<string, string[]>()
|
||||
const getText = createGetText(locale)
|
||||
|
||||
const stigmataMainIdStigmataMap = rawStigmataDataMapEntries.reduce((map, [id, rawData]) => {
|
||||
// Bronya calorie has a dummy data
|
||||
@@ -46,7 +47,7 @@ export function compileStigmataData() {
|
||||
const rawSkill = rawEquipmentSkillDataMap[skillId]
|
||||
skills.push({
|
||||
id: skillId,
|
||||
...convertEquipmentSkill(rawSkill),
|
||||
...convertEquipmentSkill(rawSkill, locale),
|
||||
param1: rawData.Prop1Param1,
|
||||
param1Add: rawData.Prop1Param1Add,
|
||||
param2: rawData.Prop1Param2,
|
||||
@@ -60,7 +61,7 @@ export function compileStigmataData() {
|
||||
const rawSkill = rawEquipmentSkillDataMap[skillId]
|
||||
skills.push({
|
||||
id: skillId,
|
||||
...convertEquipmentSkill(rawSkill),
|
||||
...convertEquipmentSkill(rawSkill, locale),
|
||||
param1: rawData.Prop2Param1,
|
||||
param1Add: rawData.Prop2Param1Add,
|
||||
param2: rawData.Prop2Param2,
|
||||
@@ -74,7 +75,7 @@ export function compileStigmataData() {
|
||||
const rawSkill = rawEquipmentSkillDataMap[skillId]
|
||||
skills.push({
|
||||
id: skillId,
|
||||
...convertEquipmentSkill(rawSkill),
|
||||
...convertEquipmentSkill(rawSkill, locale),
|
||||
param1: rawData.Prop3Param1,
|
||||
param1Add: rawData.Prop3Param1Add,
|
||||
param2: rawData.Prop3Param2,
|
||||
@@ -126,7 +127,7 @@ export function compileStigmataData() {
|
||||
const rawSkill = rawEquipmentSkillDataMap[skillId]
|
||||
skills.push({
|
||||
id: skillId,
|
||||
...convertEquipmentSkill(rawSkill),
|
||||
...convertEquipmentSkill(rawSkill, locale),
|
||||
param1: rawData.Prop1Param1,
|
||||
param1Add: rawData.Prop1Param1Add,
|
||||
param2: rawData.Prop1Param2,
|
||||
@@ -140,7 +141,7 @@ export function compileStigmataData() {
|
||||
const rawSkill = rawEquipmentSkillDataMap[skillId]
|
||||
skills.push({
|
||||
id: skillId,
|
||||
...convertEquipmentSkill(rawSkill),
|
||||
...convertEquipmentSkill(rawSkill, locale),
|
||||
param1: rawData.Prop2Param1,
|
||||
param1Add: rawData.Prop2Param1Add,
|
||||
param2: rawData.Prop2Param2,
|
||||
@@ -154,7 +155,7 @@ export function compileStigmataData() {
|
||||
const rawSkill = rawEquipmentSkillDataMap[skillId]
|
||||
skills.push({
|
||||
id: skillId,
|
||||
...convertEquipmentSkill(rawSkill),
|
||||
...convertEquipmentSkill(rawSkill, locale),
|
||||
param1: rawData.Prop3Param1,
|
||||
param1Add: rawData.Prop3Param1Add,
|
||||
param2: rawData.Prop3Param2,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { compileWeaponData } from './compileWeaponData'
|
||||
|
||||
describe('compileWeaponData', () => {
|
||||
it('compiles', () => {
|
||||
const list = compileWeaponData()
|
||||
const list = compileWeaponData('en-US')
|
||||
|
||||
const targetItem = list.find(weapon => weapon.id === '10277')
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { RootWeaponData, WeaponData } from '../../data/types'
|
||||
import { getRawEquipmentSkillDataMap } from '../raw/equipmentSkillData'
|
||||
import { getRawWeaponDataMap } from '../raw/weaponData'
|
||||
import { convertEquipmentSkill, convertWeaponType, getText } from './utils'
|
||||
import { convertEquipmentSkill, convertWeaponType, createGetText } from './utils'
|
||||
|
||||
export function compileWeaponData(): RootWeaponData[] {
|
||||
export function compileWeaponData(locale: string): RootWeaponData[] {
|
||||
const rawWeaponDataMap = getRawWeaponDataMap()
|
||||
const rawEquipmentSkillDataMap = getRawEquipmentSkillDataMap()
|
||||
const getText = createGetText(locale)
|
||||
|
||||
const rawWeaponMainIdWeaponDataMap = Object.entries(rawWeaponDataMap).reduce((map, [id, rawData]) => {
|
||||
const rawWeaponMainId = rawData.WeaponMainID.toString()
|
||||
@@ -21,7 +22,7 @@ export function compileWeaponData(): RootWeaponData[] {
|
||||
const rawSkill = rawEquipmentSkillDataMap[skillId]
|
||||
skills.push({
|
||||
id: skillId,
|
||||
...convertEquipmentSkill(rawSkill),
|
||||
...convertEquipmentSkill(rawSkill, locale),
|
||||
param1: rawData.Prop1Param1,
|
||||
param1Add: rawData.Prop1Param1Add,
|
||||
param2: rawData.Prop1Param2,
|
||||
@@ -35,7 +36,7 @@ export function compileWeaponData(): RootWeaponData[] {
|
||||
const rawSkill = rawEquipmentSkillDataMap[skillId]
|
||||
skills.push({
|
||||
id: skillId,
|
||||
...convertEquipmentSkill(rawSkill),
|
||||
...convertEquipmentSkill(rawSkill, locale),
|
||||
param1: rawData.Prop2Param1,
|
||||
param1Add: rawData.Prop2Param1Add,
|
||||
param2: rawData.Prop2Param2,
|
||||
@@ -49,7 +50,7 @@ export function compileWeaponData(): RootWeaponData[] {
|
||||
const rawSkill = rawEquipmentSkillDataMap[skillId]
|
||||
skills.push({
|
||||
id: skillId,
|
||||
...convertEquipmentSkill(rawSkill),
|
||||
...convertEquipmentSkill(rawSkill, locale),
|
||||
param1: rawData.Prop3Param1,
|
||||
param1Add: rawData.Prop3Param1Add,
|
||||
param2: rawData.Prop3Param2,
|
||||
|
||||
@@ -2,9 +2,11 @@ import { TagType, WeaponType } from '../../data/types'
|
||||
import { RawEquipmentSkillData } from '../raw/equipmentSkillData'
|
||||
import { getRawTextMap } from '../raw/textMap'
|
||||
|
||||
export function getText(id: string | number) {
|
||||
const rawTextMap = getRawTextMap()
|
||||
export function createGetText(locale?: string) {
|
||||
return function getText(id: string | number) {
|
||||
const rawTextMap = getRawTextMap(locale)
|
||||
return rawTextMap[id]?.Text || null
|
||||
}
|
||||
}
|
||||
|
||||
export function convertWeaponType(rawValue: number): WeaponType {
|
||||
@@ -93,7 +95,8 @@ export function convertTagType(rawTagId: number): TagType {
|
||||
throw new Error(`Unsupported raw show order(Skill) (${rawTagId})`)
|
||||
}
|
||||
|
||||
export function convertEquipmentSkill(rawSkill: RawEquipmentSkillData) {
|
||||
export function convertEquipmentSkill(rawSkill: RawEquipmentSkillData, locale: string) {
|
||||
const getText = createGetText(locale)
|
||||
const iconName = rawSkill.SkillIconPath.split('/').pop()
|
||||
return {
|
||||
name: getText(rawSkill.SkillName),
|
||||
|
||||
@@ -17,93 +17,129 @@ import {
|
||||
WeaponCatalogItem
|
||||
} from '../data/types'
|
||||
|
||||
export const dataDir = path.join(process.cwd(), 'data/v2')
|
||||
|
||||
export const battlesuitsDir = path.join(dataDir, 'battlesuits')
|
||||
export const battlesuitCatalogPath = path.join(dataDir, 'battlesuit-catalog.yaml')
|
||||
|
||||
export const weaponsDir = path.join(dataDir, 'weapons')
|
||||
export const weaopnCatalogPath = path.join(dataDir, 'weapon-catalog.yaml')
|
||||
|
||||
export const stigmataDir = path.join(dataDir, 'stigmata')
|
||||
export const stigmataCatalogPath = path.join(dataDir, 'stigmata-catalog.yaml')
|
||||
|
||||
export const stigmataSetsDir = path.join(dataDir, 'stigmata-sets')
|
||||
export const stigmataSetCatalogPath = path.join(dataDir, 'stigmata-set-catalog.yaml')
|
||||
|
||||
export const erBattlesuitCatalogPath = path.join(dataDir, 'er-battlesuits-catalog.yaml')
|
||||
export const erBattlesuitsDir = path.join(dataDir, 'er-battlesuits')
|
||||
export const erSignetsDir = path.join(dataDir, 'er-signets')
|
||||
export const erSupportsPath = path.join(dataDir, 'er-supports.yaml')
|
||||
export const erSigilsPath = path.join(dataDir, 'er-sigils.yaml')
|
||||
|
||||
export const elfsDir = path.join(dataDir, 'elfs')
|
||||
export const elfCatalogPath = path.join(dataDir, 'elf-catalog.yaml')
|
||||
|
||||
export function loadBattlesuitCatalog(): BattlesuitCatalogItem[] {
|
||||
return readYamlFile(battlesuitCatalogPath)
|
||||
// export const dataDir = path.join(process.cwd(), 'data/ko-KR')
|
||||
export function getDataDir(locale?: string) {
|
||||
if (locale == null) {
|
||||
return path.join(process.cwd(), 'data', 'en-US')
|
||||
}
|
||||
return path.join(process.cwd(), 'data', locale)
|
||||
}
|
||||
|
||||
export function loadBattlesuitData(id: string) {
|
||||
const battlesuitDataPath = path.join(battlesuitsDir, `${id}.yaml`)
|
||||
export function getBattlesuitsDir(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'battlesuits')
|
||||
}
|
||||
export function getBattlesuitCatalogPath(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'battlesuit-catalog.yaml')
|
||||
}
|
||||
|
||||
export function getWeaponsDir(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'weapons')
|
||||
}
|
||||
export function getWeaopnCatalogPath(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'weapon-catalog.yaml')
|
||||
}
|
||||
|
||||
export function getStigmataDir(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'stigmata')
|
||||
}
|
||||
export function getStigmataCatalogPath(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'stigmata-catalog.yaml')
|
||||
}
|
||||
|
||||
export function getStigmataSetsDir(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'stigmata-sets')
|
||||
}
|
||||
export function getStigmataSetCatalogPath(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'stigmata-set-catalog.yaml')
|
||||
}
|
||||
|
||||
export function getErBattlesuitCatalogPath(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'er-battlesuits-catalog.yaml')
|
||||
}
|
||||
export function getErBattlesuitsDir(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'er-battlesuits')
|
||||
}
|
||||
export function getErSignetsDir(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'er-signets')
|
||||
}
|
||||
export function getErSupportsPath(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'er-supports.yaml')
|
||||
}
|
||||
export function getErSigilsPath(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'er-sigils.yaml')
|
||||
}
|
||||
|
||||
export function getElfsDir(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'elfs')
|
||||
}
|
||||
export function getElfCatalogPath(locale?: string) {
|
||||
return path.join(getDataDir(locale), 'elf-catalog.yaml')
|
||||
}
|
||||
|
||||
export function loadBattlesuitCatalog(locale?: string): BattlesuitCatalogItem[] {
|
||||
return readYamlFile(getBattlesuitCatalogPath(locale))
|
||||
}
|
||||
|
||||
export function loadBattlesuitData(id: string, locale?: string) {
|
||||
const battlesuitDataPath = path.join(getBattlesuitsDir(locale), `${id}.yaml`)
|
||||
return readYamlFile(battlesuitDataPath)
|
||||
}
|
||||
|
||||
export function loadWeaponCatalog(): WeaponCatalogItem[] {
|
||||
return readYamlFile(weaopnCatalogPath)
|
||||
export function loadWeaponCatalog(locale?: string): WeaponCatalogItem[] {
|
||||
return readYamlFile(getWeaopnCatalogPath(locale))
|
||||
}
|
||||
|
||||
export function loadWeaponData(id: string) {
|
||||
const weaponDataPath = path.join(weaponsDir, `${id}.yaml`)
|
||||
export function loadWeaponData(id: string, locale?: string) {
|
||||
const weaponDataPath = path.join(getWeaponsDir(locale), `${id}.yaml`)
|
||||
return readYamlFile(weaponDataPath)
|
||||
}
|
||||
|
||||
export function loadStigmataCatalog(): StigmataCatalogItem[] {
|
||||
return readYamlFile(stigmataCatalogPath)
|
||||
export function loadStigmataCatalog(locale?: string): StigmataCatalogItem[] {
|
||||
return readYamlFile(getStigmataCatalogPath(locale))
|
||||
}
|
||||
|
||||
export function loadStigmaData(id: string): RootStigma {
|
||||
const stigmaDataPath = path.join(stigmataDir, `${id}.yaml`)
|
||||
export function loadStigmaData(id: string, locale?: string): RootStigma {
|
||||
const stigmaDataPath = path.join(getStigmataDir(locale), `${id}.yaml`)
|
||||
return readYamlFile(stigmaDataPath)
|
||||
}
|
||||
|
||||
export function loadStigmataSetCatalog(): StigmataSetCatalogItem[] {
|
||||
return readYamlFile(stigmataSetCatalogPath)
|
||||
export function loadStigmataSetCatalog(locale?: string): StigmataSetCatalogItem[] {
|
||||
return readYamlFile(getStigmataSetCatalogPath(locale))
|
||||
}
|
||||
|
||||
export function loadStigmataSetData(id: string): StigmataSet {
|
||||
const stigmataSetPath = path.join(stigmataSetsDir, `${id}.yaml`)
|
||||
export function loadStigmataSetData(id: string, locale?: string): StigmataSet {
|
||||
const stigmataSetPath = path.join(getStigmataSetsDir(locale), `${id}.yaml`)
|
||||
return readYamlFile(stigmataSetPath)
|
||||
}
|
||||
|
||||
export function loadErBattlesuitCatalog(): ErBattlesuitCatalogItem[] {
|
||||
return readYamlFile(erBattlesuitCatalogPath)
|
||||
export function loadErBattlesuitCatalog(locale?: string): ErBattlesuitCatalogItem[] {
|
||||
return readYamlFile(getErBattlesuitCatalogPath(locale))
|
||||
}
|
||||
|
||||
export function loadErBattlesuit(id: string): ErBattlesuit {
|
||||
const erBattlesuitPath = path.join(erBattlesuitsDir, `${id}.yaml`)
|
||||
export function loadErBattlesuit(id: string, locale?: string): ErBattlesuit {
|
||||
const erBattlesuitPath = path.join(getErBattlesuitsDir(locale), `${id}.yaml`)
|
||||
return readYamlFile(erBattlesuitPath)
|
||||
}
|
||||
|
||||
export function loadErSignets(id: string): ErSignet[] {
|
||||
const erSignetsPath = path.join(erSignetsDir, `${id}.yaml`)
|
||||
export function loadErSignets(id: string, locale?: string): ErSignet[] {
|
||||
const erSignetsPath = path.join(getErSignetsDir(locale), `${id}.yaml`)
|
||||
return readYamlFile(erSignetsPath)
|
||||
}
|
||||
|
||||
export function loadErSupports(): ErSupportBattlesuit[] {
|
||||
return readYamlFile(erSupportsPath)
|
||||
export function loadErSupports(locale?: string): ErSupportBattlesuit[] {
|
||||
return readYamlFile(getErSupportsPath(locale))
|
||||
}
|
||||
|
||||
export function loadErSigils(): ErSigil[] {
|
||||
return readYamlFile(erSigilsPath)
|
||||
export function loadErSigils(locale?: string): ErSigil[] {
|
||||
return readYamlFile(getErSigilsPath(locale))
|
||||
}
|
||||
|
||||
export function loadElfCatalog(): ElfCatalogItem[] {
|
||||
return readYamlFile(elfCatalogPath)
|
||||
export function loadElfCatalog(locale?: string): ElfCatalogItem[] {
|
||||
return readYamlFile(getElfCatalogPath(locale))
|
||||
}
|
||||
|
||||
export function loadElfData(id: string): Elf {
|
||||
const elfDataPath = path.join(elfsDir, `${id}.yaml`)
|
||||
export function loadElfData(id: string, locale?: string): Elf {
|
||||
const elfDataPath = path.join(getElfsDir(locale), `${id}.yaml`)
|
||||
return readYamlFile(elfDataPath)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { loadRawData } from './loadRawData'
|
||||
|
||||
export function getRawTextMap(): RawTextMap {
|
||||
export function getRawTextMap(locale?: string): RawTextMap {
|
||||
if (locale === 'en-US') {
|
||||
return loadRawData('TextMap_en.json')
|
||||
}
|
||||
return loadRawData('TextMap.json')
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ const BattlesuitShowPage = ({ battlesuit }: BattlesuitShowPageProps) => {
|
||||
export default BattlesuitShowPage
|
||||
|
||||
export async function getStaticProps({ locale, params }: NextPageContext & { params: { battlesuitId: string } }) {
|
||||
const battlesuit = loadBattlesuitData(params.battlesuitId)
|
||||
const battlesuit = loadBattlesuitData(params.battlesuitId, locale)
|
||||
|
||||
return {
|
||||
props: { battlesuit, ...(await getI18NProps(locale)) }
|
||||
|
||||
@@ -11,6 +11,7 @@ import Head from '../../../../components/atoms/Head'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import Breadcrumb from '../../../../components/organisms/Breadcrumb'
|
||||
import { generateI18NPaths, getI18NProps } from '../../../../server/i18n'
|
||||
import FormattedText from '../../../../components/v2/FormattedText'
|
||||
|
||||
interface BattlesuitShowPageProps {
|
||||
battlesuit: Battlesuit
|
||||
@@ -90,7 +91,7 @@ const BattlesuitShowPage = ({ battlesuit, erBattlesuit }: BattlesuitShowPageProp
|
||||
</Heading>
|
||||
</Box>
|
||||
<Box sx={{ p: 1, borderBottom: 'default', '&:last-child': { borderBottom: 'none' } }}>
|
||||
{ability.desc}
|
||||
<FormattedText>{ability.desc}</FormattedText>
|
||||
</Box>
|
||||
</Fragment>
|
||||
)
|
||||
@@ -117,7 +118,7 @@ const BattlesuitShowPage = ({ battlesuit, erBattlesuit }: BattlesuitShowPageProp
|
||||
</Heading>
|
||||
</Flex>
|
||||
<Box sx={{ p: 1, borderBottom: 'default', '&:last-child': { borderBottom: 'none' } }}>
|
||||
{signet.desc}
|
||||
<FormattedText>{signet.desc}</FormattedText>
|
||||
</Box>
|
||||
</Fragment>
|
||||
)
|
||||
|
||||
@@ -3,24 +3,6 @@ import { createDirIfNotExist } from '../lib/v2/server/fsUtils'
|
||||
import fs from 'fs'
|
||||
import YAML from 'yaml'
|
||||
import { runScript } from './lib/utils'
|
||||
import {
|
||||
battlesuitCatalogPath,
|
||||
battlesuitsDir,
|
||||
dataDir,
|
||||
elfCatalogPath,
|
||||
elfsDir,
|
||||
erBattlesuitCatalogPath,
|
||||
erBattlesuitsDir,
|
||||
erSigilsPath,
|
||||
erSignetsDir,
|
||||
erSupportsPath,
|
||||
stigmataCatalogPath,
|
||||
stigmataDir,
|
||||
stigmataSetCatalogPath,
|
||||
stigmataSetsDir,
|
||||
weaopnCatalogPath,
|
||||
weaponsDir
|
||||
} from '../lib/v2/server/loadData'
|
||||
import {
|
||||
BattlesuitCatalogItem,
|
||||
ElfCatalogItem,
|
||||
@@ -33,18 +15,41 @@ import { compileWeaponData } from '../lib/v2/server/compileData/compileWeaponDat
|
||||
import { compileStigmataData } from '../lib/v2/server/compileData/compileStigmataData'
|
||||
import { compileGodWarData } from '../lib/v2/server/compileData/compileGodWarData'
|
||||
import { compileElfData } from '../lib/v2/server/compileData/compileElfData'
|
||||
import {
|
||||
getBattlesuitCatalogPath,
|
||||
getBattlesuitsDir,
|
||||
getDataDir,
|
||||
getElfCatalogPath,
|
||||
getElfsDir,
|
||||
getErBattlesuitCatalogPath,
|
||||
getErBattlesuitsDir,
|
||||
getErSigilsPath,
|
||||
getErSignetsDir,
|
||||
getErSupportsPath,
|
||||
getStigmataCatalogPath,
|
||||
getStigmataDir,
|
||||
getStigmataSetCatalogPath,
|
||||
getStigmataSetsDir,
|
||||
getWeaopnCatalogPath,
|
||||
getWeaponsDir
|
||||
} from '../lib/v2/server/loadData'
|
||||
|
||||
runScript(async () => {
|
||||
createDirIfNotExist(dataDir)
|
||||
writeBattlesuitData()
|
||||
writeWeaponData()
|
||||
writeStigmataData()
|
||||
writeErData()
|
||||
writeElfData()
|
||||
writeDataFiles('ko-KR')
|
||||
writeDataFiles('en-US')
|
||||
})
|
||||
|
||||
function writeBattlesuitData() {
|
||||
const battlesuitList = compileBattlesuitData()
|
||||
function writeDataFiles(locale: string) {
|
||||
createDirIfNotExist(getDataDir(locale))
|
||||
writeBattlesuitData(locale)
|
||||
writeWeaponData(locale)
|
||||
writeStigmataData(locale)
|
||||
writeErData(locale)
|
||||
writeElfData(locale)
|
||||
}
|
||||
|
||||
function writeBattlesuitData(locale: string) {
|
||||
const battlesuitList = compileBattlesuitData(locale)
|
||||
|
||||
const catalogList: BattlesuitCatalogItem[] = battlesuitList.map(battlesuit => {
|
||||
return {
|
||||
@@ -57,18 +62,18 @@ function writeBattlesuitData() {
|
||||
}
|
||||
})
|
||||
|
||||
fs.writeFileSync(battlesuitCatalogPath, YAML.stringify(catalogList))
|
||||
fs.writeFileSync(getBattlesuitCatalogPath(locale), YAML.stringify(catalogList))
|
||||
|
||||
createDirIfNotExist(battlesuitsDir)
|
||||
createDirIfNotExist(getBattlesuitsDir(locale))
|
||||
|
||||
for (const battlesuit of battlesuitList) {
|
||||
const battlesuitDataPath = path.join(battlesuitsDir, `${battlesuit.id}.yaml`)
|
||||
const battlesuitDataPath = path.join(getBattlesuitsDir(locale), `${battlesuit.id}.yaml`)
|
||||
fs.writeFileSync(battlesuitDataPath, YAML.stringify(battlesuit))
|
||||
}
|
||||
}
|
||||
|
||||
function writeWeaponData() {
|
||||
const weaponDataList = compileWeaponData()
|
||||
function writeWeaponData(locale: string) {
|
||||
const weaponDataList = compileWeaponData(locale)
|
||||
|
||||
const catalogList: WeaponCatalogItem[] = weaponDataList.map(rootWeapon => {
|
||||
const maxedWeapon = rootWeapon.weapons[rootWeapon.weapons.length - 1]
|
||||
@@ -81,18 +86,18 @@ function writeWeaponData() {
|
||||
}
|
||||
})
|
||||
|
||||
fs.writeFileSync(weaopnCatalogPath, YAML.stringify(catalogList))
|
||||
fs.writeFileSync(getWeaopnCatalogPath(locale), YAML.stringify(catalogList))
|
||||
|
||||
createDirIfNotExist(weaponsDir)
|
||||
createDirIfNotExist(getWeaponsDir(locale))
|
||||
|
||||
for (const weaponData of weaponDataList) {
|
||||
const weaponDataPath = path.join(weaponsDir, `${weaponData.id}.yaml`)
|
||||
const weaponDataPath = path.join(getWeaponsDir(locale), `${weaponData.id}.yaml`)
|
||||
fs.writeFileSync(weaponDataPath, YAML.stringify(weaponData))
|
||||
}
|
||||
}
|
||||
|
||||
function writeStigmataData() {
|
||||
const { stigmataSetList, stigmataMainIdStigmataMap } = compileStigmataData()
|
||||
function writeStigmataData(locale: string) {
|
||||
const { stigmataSetList, stigmataMainIdStigmataMap } = compileStigmataData(locale)
|
||||
const stigmataList = [...stigmataMainIdStigmataMap.values()]
|
||||
|
||||
const catalogList: StigmataCatalogItem[] = stigmataList.map(rootStigma => {
|
||||
@@ -105,11 +110,11 @@ function writeStigmataData() {
|
||||
maxRarity: maxedStigma.maxRarity
|
||||
}
|
||||
})
|
||||
fs.writeFileSync(stigmataCatalogPath, YAML.stringify(catalogList))
|
||||
fs.writeFileSync(getStigmataCatalogPath(locale), YAML.stringify(catalogList))
|
||||
|
||||
createDirIfNotExist(stigmataDir)
|
||||
createDirIfNotExist(getStigmataDir(locale))
|
||||
for (const stigmataData of stigmataList) {
|
||||
const stigmaDataPath = path.join(stigmataDir, `${stigmataData.id}.yaml`)
|
||||
const stigmaDataPath = path.join(getStigmataDir(locale), `${stigmataData.id}.yaml`)
|
||||
fs.writeFileSync(stigmaDataPath, YAML.stringify(stigmataData))
|
||||
}
|
||||
|
||||
@@ -130,8 +135,9 @@ function writeStigmataData() {
|
||||
}
|
||||
})
|
||||
|
||||
fs.writeFileSync(stigmataSetCatalogPath, YAML.stringify(setCatalogList))
|
||||
fs.writeFileSync(getStigmataSetCatalogPath(locale), YAML.stringify(setCatalogList))
|
||||
|
||||
const stigmataSetsDir = getStigmataSetsDir(locale)
|
||||
createDirIfNotExist(stigmataSetsDir)
|
||||
for (const stigmataSet of stigmataSetList) {
|
||||
const stigmaSetDataPath = path.join(stigmataSetsDir, `${stigmataSet.id}.yaml`)
|
||||
@@ -139,33 +145,35 @@ function writeStigmataData() {
|
||||
}
|
||||
}
|
||||
|
||||
function writeErData() {
|
||||
const { buffSuitBuffListMap, mainAvatarList, supportAvatarList, sigilList } = compileGodWarData()
|
||||
function writeErData(locale: string) {
|
||||
const { buffSuitBuffListMap, mainAvatarList, supportAvatarList, sigilList } = compileGodWarData(locale)
|
||||
|
||||
const erBattlesuitCatalog = mainAvatarList.map(mainAvatar => {
|
||||
return { battlesuit: mainAvatar.battlesuit }
|
||||
})
|
||||
|
||||
fs.writeFileSync(erBattlesuitCatalogPath, YAML.stringify(erBattlesuitCatalog))
|
||||
fs.writeFileSync(getErBattlesuitCatalogPath(locale), YAML.stringify(erBattlesuitCatalog))
|
||||
|
||||
const erBattlesuitsDir = getErBattlesuitsDir(locale)
|
||||
createDirIfNotExist(erBattlesuitsDir)
|
||||
for (const erBattlesuit of mainAvatarList) {
|
||||
const erBattlesuitPath = path.join(erBattlesuitsDir, `${erBattlesuit.battlesuit}.yaml`)
|
||||
fs.writeFileSync(erBattlesuitPath, YAML.stringify(erBattlesuit))
|
||||
}
|
||||
|
||||
const erSignetsDir = getErSignetsDir(locale)
|
||||
createDirIfNotExist(erSignetsDir)
|
||||
for (const [buffSuit, list] of buffSuitBuffListMap) {
|
||||
const erSignetsPath = path.join(erSignetsDir, `${buffSuit}.yaml`)
|
||||
fs.writeFileSync(erSignetsPath, YAML.stringify(list))
|
||||
}
|
||||
|
||||
fs.writeFileSync(erSupportsPath, YAML.stringify(supportAvatarList))
|
||||
fs.writeFileSync(erSigilsPath, YAML.stringify(sigilList))
|
||||
fs.writeFileSync(getErSupportsPath(locale), YAML.stringify(supportAvatarList))
|
||||
fs.writeFileSync(getErSigilsPath(locale), YAML.stringify(sigilList))
|
||||
}
|
||||
|
||||
function writeElfData() {
|
||||
const elfs = compileElfData()
|
||||
function writeElfData(locale: string) {
|
||||
const elfs = compileElfData(locale)
|
||||
|
||||
const elfCatalogList = elfs.map<ElfCatalogItem>(elf => {
|
||||
return {
|
||||
@@ -178,8 +186,9 @@ function writeElfData() {
|
||||
}
|
||||
})
|
||||
|
||||
fs.writeFileSync(elfCatalogPath, YAML.stringify(elfCatalogList))
|
||||
fs.writeFileSync(getElfCatalogPath(locale), YAML.stringify(elfCatalogList))
|
||||
|
||||
const elfsDir = getElfsDir(locale)
|
||||
createDirIfNotExist(elfsDir)
|
||||
for (const elf of elfs) {
|
||||
const elfDataPath = path.join(elfsDir, `${elf.id}.yaml`)
|
||||
|
||||
Reference in New Issue
Block a user