horsegen, zenno/convo: get all character names

This commit is contained in:
2026-04-06 16:46:37 -04:00
parent dfb2ad2950
commit 5a444ea08c
4 changed files with 133 additions and 28 deletions

View File

@@ -1,38 +1,24 @@
<script lang="ts">
import { character } from '$lib/data/character';
import { type Character } from '$lib/data/character';
import type { ClassValue } from 'svelte/elements';
interface Props {
id: string;
characters: Character[];
value: number;
label?: string;
class?: ClassValue | null;
optionClass?: ClassValue | null;
labelClass?: ClassValue | null;
region?: keyof typeof character;
required?: boolean;
}
let {
id,
value = $bindable(),
label,
class: className,
optionClass,
labelClass,
region = 'global',
required = false,
}: Props = $props();
let { id, characters, value = $bindable(), class: className, optionClass, required = false }: Props = $props();
</script>
{#if label}
<label for={id} class={labelClass}>{label}</label>
{/if}
<select {id} class={className} bind:value {required}>
{#if !required}
<option value="0" class={optionClass}></option>
{/if}
{#each character[region] as c (c.chara_id)}
{#each characters as c (c.chara_id)}
<option value={c.chara_id} class={optionClass}>{c.name}</option>
{/each}
</select>

View File

@@ -1,8 +1,9 @@
<script lang="ts">
import { charaNames } from '$lib/data/character';
import { character, charaNames } from '$lib/data/character';
import { byChara, locations, groupPopulars } from '$lib/data/convo';
import CharaPick from '$lib/CharaPick.svelte';
const characters = character.global.filter((c) => byChara.global.has(c.chara_id));
const minSuggest = 8;
let charaID = $state(1001);
@@ -10,9 +11,9 @@
const options = $derived(byChara.global.get(charaID) ?? []);
const cur = $derived(options.find((c) => c.number === convo));
const cur1Name = $derived(cur != null ? (charaNames.get(cur.chara_1)?.en ?? 'someone not a trainee') : '');
const cur2Name = $derived(cur?.chara_2 != null ? (charaNames.get(cur.chara_2)?.en ?? 'someone not a trainee') : '');
const cur3Name = $derived(cur?.chara_3 != null ? (charaNames.get(cur.chara_3)?.en ?? 'someone not a trainee') : '');
const cur1Name = $derived(cur?.chara_1 && charaNames.get(cur.chara_1)?.en);
const cur2Name = $derived(cur?.chara_2 && charaNames.get(cur.chara_2)?.en);
const cur3Name = $derived(cur?.chara_3 && charaNames.get(cur.chara_3)?.en);
const alone = $derived([cur?.chara_1, cur?.chara_2, cur?.chara_3].filter((x) => x != null).length == 1 ? ' alone' : '');
const suggested = $derived.by(() => {
if (cur == null) {
@@ -29,7 +30,8 @@
<h1 class="text-4xl">Lobby Conversations</h1>
<div class="mx-auto mt-8 flex flex-col rounded-md text-center shadow-md ring md:max-w-xl md:flex-row">
<div class="m-4 flex-1 md:mt-3">
<CharaPick id="chara" class="w-full" label="Character" labelClass="hidden md:inline" bind:value={charaID} required />
<label for="chara" class="hidden md:inline">Character</label>
<CharaPick id="chara" {characters} class="w-full" bind:value={charaID} required />
</div>
<div class="m-4 flex-1 md:mt-3">
<label for="convo" class="hidden md:inline">Conversation</label>