feat: First iteration, multi themes, I18N
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// Loads the static game data and the lists of installed themes / languages.
|
||||
|
||||
import { buildContext } from '../engine/context.js';
|
||||
|
||||
async function getJson(url) {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) throw new Error(`${url}: HTTP ${response.status}`);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function loadGameContext() {
|
||||
const [rules, generators, upgrades] = await Promise.all([
|
||||
getJson('data/rules.json'),
|
||||
getJson('data/generators.json'),
|
||||
getJson('data/upgrades.json'),
|
||||
]);
|
||||
return buildContext({ rules, generators, upgrades });
|
||||
}
|
||||
|
||||
/** [{ id, order, assets, locales }] discovered from public/themes/ by the server. */
|
||||
export const fetchThemes = () => getJson('api/themes');
|
||||
|
||||
/** [{ code, name }] discovered from public/locales/ by the server. */
|
||||
export const fetchLocales = () => getJson('api/locales');
|
||||
Reference in New Issue
Block a user