From 18cc509531f2cec5c536a1af8152e99e3d0acfd0 Mon Sep 17 00:00:00 2001 From: Liam Arbuckle Date: Sun, 16 Jun 2024 00:05:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=95=F0=9F=90=B0=20=E2=86=9D=20[SGV2-76?= =?UTF-8?q?]:=20Missions=20now=20linked=20with=20components=20&=20confirme?= =?UTF-8?q?d=20to=20be=20working?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classifications/ClassificationForm.tsx | 45 +------------------ .../RoverContent/RoverImageClassification.tsx | 14 ++++++ app/api/gameplay/missions/route.ts | 10 ++--- app/missions/two/page.tsx | 4 +- auth/UserProfileFields.tsx | 2 +- .../Inventory/Automatons/Automaton.tsx | 16 +++++++ .../Structures/Automatons/Modules.tsx | 16 ++++++- .../Gameplay/Inventory/Structures/Mining.tsx | 23 +++++++++- .../Inventory/Structures/Structure.tsx | 14 ++++++ .../Structures/Telescopes/Telescopes.tsx | 14 ++++++ 10 files changed, 105 insertions(+), 53 deletions(-) diff --git a/Classifications/ClassificationForm.tsx b/Classifications/ClassificationForm.tsx index 2627511a..872982e2 100644 --- a/Classifications/ClassificationForm.tsx +++ b/Classifications/ClassificationForm.tsx @@ -513,46 +513,9 @@ export function CreateFirstMeteorologyClassification(assetMentioned: any) { // F const missionData = { user: session?.user?.id, time_of_completion: new Date().toISOString(), - mission: 8, + mission: 13, configuration: null, - rewarded_items: [13, 13, 13, 16], - }; - - const inventoryData = { - item: missionData.rewarded_items[0], - owner: session?.user?.id, - quantity: 1, - notes: "Created upon the completion of mission 8", - parentItem: null, - time_of_deploy: new Date().toISOString(), - anomaly: activePlanet?.id, - }; - const inventoryData2 = { - item: missionData.rewarded_items[1], - owner: session?.user?.id, - quantity: 1, - notes: "Created upon the completion of mission 8", - parentItem: null, - time_of_deploy: new Date().toISOString(), - anomaly: activePlanet?.id, - }; - const inventoryData3 = { - item: missionData.rewarded_items[2], - owner: session?.user?.id, - quantity: 1, - notes: "Created upon the completion of mission 8", - parentItem: null, - time_of_deploy: new Date().toISOString(), - anomaly: activePlanet?.id, - }; - const inventoryData4 = { - item: missionData.rewarded_items[3], - owner: session?.user?.id, - quantity: 1, - notes: "Created upon the completion of mission 8", - parentItem: null, - time_of_deploy: new Date().toISOString(), - anomaly: activePlanet?.id, + rewarded_items: [1], }; const newAnomalyData = { @@ -569,10 +532,6 @@ export function CreateFirstMeteorologyClassification(assetMentioned: any) { // F const { data: newAnomaly, error: newAnomalyError } = await supabase .from("user_anomalies") .insert([newAnomalyData]); - - const { data: newInventoryEntry, error: newInventoryEntryError } = await supabase - .from("inventory") - .insert([inventoryData, inventoryData2, inventoryData3, inventoryData4]); } catch (error: any) { console.error(error); }; diff --git a/Classifications/RoverContent/RoverImageClassification.tsx b/Classifications/RoverContent/RoverImageClassification.tsx index 511d5f13..6efc9961 100644 --- a/Classifications/RoverContent/RoverImageClassification.tsx +++ b/Classifications/RoverContent/RoverImageClassification.tsx @@ -38,6 +38,20 @@ export const RoverClassificationFromItem32: React.FC {}} onPointerLeaveCapture={() => {}}> - {/* target={11} /> */} + {}} onPointerLeaveCapture={() => {}}> {/* */} @@ -59,7 +59,7 @@ export default function MissionGroupTwo() { {}} onPointerLeaveCapture={() => {}}> - + {}} onPointerLeaveCapture={() => {}}> diff --git a/auth/UserProfileFields.tsx b/auth/UserProfileFields.tsx index 190b70ea..62ae679d 100644 --- a/auth/UserProfileFields.tsx +++ b/auth/UserProfileFields.tsx @@ -85,7 +85,7 @@ export function ProfileCard() { if (profileError) { throw profileError; } - + // Mark mission 2 as complete const missionId = 2; const mission = missions.find(m => m.id === missionId); diff --git a/components/Gameplay/Inventory/Automatons/Automaton.tsx b/components/Gameplay/Inventory/Automatons/Automaton.tsx index 0d09a1ed..ccdb7bf5 100644 --- a/components/Gameplay/Inventory/Automatons/Automaton.tsx +++ b/components/Gameplay/Inventory/Automatons/Automaton.tsx @@ -854,6 +854,22 @@ export function SingleAutomatonCraftItem({ craftItemId }: { craftItemId: number const craftItem = inventoryItems.find(item => item.id === craftItemId); if (!craftItem?.recipe) return; + if (craftItemId === 30) { + const missionData = { + user: session?.user?.id, + time_of_completion: new Date().toISOString(), + mission: 9, + }; + + const { error: missionError } = await supabase + .from('missions') + .insert([missionData]); + + if (missionError) { + throw missionError; + }; + }; + for (const [resourceId, requiredQuantity] of Object.entries(craftItem.recipe)) { const userResource = userItems.find(item => item.item === parseInt(resourceId)); if (userResource) { diff --git a/components/Gameplay/Inventory/Structures/Automatons/Modules.tsx b/components/Gameplay/Inventory/Structures/Automatons/Modules.tsx index 9a7d763f..a9da1243 100644 --- a/components/Gameplay/Inventory/Structures/Automatons/Modules.tsx +++ b/components/Gameplay/Inventory/Structures/Automatons/Modules.tsx @@ -284,7 +284,7 @@ export const CameraReceiverStation: React.FC = () => { const { data, error } = await supabase .from("anomalies") .insert({ - id: "9", + id: "10", content: `Rover image by ${session.user.id}`, anomalytype: 'roverImg', avatar_url: image, @@ -293,6 +293,20 @@ export const CameraReceiverStation: React.FC = () => { created_at: new Date() }); + const missionData = { + user: session?.user?.id, + time_of_completion: new Date().toISOString(), + mission: 17, + }; + + const { error: missionError } = await supabase + .from('missions') + .insert([missionData]); + + if (missionError) { + throw missionError; + }; + if (error) { throw error; } diff --git a/components/Gameplay/Inventory/Structures/Mining.tsx b/components/Gameplay/Inventory/Structures/Mining.tsx index 6d487300..e13c37e6 100644 --- a/components/Gameplay/Inventory/Structures/Mining.tsx +++ b/components/Gameplay/Inventory/Structures/Mining.tsx @@ -133,7 +133,11 @@ const imageUrl = `${supabaseUrl}/storage/v1/object/public/citiAnomalies/${active ); }; -export default function MiningStationPlaceable() { +interface MiningStationPlaceableProps { + missionId: number; +} + +const MiningStationPlaceable: React.FC = ({ missionId }) => { const supabase = useSupabaseClient(); const session = useSession(); @@ -186,6 +190,21 @@ export default function MiningStationPlaceable() { notes: `Reward from mining station id: ${userStructure[0].ownedItem?.id}`, }, ]); + + + const missionData = { + user: session?.user?.id, + time_of_completion: new Date().toISOString(), + mission: missionId, + }; + + const { error: missionError } = await supabase + .from('missions') + .insert([missionData]); + + if (missionError) { + throw missionError; + }; if (insertError) { throw insertError; @@ -384,6 +403,8 @@ export default function MiningStationPlaceable() { ); }; +export default MiningStationPlaceable; + export const MiningStructureModal: React.FC = ({ isOpen, onClose, ownedItem, structure }) => { const { activePlanet } = useActivePlanet(); diff --git a/components/Gameplay/Inventory/Structures/Structure.tsx b/components/Gameplay/Inventory/Structures/Structure.tsx index 6686c82e..8999f7c5 100644 --- a/components/Gameplay/Inventory/Structures/Structure.tsx +++ b/components/Gameplay/Inventory/Structures/Structure.tsx @@ -539,6 +539,20 @@ export function CreateStructureWithItemRequirementinfo({ craftingItemId }: { cra const { error } = await supabase .from("inventory") .insert([{ item: craftItem.id, owner: session?.user.id, quantity: 1, anomaly: activePlanet?.id }]); + + const missionData = { + user: session?.user?.id, + time_of_completion: new Date().toISOString(), + mission: 12, + }; + + const { error: missionError } = await supabase + .from('missions') + .insert([missionData]); + + if (missionError) { + throw missionError; + }; if (error) { throw error; diff --git a/components/Gameplay/Inventory/Structures/Telescopes/Telescopes.tsx b/components/Gameplay/Inventory/Structures/Telescopes/Telescopes.tsx index 65f9a819..0fbd476d 100644 --- a/components/Gameplay/Inventory/Structures/Telescopes/Telescopes.tsx +++ b/components/Gameplay/Inventory/Structures/Telescopes/Telescopes.tsx @@ -108,6 +108,20 @@ export const SurveyorStructureModal: React.FC = () => { } ]); + const missionData = { + user: session?.user?.id, + time_of_completion: new Date().toISOString(), + mission: 21, + }; + + const { error: missionError } = await supabase + .from('missions') + .insert([missionData]); + + if (missionError) { + throw missionError; + }; + if (error) { throw error; }