From 8271bdcee6b97441ecf703b1169809b04d1621b0 Mon Sep 17 00:00:00 2001 From: Aelita4 Date: Thu, 26 Sep 2024 13:38:10 +0200 Subject: [PATCH] Show planet owners in galaxy view --- src/pages/game/galaxyView.astro | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pages/game/galaxyView.astro b/src/pages/game/galaxyView.astro index a2cc6d2..859bf58 100644 --- a/src/pages/game/galaxyView.astro +++ b/src/pages/game/galaxyView.astro @@ -3,6 +3,8 @@ import Layout from '../../layouts/Layout.astro'; import NavBar from '../../components/NavBar.astro'; import { getUserByAccessToken } from '../../lib/db/users'; import { getAllPlanets } from '../../lib/db/planets'; +import locationManager from '../../lib/classes/managers/LocationManager'; +import ResourceBar from '../../components/ResourceBar.astro'; const loggedToken = Astro.cookies.get('sessionToken')?.value ?? null; const username = Astro.cookies.get('username')?.value ?? ""; @@ -12,12 +14,20 @@ const checkUser = await getUserByAccessToken(loggedToken); if(checkUser === null || checkUser.username !== username) return Astro.redirect('/logout'); const allPlanets = await getAllPlanets(); + +const formattedPlanets = allPlanets.map(planet => { + return { + name: planet.name, + owner: locationManager.getUser(planet.owner)?.username ?? "Unowned" + }; +}) --- +
    - {allPlanets.map(planet =>
  • {planet.name} ({planet.owner.username})
  • )} + {formattedPlanets.map(planet =>
  • {planet.name} ({planet.owner})
  • )}