Skip to content

Commit

Permalink
️🧑🏼‍⚕️🦝 ↝ [SSM-101 SSM-104 SSM-105]: Beginning some calculations for …
Browse files Browse the repository at this point in the history
…biomass values on Earth & off-world
  • Loading branch information
Gizmotronn committed Jan 30, 2025
1 parent 2cd94bc commit f169998
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 92 deletions.
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Use the official Node.js image
FROM node:18-bullseye

# Set the working directory
WORKDIR /app

# Copy the package.json and yarn.lock
COPY package.json yarn.lock ./

# Install dependencies
RUN yarn install
# RUN yarn build

# Copy the rest of the application code
COPY . .

# For hot-reloading, you can use development mode
CMD ["yarn", "dev"]
20 changes: 20 additions & 0 deletions app/api/gameplay/inventory/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,26 @@ const inventoryItems: InventoryItem[] = [
ItemCategory: 'CommunityStation',
locationType: 'Orbital',
},


// Greenhouse/Biodome stations
{
id: 3104001,
name: "Desert Observatory",
description: "Track & tag animals and plants that originate in desert locations on Earth",
icon_url: '/assets/Archive/Inventory/Items/Coal.png', // For test
ItemCategory: 'BioDomeStation',
locationType: 'Surface',
},
{
id: 3104002,
name: "Ocean Observatory",
description: "Track & tag animals and plants that originate in the oceans of Earth",
icon_url: '/assets/Archive/Inventory/Items/Coal.png', // For test
ItemCategory: 'BioDomeStation',
locationType: 'Surface', // Maybe underwater?
},


// Tests
{
Expand Down
2 changes: 1 addition & 1 deletion app/scenes/onboarding/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { EarthScene } from "../earth/scene";
import { EarthScene } from "@/app/scenes/earth/scene";
import InventoryPage from "@/components/Inventory/Grid/Grid";
import EnhancedWeatherEvents from '@/components/(scenes)/mining/enhanced-weather-events';
import MissionSelector from "@/components/Missions/mission-selector";
Expand Down
2 changes: 1 addition & 1 deletion components/Data/unlockNewDataSources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ChevronDown, ChevronUp, Unlock } from "lucide-react";
import { lidarDataSources, telescopeDataSources, zoodexDataSources, roverDataSources } from "./ZoodexDataSources";
import { useActivePlanet } from "@/context/ActivePlanet";
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
import { InventoryIdFetcher } from "../Inventory/fetchId";
import { InventoryIdFetcher } from "@/components/Inventory/fetchId";
import Link from "next/link";

export function DataSourcesModal({ structureId, structure }: DataSourcesModalProps) {
Expand Down
2 changes: 1 addition & 1 deletion components/Layout/BottomMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Globe, HelpCircle, Star, Pickaxe } from "lucide-react";
import { usePathname } from "next/navigation";
import Link from "next/link";
import { useState } from "react";
import { MiningComponentComponent } from "../(scenes)/mining/mining-component";
import { MiningComponentComponent } from "@/components/(scenes)/mining/mining-component";

const menuItems = [
{ icon: Globe, label: "Planet", href: "/" },
Expand Down
4 changes: 2 additions & 2 deletions components/Structures/Build/EditMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function UnownedSurfaceStructures() {

useEffect(() => {
fetchStructures();
}, [fetchTrigger, fetchStructures]); // Re-fetch when fetchTrigger changes
}, [fetchTrigger, fetchStructures]); // Re-fetch when fetchTrigger changes

const addResearchStation = async () => {
if (!session || !activePlanet) return;
Expand All @@ -96,7 +96,7 @@ export function UnownedSurfaceStructures() {
alert("You now have a Research Station in your inventory!");
setFetchTrigger(fetchTrigger + 1); // Trigger a re-fetch
} catch (error) {
console.error('Error adding research station:', error);
console.error('Error adding research station: ', error);
setError('Failed to add the Research Station.');
};
};
Expand Down
9 changes: 9 additions & 0 deletions components/Structures/IndividualStructure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { GreenhouseResearchStations } from "./Missions/Biologists/ResearchStations";

