add promotions to weapon database views
This commit is contained in:
parent
cf694bb1ce
commit
8c45c21939
2 changed files with 34 additions and 7 deletions
|
|
@ -7,6 +7,7 @@ export const WeaponEditSchema = z.object({
|
||||||
element: z.number().int().min(0),
|
element: z.number().int().min(0),
|
||||||
proficiency1: z.number().int().min(0).optional().default(0),
|
proficiency1: z.number().int().min(0).optional().default(0),
|
||||||
proficiency2: z.number().int().min(0).optional().default(0),
|
proficiency2: z.number().int().min(0).optional().default(0),
|
||||||
|
promotions: z.array(z.number().int().min(1)),
|
||||||
min_hp: z.number().int().min(0),
|
min_hp: z.number().int().min(0),
|
||||||
max_hp: z.number().int().min(0),
|
max_hp: z.number().int().min(0),
|
||||||
max_hp_flb: z.number().int().min(0),
|
max_hp_flb: z.number().int().min(0),
|
||||||
|
|
@ -23,17 +24,19 @@ export type WeaponEdit = z.infer<typeof WeaponEditSchema>
|
||||||
export function toEditData(model: any): WeaponEdit {
|
export function toEditData(model: any): WeaponEdit {
|
||||||
return {
|
return {
|
||||||
name: model?.name ?? '',
|
name: model?.name ?? '',
|
||||||
granblue_id: model?.granblue_id ?? '',
|
granblue_id: model?.granblueId ?? model?.granblue_id ?? '',
|
||||||
rarity: model?.rarity ?? 1,
|
rarity: model?.rarity ?? 1,
|
||||||
element: model?.element ?? 0,
|
element: model?.element ?? 0,
|
||||||
proficiency1: Array.isArray(model?.proficiency) ? (model.proficiency[0] ?? 0) : (model?.proficiency ?? 0),
|
proficiency1: Array.isArray(model?.proficiency) ? (model.proficiency[0] ?? 0) : (model?.proficiency ?? 0),
|
||||||
proficiency2: Array.isArray(model?.proficiency) ? (model.proficiency[1] ?? 0) : 0,
|
proficiency2: Array.isArray(model?.proficiency) ? (model.proficiency[1] ?? 0) : 0,
|
||||||
min_hp: model?.hp?.min_hp ?? 0,
|
promotions: model?.promotions ?? [],
|
||||||
max_hp: model?.hp?.max_hp ?? 0,
|
// API returns camelCase after transformation
|
||||||
max_hp_flb: model?.hp?.max_hp_flb ?? 0,
|
min_hp: model?.hp?.minHp ?? model?.hp?.min_hp ?? 0,
|
||||||
min_atk: model?.atk?.min_atk ?? 0,
|
max_hp: model?.hp?.maxHp ?? model?.hp?.max_hp ?? 0,
|
||||||
max_atk: model?.atk?.max_atk ?? 0,
|
max_hp_flb: model?.hp?.maxHpFlb ?? model?.hp?.max_hp_flb ?? 0,
|
||||||
max_atk_flb: model?.atk?.max_atk_flb ?? 0,
|
min_atk: model?.atk?.minAtk ?? model?.atk?.min_atk ?? 0,
|
||||||
|
max_atk: model?.atk?.maxAtk ?? model?.atk?.max_atk ?? 0,
|
||||||
|
max_atk_flb: model?.atk?.maxAtkFlb ?? model?.atk?.max_atk_flb ?? 0,
|
||||||
flb: model?.uncap?.flb ?? false,
|
flb: model?.uncap?.flb ?? false,
|
||||||
ulb: model?.uncap?.ulb ?? false,
|
ulb: model?.uncap?.ulb ?? false,
|
||||||
transcendence: model?.uncap?.transcendence ?? false
|
transcendence: model?.uncap?.transcendence ?? false
|
||||||
|
|
@ -47,6 +50,7 @@ export function toPayload(edit: WeaponEdit) {
|
||||||
rarity: edit.rarity,
|
rarity: edit.rarity,
|
||||||
element: edit.element,
|
element: edit.element,
|
||||||
proficiency: [edit.proficiency1, edit.proficiency2].filter(v => v !== 0),
|
proficiency: [edit.proficiency1, edit.proficiency2].filter(v => v !== 0),
|
||||||
|
promotions: edit.promotions,
|
||||||
hp: {
|
hp: {
|
||||||
min_hp: edit.min_hp,
|
min_hp: edit.min_hp,
|
||||||
max_hp: edit.max_hp,
|
max_hp: edit.max_hp,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
import { getElementLabel, getElementOptions } from '$lib/utils/element'
|
import { getElementLabel, getElementOptions } from '$lib/utils/element'
|
||||||
import { getProficiencyOptions } from '$lib/utils/proficiency'
|
import { getProficiencyOptions } from '$lib/utils/proficiency'
|
||||||
import { getWeaponSeriesOptions, getWeaponSeriesSlug } from '$lib/utils/weaponSeries'
|
import { getWeaponSeriesOptions, getWeaponSeriesSlug } from '$lib/utils/weaponSeries'
|
||||||
|
import { PROMOTION_NAMES, getPromotionNames } from '$lib/types/enums'
|
||||||
|
|
||||||
type ElementName = 'wind' | 'fire' | 'water' | 'earth' | 'dark' | 'light'
|
type ElementName = 'wind' | 'fire' | 'water' | 'earth' | 'dark' | 'light'
|
||||||
|
|
||||||
|
|
@ -38,6 +39,12 @@
|
||||||
const proficiencyOptions = getProficiencyOptions()
|
const proficiencyOptions = getProficiencyOptions()
|
||||||
const seriesOptions = [{ value: 0, label: 'None' }, ...getWeaponSeriesOptions()]
|
const seriesOptions = [{ value: 0, label: 'None' }, ...getWeaponSeriesOptions()]
|
||||||
|
|
||||||
|
// Promotion options for multiselect
|
||||||
|
const promotionOptions = Object.entries(PROMOTION_NAMES).map(([value, label]) => ({
|
||||||
|
value: Number(value),
|
||||||
|
label
|
||||||
|
}))
|
||||||
|
|
||||||
// Get element name for checkbox theming
|
// Get element name for checkbox theming
|
||||||
const elementName = $derived.by((): ElementName | undefined => {
|
const elementName = $derived.by((): ElementName | undefined => {
|
||||||
const el = editMode ? editData.element : weapon?.element
|
const el = editMode ? editData.element : weapon?.element
|
||||||
|
|
@ -55,6 +62,12 @@
|
||||||
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
||||||
.join(' ')
|
.join(' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Format promotions for display
|
||||||
|
function formatPromotionsDisplay(promotions: number[]): string {
|
||||||
|
if (!promotions || promotions.length === 0) return '—'
|
||||||
|
return getPromotionNames(promotions).join(', ')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DetailsContainer title="Details">
|
<DetailsContainer title="Details">
|
||||||
|
|
@ -112,6 +125,15 @@
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
element={elementName}
|
element={elementName}
|
||||||
/>
|
/>
|
||||||
|
<DetailItem
|
||||||
|
label="Promotions"
|
||||||
|
sublabel="Gacha pools where this weapon appears"
|
||||||
|
bind:value={editData.promotions}
|
||||||
|
editable={true}
|
||||||
|
type="multiselect"
|
||||||
|
options={promotionOptions}
|
||||||
|
element={elementName}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<DetailItem label="Element">
|
<DetailItem label="Element">
|
||||||
<ElementLabel element={weapon.element} size="medium" />
|
<ElementLabel element={weapon.element} size="medium" />
|
||||||
|
|
@ -126,5 +148,6 @@
|
||||||
<DetailItem label="Extra" sublabel="Can be placed in Additional Weapons" value={weapon.extra ? 'Yes' : 'No'} />
|
<DetailItem label="Extra" sublabel="Can be placed in Additional Weapons" value={weapon.extra ? 'Yes' : 'No'} />
|
||||||
<DetailItem label="Limit" sublabel="Only one copy can be placed in a team" value={weapon.limit ? 'Yes' : 'No'} />
|
<DetailItem label="Limit" sublabel="Only one copy can be placed in a team" value={weapon.limit ? 'Yes' : 'No'} />
|
||||||
<DetailItem label="AX Skills" sublabel="Can have AX Skills" value={weapon.ax ? 'Yes' : 'No'} />
|
<DetailItem label="AX Skills" sublabel="Can have AX Skills" value={weapon.ax ? 'Yes' : 'No'} />
|
||||||
|
<DetailItem label="Promotions" sublabel="Gacha pools where this weapon appears" value={formatPromotionsDisplay(weapon.promotions)} />
|
||||||
{/if}
|
{/if}
|
||||||
</DetailsContainer>
|
</DetailsContainer>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue