diff --git a/src/components/ResourceBar.astro b/src/components/ResourceBar.astro index b729649..8388ec6 100644 --- a/src/components/ResourceBar.astro +++ b/src/components/ResourceBar.astro @@ -105,7 +105,7 @@ if(!(planet instanceof SystemManager)) { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); position: sticky; top: 0; - z-index: 1000; + z-index: 100; border-radius: 0px 0px 10px 10px; padding-top: 4px; padding-bottom: 4px; diff --git a/src/lib/classes/managers/FleetManager.ts b/src/lib/classes/managers/FleetManager.ts index 2dd3631..5a8c1c0 100644 --- a/src/lib/classes/managers/FleetManager.ts +++ b/src/lib/classes/managers/FleetManager.ts @@ -212,7 +212,7 @@ export default class FleetManager { this.data.source instanceof SystemManager ? this.data.source.data.ownedBy.id : this.data.source.system.data.ownedBy.id, this.data.destination.data.ownedBy.id, new Date(), - [], + this.data.destination.data.ownedBy.research.research.map(research => { return { id: research.id, level: research.level } }), gatheredData ); } @@ -234,7 +234,7 @@ export default class FleetManager { if(existing.planets.find(p => p.id.equals(planetId))) { await updatePlanetSpyReport(existing._id, planetId, gatheredData); } else { - await addPlanetToExistingSpyReport(existing._id, gatheredData); + await addPlanetToExistingSpyReport(existing._id, planetId, gatheredData); } } diff --git a/src/lib/db/spyReports.ts b/src/lib/db/spyReports.ts index 426fdde..602b141 100644 --- a/src/lib/db/spyReports.ts +++ b/src/lib/db/spyReports.ts @@ -65,6 +65,7 @@ export const updateSystemSpyReportWithoutPlanets = async ( export const addPlanetToExistingSpyReport = async ( id: ObjectId, + planetId: ObjectId, data: { resources: Array<{ id: string, amount: number }>, buildings: Array<{ id: string, level: number }>, @@ -77,7 +78,7 @@ export const addPlanetToExistingSpyReport = async ( }, { $push: { planets: { - id: new ObjectId(), + id: planetId, scanned: true, scannedAt: new Date(), resources: data.resources, diff --git a/src/pages/game/galaxyView.astro b/src/pages/game/galaxyView.astro index b31db4d..62610c2 100644 --- a/src/pages/game/galaxyView.astro +++ b/src/pages/game/galaxyView.astro @@ -1,6 +1,10 @@ --- import LoggedIn from '../../layouts/LoggedIn.astro'; import locationManager from '../../lib/classes/managers/LocationManager'; +import User from '../../lib/classes/User'; +import { getUserSpyReports } from '../../lib/db/users'; + +const user: User = Astro.locals.user; const allGalaxies = locationManager.galaxies; @@ -21,9 +25,80 @@ const galaxies = allGalaxies.map(galaxy => { }; }) }; -}) +}); + +const spyReportsDB = await getUserSpyReports(user.id); + +const spyReports = spyReportsDB.map(spy => { + const user = locationManager.getUser(spy.victimId); + const system = locationManager.getSystem(spy.systemId); + + return { + username: user?.username ?? "Unknown", + systemName: system?.data.name ?? "Unknown", + sectorId: system?.data.sector._id.toString(), + scannedAt: spy.scannedAt, + research: spy.research, + resources: spy.resources, + structures: spy.structures, + ships: spy.ships, + defense: spy.defense, + planets: system?.planets.map(planet => { + const report = spy.planets.find(p => p.id.equals(planet._id)); + + return { + id: planet._id.toString(), + name: planet.name, + scanned: spy.planets.find(p => p.id.equals(planet._id))?.scanned ?? false, + scannedAt: report?.scannedAt ?? "Unknown", + resources: report?.resources ?? [], + buildings: report?.buildings ?? [], + ships: report?.ships ?? [], + defense: report?.defense ?? [] + }; + }) + } +}); --- +
+
+

Spy report from at

+
+
+
+

Resources:

+
+
+
+

Structures:

+
+
+
+
+
+ +

Ships:

+
+
+
+

Defense:

+
+
+
+
+
+

Research:

+
+
+
+

Planets:

+
+
+
+
+
+
{galaxies.map(galaxy => <> @@ -34,9 +109,9 @@ const galaxies = allGalaxies.map(galaxy => { )}
-
+
@@ -76,23 +151,23 @@ const galaxies = allGalaxies.map(galaxy => { color: white; } -.galaxy-details { +.sidebar-details { width: 23%; height: 500px; margin-top: 50px; margin-right: 50px; } -.galaxy-details h2 { +.sidebar-details h2 { text-align: center; } -.galaxy-sector-list { +.sidebar-list { display: flex; flex-direction: column; } -.galaxy-sector-list div { +.sidebar-list div { text-align: center; background-color: gray; margin-top: 10px; @@ -100,36 +175,155 @@ const galaxies = allGalaxies.map(galaxy => { padding-top: 10px; padding-bottom: 10px; } + +.sidebar-list .sidebar-planet { + margin-left: 32px; +} + +.sidebar-list div:hover { + background-color: #888888; +} + + +#report-modal-background { + display: none; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.5); + z-index: 100; +} + +#report-modal-details { + display: none; + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 80%; + max-width: 800px; + background: rgba(0, 0, 0, 0.9); + border-radius: 8px; + padding: 1rem; + z-index: 10000; + color: white; +} + +.report-modal-row { + display: flex; + flex-direction: row; + justify-content: space-evenly; +} + +.report-modal-card { + width: 45%; +} - \ No newline at end of file