export interface IndividualStructureProps {
name: string;
Expand Down Expand Up @@ -49,6 +50,10 @@ const IndividualStructure: React.FC<IndividualStructureProps> = ({
const [tooltip, setTooltip] = useState<{ visible: boolean; text: string } | null>(null);
const modalRef = useRef<HTMLDivElement>(null);

useEffect(() => {
console.warn(structureId)
}, [])

const handleActionClick = (actionText: string, component: React.ReactNode, sizePercentage: number = 100) => {
setActiveComponent(component);
setModalSizePercentage(sizePercentage);
Expand Down Expand Up @@ -233,6 +238,10 @@ const IndividualStructure: React.FC<IndividualStructureProps> = ({
</DialogContent>
)}

{structureId === 3104 && (
<GreenhouseResearchStations />
)}

</div>
</Dialog>
);
Expand Down
85 changes: 85 additions & 0 deletions components/Structures/Missions/Biologists/BiomassOnPlanet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React, { useEffect, useState } from "react";
import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react";
import { Card, CardContent } from "@/components/ui/card";
import { Switch } from "@/components/ui/switch";
import { Progress } from "@/components/ui/progress";
import { TreeDeciduousIcon } from "lucide-react";
import { useActivePlanet } from "@/context/ActivePlanet";

const BiomassStats = () => {
const supabase = useSupabaseClient();
const session = useSession();

const { activePlanet } = useActivePlanet();

const [totalBio, setTotalBio] = useState(0);
const [recentBio, setRecentBio] = useState(0);
const [onlyMine, setOnlyMine] = useState(false);
const [onPlanet, setOnPlanet] = useState(false);

useEffect(() => {
if (!session) {
return;
};

const fetchBioCount = async () => {
const query = supabase
.from("classifications")
.select("id, created_at")
.eq("classificationtype", "zoodex-planktonPortal") // add others

if (onlyMine) {
query.eq("author", session.user.id);
};

if (onPlanet) {
query.eq("anomaly", activePlanet.id); // fix to show the classificationConfiguration instead
};

const { data, error } = await query;

if ( error ) {
return;
} ;

setTotalBio(data.length);

const oneYearAgo = new Date();
oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1);
const recentCount = data.filter((entry) => new Date(entry.created_at) > oneYearAgo).length;
setRecentBio(recentCount);
};

fetchBioCount();
})

const bioScore = Math.min(100, (recentBio / 50) * 100); // Update this to be based on biomass weight, not quantity
const biomassLevel = bioScore > 5 ? "Intelligent Life" : bioScore > 3 ? "Fauna" : bioScore > 2 ? "Flora" : bioScore > 0 ? "Bacterium" : "Null";

return (
<Card className="p-4 w-full max-w-md bg-card border shadow-md rounded-lg">
<CardContent className="flex flex-col gap-4">
<div className="flex items-center justify-between">
<h2 className="text-lg font-semibold text-blue-500 clex items-center gap-2">
<TreeDeciduousIcon className="w-5 h-5" /> Total biomass
</h2>
<div className="flex items-center gap-2 text-sm">
<span className="text-gray-600">Only my discoveries</span>
<Switch checked={onlyMine} onCheckedChange={setOnlyMine} />
</div>
<div className="flex items-center gap-2 text-sm">
<span className="text-gray-600">Only on Planet: {activePlanet}</span>
<Switch checked={onPlanet} onCheckedChange={setOnPlanet} />
</div>
</div>
<p className="text-xl font-bold text-green-400">{totalBio}</p>
<div>
<p className="text-sm text-gray-500">Biomass score: {biomassLevel}</p>
<Progress value={bioScore} className="h-2 bg-green-500" />
</div>
</CardContent>
</Card>
)
};

export default BiomassStats;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FishIcon } from "lucide-react";
const PlanktonDiscoveryStats = () => {
const supabase = useSupabaseClient();
const session = useSession();

const [totalPlankton, setTotalPlankton] = useState(0);
const [recentPlankton, setRecentPlankton] = useState(0);
const [onlyMine, setOnlyMine] = useState(false);
Expand All @@ -26,6 +27,7 @@ const PlanktonDiscoveryStats = () => {
};

const { data, error } = await query;

if (error) return;

setTotalPlankton(data.length);
Expand Down
Loading

0 comments on commit f169998

Please sign in to comment.