zenno: format

This commit is contained in:
2026-03-31 12:07:38 -04:00
parent 08deedea8f
commit 22ca5c98f3
15 changed files with 196 additions and 179 deletions

View File

@@ -1,8 +1,8 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"trailingComma": "all",
"printWidth": 130,
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
"overrides": [
{

View File

@@ -22,8 +22,8 @@ export default defineConfig(
rules: {
// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
'no-undef': 'off'
}
'no-undef': 'off',
},
},
{
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
@@ -32,8 +32,8 @@ export default defineConfig(
projectService: true,
extraFileExtensions: ['.svelte'],
parser: ts.parser,
svelteConfig
}
}
}
svelteConfig,
},
},
},
);

View File

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

View File

@@ -1,5 +1,5 @@
import type { RegionalName } from '$lib/regional-name'
import globalJSON from '../../../../global/character.json'
import type { RegionalName } from '$lib/regional-name';
import globalJSON from '../../../../global/character.json';
/**
* Character definitions.
@@ -8,16 +8,19 @@ export interface Character {
/**
* Character ID.
*/
chara_id: number
chara_id: number;
/**
* Regional name of the character.
* E.g., Special Week for Global, or スペシャルウィーク for JP.
*/
name: string
name: string;
}
export const character = {
global: globalJSON as Character[],
}
global: globalJSON as Character[],
};
export const charaNames = globalJSON.reduce((m, c) => m.set(c.chara_id, {en: c.name}), new Map<Character['chara_id'], RegionalName>());
export const charaNames = globalJSON.reduce(
(m, c) => m.set(c.chara_id, { en: c.name }),
new Map<Character['chara_id'], RegionalName>(),
);

View File

@@ -1,5 +1,5 @@
import type { RegionalName } from '$lib/regional-name';
import globalJSON from '../../../../global/conversation.json'
import globalJSON from '../../../../global/conversation.json';
/**
* Lobby conversation data.
@@ -42,33 +42,36 @@ export interface Conversation {
export const conversation = {
global: globalJSON as Conversation[],
}
};
export const byChara = {
global: globalJSON.reduce((m, c) => m.set(c.chara_id, (m.get(c.chara_id) ?? []).concat(c as Conversation)), new Map<Conversation['chara_id'], Conversation[]>()),
}
global: globalJSON.reduce(
(m, c) => m.set(c.chara_id, (m.get(c.chara_id) ?? []).concat(c as Conversation)),
new Map<Conversation['chara_id'], Conversation[]>(),
),
};
export const locations: Record<Conversation['location'], {name: RegionalName, group: 1 | 2 | 3 | 4 | 5}> = {
110: {name: {en: 'right side front'}, group: 1},
120: {name: {en: 'right side front'}, group: 1},
130: {name: {en: 'right side front'}, group: 1},
210: {name: {en: 'left side table'}, group: 2},
220: {name: {en: 'left side table'}, group: 2},
310: {name: {en: 'center back seat'}, group: 3},
410: {name: {en: 'center posters'}, group: 4},
420: {name: {en: 'center posters'}, group: 4},
430: {name: {en: 'center posters'}, group: 4},
510: {name: {en: 'left side school map'}, group: 5},
520: {name: {en: 'left side school map'}, group: 5},
530: {name: {en: 'left side school map'}, group: 5},
}
export const locations: Record<Conversation['location'], { name: RegionalName; group: 1 | 2 | 3 | 4 | 5 }> = {
110: { name: { en: 'right side front' }, group: 1 },
120: { name: { en: 'right side front' }, group: 1 },
130: { name: { en: 'right side front' }, group: 1 },
210: { name: { en: 'left side table' }, group: 2 },
220: { name: { en: 'left side table' }, group: 2 },
310: { name: { en: 'center back seat' }, group: 3 },
410: { name: { en: 'center posters' }, group: 4 },
420: { name: { en: 'center posters' }, group: 4 },
430: { name: { en: 'center posters' }, group: 4 },
510: { name: { en: 'left side school map' }, group: 5 },
520: { name: { en: 'left side school map' }, group: 5 },
530: { name: { en: 'left side school map' }, group: 5 },
};
function locCharas(convos: Conversation[], locGroup: 1 | 2 | 3 | 4 | 5) {
const m = convos
.filter((c) => locations[c.location].group === locGroup)
.flatMap((c) => [c.chara_1, c.chara_2, c.chara_3].filter((x) => x != null))
.reduce((m, id) => m.set(id, 1 + (m.get(id) ?? 0)), new Map<number, number>())
return [...m].toSorted((a, b) => b[1] - a[1]) // descending
.reduce((m, id) => m.set(id, 1 + (m.get(id) ?? 0)), new Map<number, number>());
return [...m].toSorted((a, b) => b[1] - a[1]); // descending
}
export const groupPopulars = {
@@ -79,4 +82,4 @@ export const groupPopulars = {
4: locCharas(conversation.global, 4),
5: locCharas(conversation.global, 5),
},
}
};

View File

@@ -3,5 +3,5 @@
* Currently English is the only supported language.
*/
export interface RegionalName {
en: string
en: string;
}

