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,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),
},
}
};