Add groupWeaponKeys and weaponKeyGroups
This commit is contained in:
parent
da07db0a83
commit
a50804a33b
2 changed files with 86 additions and 0 deletions
34
utils/groupWeaponKeys.tsx
Normal file
34
utils/groupWeaponKeys.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { weaponKeyGroups } from './weaponKeyGroups'
|
||||
|
||||
export type GroupedWeaponKeys = {
|
||||
[key: string]: WeaponKey[]
|
||||
pendulum: WeaponKey[]
|
||||
chain: WeaponKey[]
|
||||
teluma: WeaponKey[]
|
||||
gauph: WeaponKey[]
|
||||
emblem: WeaponKey[]
|
||||
}
|
||||
|
||||
export function groupWeaponKeys(keys: WeaponKey[]) {
|
||||
console.log(keys)
|
||||
const numGroups = Math.max.apply(
|
||||
Math,
|
||||
keys.map((key) => key.group)
|
||||
)
|
||||
|
||||
let groupedKeys: GroupedWeaponKeys = {
|
||||
pendulum: [],
|
||||
chain: [],
|
||||
teluma: [],
|
||||
gauph: [],
|
||||
emblem: [],
|
||||
}
|
||||
|
||||
for (let i = 0; i <= numGroups; i++) {
|
||||
groupedKeys[weaponKeyGroups[i].slug] = keys.filter((key) => key.group == i)
|
||||
}
|
||||
|
||||
console.log(groupedKeys)
|
||||
|
||||
return groupedKeys
|
||||
}
|
||||
52
utils/weaponKeyGroups.tsx
Normal file
52
utils/weaponKeyGroups.tsx
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
interface WeaponKeyGroup {
|
||||
id: number
|
||||
slug: string
|
||||
name: {
|
||||
[key: string]: string
|
||||
en: string
|
||||
ja: string
|
||||
}
|
||||
}
|
||||
|
||||
export const weaponKeyGroups: WeaponKeyGroup[] = [
|
||||
{
|
||||
id: 0,
|
||||
slug: 'pendulum',
|
||||
name: {
|
||||
en: 'Pendulum',
|
||||
ja: 'ペンデュラム',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
slug: 'chain',
|
||||
name: {
|
||||
en: 'Chain',
|
||||
ja: 'チェイン',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
slug: 'teluma',
|
||||
name: {
|
||||
en: 'Teluma',
|
||||
ja: 'テルマ',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
slug: 'gauph',
|
||||
name: {
|
||||
en: 'Gauph Key',
|
||||
ja: 'ガフスキー',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
slug: 'emblem',
|
||||
name: {
|
||||
en: 'Emblem',
|
||||
ja: 'エンブレム',
|
||||
},
|
||||
},
|
||||
]
|
||||
Loading…
Reference in a new issue