From 4f24a17ce526e8af8aad328316862dcd6b862383 Mon Sep 17 00:00:00 2001 From: Gizmotronn Date: Thu, 28 Nov 2024 12:55:01 +1100 Subject: [PATCH] =?UTF-8?q?=E2=9B=8F=EF=B8=8F=F0=9F=9A=9A=20=E2=86=9D=20[S?= =?UTF-8?q?SG-76=20SSG-70=20SSG-77=20SSP-39]:=20Mining=20for=2029.11.2024?= =?UTF-8?q?=20community=20expedition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scenes/mars/page.tsx | 10 +- components/(scenes)/planetScene/layout.tsx | 15 ++ components/(scenes)/travel/SolarSystem.tsx | 4 +- components/Inventory/items/ItemsOnPlanet.tsx | 2 +- components/mining-component.tsx | 259 +++++++++++++------ 5 files changed, 204 insertions(+), 86 deletions(-) diff --git a/app/scenes/mars/page.tsx b/app/scenes/mars/page.tsx index 4b368296..bb169f5c 100644 --- a/app/scenes/mars/page.tsx +++ b/app/scenes/mars/page.tsx @@ -4,7 +4,7 @@ import React, { useEffect, useState } from "react"; import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react"; import { useActivePlanet } from "@/context/ActivePlanet"; -import { EarthActionSceneLayout, EarthViewLayout } from "@/components/(scenes)/planetScene/layout"; +import { EarthActionSceneLayout, EarthViewLayout, MarsActionSceneLayout } from "@/components/(scenes)/planetScene/layout"; import InitialisePlanet from "@/components/(scenes)/planetScene/initialisePlanet"; import StructuresOnPlanet, { AtmosphereStructuresOnPlanet, OrbitalStructuresOnPlanet } from "@/components/Structures/Structures"; import { InventoryStructureItem } from "@/types/Items"; @@ -55,10 +55,10 @@ export default MarsView; const MarsStructures: React.FC = () => { return ( - - - - + + + + // //
//
diff --git a/components/(scenes)/planetScene/layout.tsx b/components/(scenes)/planetScene/layout.tsx index 9d5335f7..d2743f49 100644 --- a/components/(scenes)/planetScene/layout.tsx +++ b/components/(scenes)/planetScene/layout.tsx @@ -217,4 +217,19 @@ export const EarthActionSceneLayout: React.FC = ({ {children}
); +}; + +export const MarsActionSceneLayout: React.FC = ({ + children +}) => { + return ( +
+ Mars Background + {children} +
+ ); }; \ No newline at end of file diff --git a/components/(scenes)/travel/SolarSystem.tsx b/components/(scenes)/travel/SolarSystem.tsx index bb119d8a..74b783a7 100644 --- a/components/(scenes)/travel/SolarSystem.tsx +++ b/components/(scenes)/travel/SolarSystem.tsx @@ -583,11 +583,11 @@ export default function SwitchPlanet() { )} - {!missionSelected && ( + {/* {!missionSelected && (
- )} + )} */} )} diff --git a/components/Inventory/items/ItemsOnPlanet.tsx b/components/Inventory/items/ItemsOnPlanet.tsx index 3eb50b70..512b2e8b 100644 --- a/components/Inventory/items/ItemsOnPlanet.tsx +++ b/components/Inventory/items/ItemsOnPlanet.tsx @@ -75,7 +75,7 @@ const InventoryList = ({ anomaly }: InventoryListProps) => { return (
{filteredItems.length > 0 ? ( - filteredItems.map((item) => { + filteredItems.map((item) => { const apiItem = inventoryItems.find(apiItem => apiItem.id === item.item); return (
diff --git a/components/mining-component.tsx b/components/mining-component.tsx index 5fd2351e..d869fb68 100644 --- a/components/mining-component.tsx +++ b/components/mining-component.tsx @@ -262,7 +262,7 @@ export function MiningComponentComponent() { owner: session.user.id, quantity: minedAmount, anomaly: activePlanet.id, - configuration: { Uses: 1 }, + configuration: { Uses: 1, CommunityExpedition: "1 Mars 29 Nov 2024" }, }, ]) .select(); @@ -305,97 +305,200 @@ export function MiningComponentComponent() { } }; - return ( -
-
-

Mining Operations

- -
-
-
- {activeMap === '2D' ? ( - - ) : ( - - )} -
-
-
- {selectedDeposit ? ( -
-

Selected Deposit: {selectedDeposit.name}

-

Amount: {selectedDeposit.amount} units

- + return ( +
+
+
+

Mining Operations

+ +
+
+
+ {activeMap === '2D' ? ( + + ) : ( + + )} +
+
+
+ {selectedDeposit ? ( +
+

Selected Deposit

+

{selectedDeposit.name}

+ +
+ ) : ( +

Select a deposit to start mining.

+ )}
- ) : ( +
- )} + +
+ +
+ {activeLandmark && ( +
+
e.stopPropagation()} + > +

{activeLandmark.name}

+

{activeLandmark.description}

+ +
+
+ )}
-
- -
- {activeLandmark && ( - - )} -
- ); + ); }; -type LandmarkModalProps = { - landmark: Landmark | null; - isOpen: boolean; - onClose: () => void; -}; +// type LandmarkModalProps = { +// landmark: Landmark | null; +// isOpen: boolean; +// onClose: () => void; +// }; + +// const LandmarkModal: React.FC = ({ landmark, isOpen, onClose }) => { +// if (!isOpen || !landmark) return null; + +// return ( +//
+//
+// +//

{landmark.name}

+//

{landmark.description}

+//
+//
+// ); +// }; + +const MineralDepositsGenerator: React.FC = () => { + const supabase = useSupabaseClient(); + const session = useSession(); + const { activePlanet } = useActivePlanet(); + + const [classificationsCount, setClassificationsCount] = useState(0); + const [creatingDeposits, setCreatingDeposits] = useState(false); + const [mineralDeposits, setMineralDeposits] = useState([]); // Track created deposits + const [notification, setNotification] = useState(null); + + const availableMinerals = [11, 13, 15, 16, 18, 19]; + + useEffect(() => { + const fetchClassifications = async () => { + if (!session?.user?.id || !activePlanet?.id) { + console.error("User or activePlanet is undefined."); + return; + } + const { data: classifications, error } = await supabase + .from('classifications') + .select('*') + .eq('user', session.user.id) + .eq('planet_id', activePlanet.id); + + if (error) { + console.error("Error fetching classifications:", error); + } else { + console.log("Fetched classifications:", classifications); + // Make sure to set the classifications state correctly + } + }; + fetchClassifications(); + }, [session, activePlanet, supabase]); + + const handleCreateDeposits = async () => { + if (!session?.user?.id || !activePlanet?.id) { + console.error("User or activePlanet is undefined."); + return; + } + + // Randomly pick a mineral ID from availableMinerals + const randomMineral = availableMinerals[Math.floor(Math.random() * availableMinerals.length)]; + + const newDeposit = { + mineralconfiguration: { + mineral: randomMineral, // Use the mineral ID (number) + quantity: 100, + icon_url: `https://example.com/mineral-icon-${randomMineral}.png`, // Assuming different icons for each mineral + level: 1, + uses: ['Mining', 'Excavation'], + position: { x: Math.random() * 100, y: Math.random() * 100 } // Random position + }, + owner: session.user.id, + anomaly: activePlanet.id, + }; + + const { data, error } = await supabase + .from('mineralDeposits') + .insert([newDeposit]) + .select(); + + if (error) { + console.error("Error creating deposit:", error); + return; + } -const LandmarkModal: React.FC = ({ landmark, isOpen, onClose }) => { - if (!isOpen || !landmark) return null; + console.log("Created new deposit:", data); + // Optionally, update the local state to reflect the new deposit + setMineralDeposits(prevDeposits => [ + ...prevDeposits, + { ...newDeposit.mineralconfiguration, id: data[0].id } + ]); + }; return ( -
-
- -

{landmark.name}

-

{landmark.description}

+
+
+

Create Mineral Deposits

+

You have {classificationsCount} classifications. You can create up to 3 mineral deposits.

+
);