--- import { ObjectId } from 'mongodb'; import { Image } from 'astro:assets'; import { getHighestWeightedLanguage, getLocales, getName } from '../lib/utils/langDriver'; import { getAllResources } from '../lib/db/resources'; import locationManager from '../lib/classes/managers/LocationManager'; import { Resource } from '../lib/classes/managers/abstract/ResourceManager'; import SystemManager from '../lib/classes/managers/SystemManager'; const resourceTypes = await getAllResources(); const lang = await getLocales(Astro.cookies.get('language')?.value ?? await getHighestWeightedLanguage(Astro.request.headers.get('accept-language'))); const planetId = new ObjectId(Astro.cookies.get('currentPlanet')?.value ?? ''); const planet = locationManager.findId(planetId); if(!planet) return; await planet.resources.calculateCurrentAvailableResources(); const resourceArray: (Resource & { capacity: number })[] = []; for(const key of planet.resources.resources) { resourceArray.push({ ...key, capacity: 10_000 }); } if(!(planet instanceof SystemManager)) { const mapStorageToResource: { [key: string]: string } = { "coal-storage": "coal", "iron-storage": "iron", "gold-storage": "gold", "water-tank": "water", "acid-tank": "sulfuric-acid", "nitrogen-tank": "liquid-nitrogen", "hydrogen-tank": "hydrogen", "oxygen-tank": "oxygen", "helium3-tank": "helium-3", } resourceArray.forEach(res => { res.capacity = 10_000; }); for(const building of planet.buildings.buildings) { if(building.data.category === 'storage') { const resource = mapStorageToResource[building.data.id]; if(resource) { const res = resourceArray.find(x => x.id === resource); if(res) res.capacity += building.level * 10_000; } } } } ---