View File

@@ -7,9 +7,7 @@ describe('Welcome.svelte', () => {
it('renders greetings for host and guest', async () => {
render(Welcome, { host: 'SvelteKit', guest: 'Vitest' });
await expect
.element(page.getByRole('heading', { level: 1 }))
.toHaveTextContent('Hello, SvelteKit!');
await expect.element(page.getByRole('heading', { level: 1 })).toHaveTextContent('Hello, SvelteKit!');
await expect.element(page.getByText('Hello, Vitest!')).toBeInTheDocument();
});
});

View File

@@ -7,22 +7,22 @@
<svelte:head><link rel="icon" href={favicon} /></svelte:head>
<nav class="flex min-w-full p-4 mb-4 shadow-md">
<span class="hidden md:inline flex-1">
<nav class="mb-4 flex min-w-full p-4 shadow-md">
<span class="hidden flex-1 md:inline">
<a href="/" class="text-7xl">Zenno Rob Roy</a>
</span>
<span class="flex-1 text-center">
<a href="/" class="md:hidden block mx-8 my-1 font-semibold">Zenno Rob Roy</a>
<a href="/inherit" class="inline-block mx-8 my-1">Inheritance Chance</a>
<a href="/spark" class="inline-block mx-8 my-1">Spark Chance</a>
<a href="/vet" class="inline-block mx-8 my-1">My Veterans</a>
<a href="/convo" class="inline-block mx-8 my-1">Lobby Conversations</a>
<a href="/" class="mx-8 my-1 block font-semibold md:hidden">Zenno Rob Roy</a>
<a href="/inherit" class="mx-8 my-1 inline-block">Inheritance Chance</a>
<a href="/spark" class="mx-8 my-1 inline-block">Spark Chance</a>
<a href="/vet" class="mx-8 my-1 inline-block">My Veterans</a>
<a href="/convo" class="mx-8 my-1 inline-block">Lobby Conversations</a>
</span>
</nav>
<div class="md:min-w-7xl md:max-w-7xl md:m-auto">
<div class="md:m-auto md:max-w-7xl md:min-w-7xl">
{@render children()}
</div>
<footer class="p-4 mt-32 inset-x-0 bottom-0 border-t text-center text-[14px]">
Umamusume: Pretty Derby tools by <a href="https://zephyrtronium.date/">zephyrtronium</a>.<br>
<footer class="inset-x-0 bottom-0 mt-32 border-t p-4 text-center text-[14px]">
Umamusume: Pretty Derby tools by <a href="https://zephyrtronium.date/">zephyrtronium</a>.<br />
All data is generated from the game's local database.
</footer>

View File

@@ -1,11 +1,21 @@
<script lang="ts">
import CharaPick from "$lib/CharaPick.svelte";
import CharaPick from '$lib/CharaPick.svelte';
let selChara = $state(0);
let selChara = $state(0);
</script>
<h1>Welcome to SvelteKit</h1>
<CharaPick id="test-chara" bind:value={selChara} />
<p>selected character is id {selChara}</p>
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>
<p>Lorem ipsum (/ ˌ l ɔː. r ə m ˈ ɪ p. s ə m/ LOR-əm IP-səm) is a dummy or placeholder text commonly used in graphic design, publishing, and web development. It is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero, with words altered, added, and removed to make it nonsensical and improper Latin. The first two words are the truncation of dolorem ipsum ("pain itself"). Lorem ipsum's purpose is to permit a page layout to be designed, independently of the copy that will subsequently populate it, or to demonstrate various fonts of a typeface without meaningful text that could be distracting. Versions of the Lorem ipsum text have been used in typesetting since the 1960s, when advertisements for Letraset transfer sheets popularized it. Lorem ipsum was introduced to the digital world in the mid-1980s, when Aldus employed it in graphic and word-processing templates for its desktop publishing program PageMaker. Other popular word processors, including Pages and Microsoft Word, have since adopted Lorem ipsum, as have many LaTeX packages, web content</p>
<p>
Lorem ipsum (/ ˌ l ɔː. r ə m ˈ ɪ p. s ə m/ LOR-əm IP-səm) is a dummy or placeholder text commonly used in graphic design,
publishing, and web development. It is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by
the Roman statesman and philosopher Cicero, with words altered, added, and removed to make it nonsensical and improper Latin.
The first two words are the truncation of dolorem ipsum ("pain itself"). Lorem ipsum's purpose is to permit a page layout to be
designed, independently of the copy that will subsequently populate it, or to demonstrate various fonts of a typeface without
meaningful text that could be distracting. Versions of the Lorem ipsum text have been used in typesetting since the 1960s, when
advertisements for Letraset transfer sheets popularized it. Lorem ipsum was introduced to the digital world in the mid-1980s,
when Aldus employed it in graphic and word-processing templates for its desktop publishing program PageMaker. Other popular word
processors, including Pages and Microsoft Word, have since adopted Lorem ipsum, as have many LaTeX packages, web content
</p>

