-
{Astro.props.name}
+
{Astro.props.name} | {Astro.props.level}
{Astro.props.description}
{getName(lang, Astro.props.button_type, Astro.props.button_name)}
i
diff --git a/src/components/ResourceBar.astro b/src/components/ResourceBar.astro
index 76cb44a..3033256 100644
--- a/src/components/ResourceBar.astro
+++ b/src/components/ResourceBar.astro
@@ -1,20 +1,26 @@
---
import { ObjectId } from 'mongodb';
-import { calculateCurrentAvailableResources } from '../lib/utils/resourceManager';
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/ResourceManager';
const resourceTypes = await getAllResources();
const lang = await getLocales(await getHighestWeightedLanguage(Astro.request.headers.get('accept-language')));
-const resources = await calculateCurrentAvailableResources(new ObjectId(Astro.cookies.get('planetid')?.value ?? ''));
+const planetId = new ObjectId(Astro.cookies.get('planetid')?.value ?? '');
-const resourceArray = [];
-for(const key in resources) {
- resourceArray.push(resources[key as never]);
+const resources = locationManager.getPlanet(planetId)?.resources;
+
+if(!resources) return;
+
+resources.calculateCurrentAvailableResources();
+
+const resourceArray: Resource[] = [];
+for(const key of resources.resources) {
+ resourceArray.push(key);
}
-
---
@@ -23,16 +29,16 @@ for(const key in resources) {
{resourceArray.map(res =>
x.id === res.name)?.type ?? "solid"}
+ data-res-type={resourceTypes.find(x => x.id === res.id)?.type ?? "solid"}
data-res-amount={res.amount}
data-res-mining-rate={res.perHourMiningRate}
- style={(resourceTypes.find(x => x.id === res.name)?.type ?? "solid") === "solid" ? "" : "display: none;"}
+ style={(resourceTypes.find(x => x.id === res.id)?.type ?? "solid") === "solid" ? "" : "display: none;"}
>
-
x.id === res.name)?.icon ?? "#"} alt={res.name} />
+
x.id === res.id)?.icon ?? "#"} alt={res.id} />
-
-
{getName(lang, 'resources', res.name)}
+
+
{getName(lang, 'resources', res.id)}
[fetching]