diff --git a/src/components/ResourceBar.astro b/src/components/ResourceBar.astro new file mode 100644 index 0000000..bc6850e --- /dev/null +++ b/src/components/ResourceBar.astro @@ -0,0 +1,32 @@ +--- +import { getHighestWeightedLanguage, getLocales } from '../lib/lang/langDriver'; +interface Props { + loggedIn: string; +} + +const lang = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'resourcebar'); + +// const { loggedIn } = Astro.props; +--- + +
+
+ +
coal
+
+
+ + \ No newline at end of file diff --git a/src/lib/lang/en/game.json b/src/lib/lang/en/game.json index 8ddaee2..3fc534f 100644 --- a/src/lib/lang/en/game.json +++ b/src/lib/lang/en/game.json @@ -4,6 +4,6 @@ }, "Link": { "logout": "Log out", - "build": "Build {}" + "build": "[build]" } } \ No newline at end of file diff --git a/src/lib/lang/en/resourcebar.json b/src/lib/lang/en/resourcebar.json new file mode 100644 index 0000000..e3ea382 --- /dev/null +++ b/src/lib/lang/en/resourcebar.json @@ -0,0 +1,7 @@ +{ + "Label": { + "avaliable": "Avaliable: {}", + "production": "Production: {}/h", + "capacity": "Storage capacity: {}" + } +} \ No newline at end of file diff --git a/src/pages/game/index.astro b/src/pages/game/index.astro index d276dfb..0444489 100644 --- a/src/pages/game/index.astro +++ b/src/pages/game/index.astro @@ -3,6 +3,7 @@ import Layout from '../../layouts/Layout.astro'; import NavBar from '../../components/NavBar.astro'; import { getUserResources, updateUserResources } from '../../lib/db/users'; import { getHighestWeightedLanguage, getLocales } from '../../lib/lang/langDriver'; +import ResourceBar from '../../components/ResourceBar.astro'; const loggedToken = Astro.cookies.get('sessionToken')?.value ?? null; const username = Astro.cookies.get('username')?.value ?? ""; @@ -11,17 +12,12 @@ if(loggedToken === null || username === "") return Astro.redirect('/'); const resources = await getUserResources(username); -await updateUserResources(username, { - coal: resources.coal * 2, - iron: resources.iron * 3, - gold: resources.gold * 4, -}); - const langResources = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'resources'); --- +
  • {langResources['Label_coal']}: {resources.coal * 2}
  • {langResources['Label_iron']}: {resources.iron * 3}