View File

@@ -1,69 +1,69 @@
<script lang="ts">
import { charaNames } from "$lib/data/character";
import { byChara, locations, groupPopulars } from "$lib/data/convo";
import CharaPick from "$lib/CharaPick.svelte";
import { charaNames } from '$lib/data/character';
import { byChara, locations, groupPopulars } from '$lib/data/convo';
import CharaPick from '$lib/CharaPick.svelte';
let charaID = $state(1001)
let convo = $state(1)
let charaID = $state(1001);
let convo = $state(1);
let options = $derived(byChara.global.get(charaID) ?? [])
let cur = $derived(options.find((c) => c.number === convo))
let options = $derived(byChara.global.get(charaID) ?? []);
let cur = $derived(options.find((c) => c.number === convo));
function suggest(n: number, pops: typeof groupPopulars['global']) {
if (cur == null) {
return []
}
const u = pops[locations[cur.location].group]
.filter((s) => charaNames.get(s[0]) != null && s[0] !== cur.chara_1 && s[0] !== cur.chara_2 && s[0] !== cur.chara_3)
if (u.length <= n) {
return u
}
return u.filter((s) => s[1] >= u[n][1])
}
function suggest(n: number, pops: (typeof groupPopulars)['global']) {
if (cur == null) {
return [];
}
const u = pops[locations[cur.location].group].filter(
(s) => charaNames.get(s[0]) != null && s[0] !== cur.chara_1 && s[0] !== cur.chara_2 && s[0] !== cur.chara_3,
);
if (u.length <= n) {
return u;
}
return u.filter((s) => s[1] >= u[n][1]);
}
</script>
<h1>Lobby Conversations</h1>
<div class="flex text-center mt-8">
<div class="flex-1">
<CharaPick id="chara" label="Character" bind:value={charaID} required />
</div>
<div class="flex-1">
<label for="convo">Conversation</label>
<select id="convo" bind:value={convo} class="w-full">
{#each options as opt}
<option value={opt.number}>Slice of Life {opt.number}</option>
{/each}
</select>
</div>
<div class="mt-8 flex text-center">
<div class="flex-1">
<CharaPick id="chara" label="Character" bind:value={charaID} required />
</div>
<div class="flex-1">
<label for="convo">Conversation</label>
<select id="convo" bind:value={convo} class="w-full">
{#each options as opt}
<option value={opt.number}>Slice of Life {opt.number}</option>
{/each}
</select>
</div>
</div>
{#if cur}
<div class="transition-shadow shadow-sm hover:shadow-md">
<div class="flex mt-8 text-center">
<span class="flex-1">{charaNames.get(cur.chara_1)?.en ?? 'someone not a trainee'}</span>
{#if cur.chara_2}
<span class="flex-1">{charaNames.get(cur.chara_2)?.en ?? 'someone not a trainee'}</span>
{/if}
{#if cur.chara_3}
<span class="flex-1">{charaNames.get(cur.chara_3)?.en ?? 'someone not a trainee'}</span>
{/if}
</div>
<div class="flex mt-4 w-full text-center">
<span class="flex-1">at {locations[cur.location].name.en}</span>
</div>
</div>
<div class="block mt-4 text-center">
<span>Characters who appear here most often:</span>
</div>
<div class="grid md:grid-cols-4 mt-4 text-center transition-shadow ease-in hover:ease-out shadow-sm hover:shadow-md">
{#each suggest(8, groupPopulars.global) as s}
<span>{charaNames.get(s[0])?.en}: {s[1]}&#xd7;</span>
{/each}
</div>
<div class="block mt-4 text-center">
<span>
Set characters that appear more often to fixed positions
(main, upgrades, story, races)
to maximize the chance of getting this conversation.
</span>
</div>
{/if}
<div class="shadow-sm transition-shadow hover:shadow-md">
<div class="mt-8 flex text-center">
<span class="flex-1">{charaNames.get(cur.chara_1)?.en ?? 'someone not a trainee'}</span>
{#if cur.chara_2}
<span class="flex-1">{charaNames.get(cur.chara_2)?.en ?? 'someone not a trainee'}</span>
{/if}
{#if cur.chara_3}
<span class="flex-1">{charaNames.get(cur.chara_3)?.en ?? 'someone not a trainee'}</span>
{/if}
</div>
<div class="mt-4 flex w-full text-center">
<span class="flex-1">at {locations[cur.location].name.en}</span>
</div>
</div>
<div class="mt-4 block text-center">
<span>Characters who appear here most often:</span>
</div>
<div class="mt-4 grid text-center shadow-sm transition-shadow ease-in hover:shadow-md hover:ease-out md:grid-cols-4">
{#each suggest(8, groupPopulars.global) as s}
<span>{charaNames.get(s[0])?.en}: {s[1]}&#xd7;</span>
{/each}
</div>
<div class="mt-4 block text-center">
<span>
Set characters that appear more often to fixed positions (main, upgrades, story, races) to maximize the chance of getting
this conversation.
</span>
</div>
{/if}

View File

@@ -2,5 +2,5 @@
@import './sakura-vars.css';
@theme {
--text-sm: 1.25rem;
--text-sm: 1.25rem;
}

View File

@@ -13,7 +13,7 @@
--text: #292222;
}
[data-theme="iron goddess"] {
[data-theme='iron goddess'] {
--blossom: #424b51;
--fade: #64707a;
--bg: #fff2e2;
@@ -21,7 +21,7 @@
--text: #2c2923;
}
[data-theme="main sequence"] {
[data-theme='main sequence'] {
--blossom: #3a5425;
--fade: #698650;
--bg: #fffde5;
@@ -29,7 +29,7 @@
--text: #5e592a;
}
[data-theme="sorcery"] {
[data-theme='sorcery'] {
--blossom: #5a5a69;
--fade: #868698;
--bg: #e5f4e5;
@@ -37,7 +37,7 @@
--text: #323932;
}
[data-theme="cirrus"] {
[data-theme='cirrus'] {
--blossom: #565a4b;
--fade: #9da587;
--bg: #e5f6fa;
@@ -45,7 +45,7 @@
--text: #31393b;
}
[data-theme="oxygen"] {
[data-theme='oxygen'] {
--blossom: #162011;
--fade: #343932;
--bg: #e1e2e4;
@@ -53,7 +53,7 @@
--text: #27282c;
}
[data-theme="dauphin"] {
[data-theme='dauphin'] {
--blossom: #171e1c;
--fade: #485b58;
--bg: #ebe5f8;
@@ -61,7 +61,7 @@
--text: #1c1a20;
}
[data-theme="diamond-burned"] {
[data-theme='diamond-burned'] {
--blossom: #0f0d0b;
--fade: #4d4743;
--bg: #f8ebf2;
@@ -69,7 +69,7 @@
--text: #3e363a;
}
[data-theme="chi"] {
[data-theme='chi'] {
--blossom: #908975;
--fade: #fff8e5;
--bg: #110c0c;
@@ -77,7 +77,7 @@
--text: #cfa9a9;
}
[data-theme="darjeeling"] {
[data-theme='darjeeling'] {
--blossom: #ba949c;
--fade: #f8e1e6;
--bg: #1c160d;
@@ -85,7 +85,7 @@
--text: #c9b9a0;
}
[data-theme="subgiant"] {
[data-theme='subgiant'] {
--blossom: #9fad8a;
--fade: #e8f2d7;
--bg: #16130b;
@@ -93,7 +93,7 @@
--text: #bbb396;
}
[data-theme="goblin"] {
[data-theme='goblin'] {
--blossom: #7a808e;
--fade: #dae1ef;
--bg: #070905;
@@ -101,7 +101,7 @@
--text: #acbd9f;
}
[data-theme="altostratus"] {
[data-theme='altostratus'] {
--blossom: #a8a0b7;
--fade: #e5dbf7;
--bg: #0c0f0f;
@@ -109,7 +109,7 @@
--text: #8da4a4;
}
[data-theme="silicon"] {
[data-theme='silicon'] {
--blossom: #717f63;
--fade: #c4d4b3;
--bg: #050a0f;
@@ -117,7 +117,7 @@
--text: #838e9a;
}
[data-theme="imperator"] {
[data-theme='imperator'] {
--blossom: #93a0a3;
--fade: #f3fbfd;
--bg: #0e0c12;
@@ -125,7 +125,7 @@
--text: #a8a1b1;
}
[data-theme="mædi"] {
[data-theme='mædi'] {
--blossom: #ccd3b6;
--fade: #fdfbf3;
--bg: #10090f;
@@ -136,7 +136,7 @@
/* Body */
html {
font-size: 62.5%;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
}
body {
@@ -168,7 +168,7 @@ h4,
h5,
h6 {
line-height: 1.1;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
font-weight: 700;
margin-top: 3rem;
margin-bottom: 1.5rem;
@@ -281,7 +281,7 @@ samp {
white-space: pre-wrap;
}
pre>code {
pre > code {
padding: 0;
background-color: transparent;
white-space: pre;
@@ -319,10 +319,10 @@ textarea {
.button,
button,
input[type=submit],
input[type=reset],
input[type=button],
input[type=file]::file-selector-button {
input[type='submit'],
input[type='reset'],
input[type='button'],
input[type='file']::file-selector-button {
display: inline-block;
padding: 5px 10px;
text-align: center;
@@ -338,20 +338,20 @@ input[type=file]::file-selector-button {
.button[disabled],
button[disabled],
input[type=submit][disabled],
input[type=reset][disabled],
input[type=button][disabled],
input[type=file]::file-selector-button[disabled] {
input[type='submit'][disabled],
input[type='reset'][disabled],
input[type='button'][disabled],
input[type='file']::file-selector-button[disabled] {
cursor: default;
opacity: 0.5;
}
.button:hover,
button:hover,
input[type=submit]:hover,
input[type=reset]:hover,
input[type=button]:hover,
input[type=file]::file-selector-button:hover {
input[type='submit']:hover,
input[type='reset']:hover,
input[type='button']:hover,
input[type='file']::file-selector-button:hover {
background-color: var(--fade);
color: var(--bg);
outline: 0;
@@ -359,10 +359,10 @@ input[type=file]::file-selector-button:hover {
.button:focus-visible,
button:focus-visible,
input[type=submit]:focus-visible,
input[type=reset]:focus-visible,
input[type=button]:focus-visible,
input[type=file]::file-selector-button:focus-visible {
input[type='submit']:focus-visible,
input[type='reset']:focus-visible,
input[type='button']:focus-visible,
input[type='file']::file-selector-button:focus-visible {
outline-style: solid;
outline-width: 2px;
}
@@ -388,7 +388,7 @@ input:focus {
outline: 0;
}
input[type=checkbox]:focus {
input[type='checkbox']:focus {
outline: 1px dotted var(--blossom);
}
@@ -398,4 +398,4 @@ fieldset {
display: block;
margin-bottom: 0.5rem;
font-weight: 600;
}
}

View File

@@ -1,3 +1,6 @@
<h1>Spark Generation Chance</h1>
<p>Given a legacy, calculate the chance of generating each spark if you fulfill the conditions to do so, and the distribution of total spark counts.</p>
<p>
Given a legacy, calculate the chance of generating each spark if you fulfill the conditions to do so, and the distribution of
total spark counts.
</p>
<p>TODO</p>

View File

@@ -11,14 +11,14 @@ const config = {
const isExternalLibrary = pathSegments.includes('node_modules');
return isExternalLibrary ? undefined : true;
}
},
},
kit: {
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
adapter: adapter()
}
adapter: adapter(),
},
};
export default config;

View File

@@ -15,11 +15,11 @@ export default defineConfig({
browser: {
enabled: true,
provider: playwright(),
instances: [{ browser: 'chromium', headless: true }]
instances: [{ browser: 'chromium', headless: true }],
},
include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
exclude: ['src/lib/server/**']
}
exclude: ['src/lib/server/**'],
},
},
{
@@ -28,9 +28,9 @@ export default defineConfig({
name: 'server',
environment: 'node',
include: ['src/**/*.{test,spec}.{js,ts}'],
exclude: ['src/**/*.svelte.{test,spec}.{js,ts}']
}
}
]
}
exclude: ['src/**/*.svelte.{test,spec}.{js,ts}'],
},
},
],
},
});