From 987e3ffb430266d446e96594558efbec3b7656a0 Mon Sep 17 00:00:00 2001 From: Gizmotronn Date: Mon, 11 Nov 2024 06:40:04 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=AD=F0=9F=9B=BC=20=E2=86=9D=20[SSG-65]?= =?UTF-8?q?:=20Removing=20some=20previous=20onboarding=20fluff=20and=20upd?= =?UTF-8?q?ating=20how=20telescope=20&=20zoodex=20structs.=20display=20the?= =?UTF-8?q?ir=20modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/page.tsx | 1 - app/scenes/earth/page.tsx | 1 - app/scenes/onboarding/page.tsx | 1 - app/scenes/planet/page.tsx | 3 - app/tests/page.tsx | 5 +- .../(scenes)/chapters/one/ChapterOneIntro.tsx | 115 ------- .../(scenes)/chapters/one/InitialiseUser.tsx | 324 ------------------ components/(scenes)/travel/SolarSystem.tsx | 48 +-- components/Data/ZoodexDataSources.tsx | 40 ++- components/Structures/Structures.tsx | 2 +- constants/Structures/Properties.tsx | 2 +- constants/Structures/Telescope.tsx | 81 +++++ constants/Structures/Zoodex.tsx | 72 ++++ 13 files changed, 212 insertions(+), 483 deletions(-) delete mode 100644 components/(scenes)/chapters/one/ChapterOneIntro.tsx delete mode 100644 components/(scenes)/chapters/one/InitialiseUser.tsx create mode 100644 constants/Structures/Telescope.tsx create mode 100644 constants/Structures/Zoodex.tsx diff --git a/app/page.tsx b/app/page.tsx index c0f22602..d901e3dc 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -29,7 +29,6 @@ import { VenusView } from './scenes'; import GlobeView from "./scenes/globe/page"; -import InitialiseChapterOneUser from "@/components/(scenes)/chapters/one/InitialiseUser"; import { EarthScene } from "./scenes/earth/scene"; import StructuresOnPlanet, { AtmosphereStructuresOnPlanet, OrbitalStructuresOnPlanet } from "@/components/Structures/Structures"; import EnhancedWeatherEvents from "@/components/enhanced-weather-events"; diff --git a/app/scenes/earth/page.tsx b/app/scenes/earth/page.tsx index 86a4ba19..ebf17661 100644 --- a/app/scenes/earth/page.tsx +++ b/app/scenes/earth/page.tsx @@ -11,7 +11,6 @@ import StructuresOnPlanet, { OrbitalStructuresOnPlanet, } from "@/components/Structures/Structures"; import AllAutomatonsOnActivePlanet from "@/components/Structures/Auto/AllAutomatons"; -import InitialiseChapterOneUser from "@/components/(scenes)/chapters/one/InitialiseUser"; import InventoryPage from "@/components/Inventory/Grid/Grid"; import EnhancedWeatherEventsComponent from "@/components/enhanced-weather-events"; import TopographicMap from "@/components/topographic-map"; diff --git a/app/scenes/onboarding/page.tsx b/app/scenes/onboarding/page.tsx index 1143158f..8e13c400 100644 --- a/app/scenes/onboarding/page.tsx +++ b/app/scenes/onboarding/page.tsx @@ -1,6 +1,5 @@ import React from "react"; import { EarthScene } from "../earth/scene"; -import InitialiseChapterOneUser from "@/components/(scenes)/chapters/one/InitialiseUser"; import InventoryPage from "@/components/Inventory/Grid/Grid"; import EnhancedWeatherEvents from "@/components/enhanced-weather-events"; import MissionSelector from "@/components/mission-selector"; diff --git a/app/scenes/planet/page.tsx b/app/scenes/planet/page.tsx index 1a873ac3..d6ee7257 100644 --- a/app/scenes/planet/page.tsx +++ b/app/scenes/planet/page.tsx @@ -6,7 +6,6 @@ import { useActivePlanet } from "@/context/ActivePlanet"; import PlanetViewLayout from "@/components/(scenes)/planetScene/layout"; import StructuresOnPlanet, { AtmosphereStructuresOnPlanet, OrbitalStructuresOnPlanet } from "@/components/Structures/Structures"; import { InventoryStructureItem } from "@/types/Items"; -import ChapterOneIntroduction from "@/components/(scenes)/chapters/one/ChapterOneIntro"; import { PlanetarySystem } from "@/components/(scenes)/planetScene/orbitals/system"; // import { BottomMenuBar } from "@/app/components/sections/bottomMenuBar"; import AllAutomatonsOnActivePlanet from "@/components/Structures/Auto/AllAutomatons"; @@ -81,7 +80,6 @@ export default function PlanetViewPage() {
-
); } @@ -102,7 +100,6 @@ export default function PlanetViewPage() { {isGuidePopupVisible && (
- -
- - ); -}; \ No newline at end of file diff --git a/components/(scenes)/chapters/one/InitialiseUser.tsx b/components/(scenes)/chapters/one/InitialiseUser.tsx deleted file mode 100644 index e0c0ca66..00000000 --- a/components/(scenes)/chapters/one/InitialiseUser.tsx +++ /dev/null @@ -1,324 +0,0 @@ -"use client"; - -import React, { useState, useEffect } from "react"; -import { motion, AnimatePresence } from "framer-motion"; -import { ChevronRight, ChevronLeft } from "lucide-react"; - -import { zoodexDataSources, telescopeDataSources, lidarDataSources } from "@/components/Data/ZoodexDataSources"; -import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; -import { useActivePlanet } from "@/context/ActivePlanet"; - -interface Category { - title: string; - description: string; - details: { name: string; description: string; techId: number; tutorialMission: number; activeStructure: number; identifier: string; }[]; -} - -const combineCategories = (): Category[] => { - return [ - { - title: "Biological Projects", // Zoodex - description: "Explore biological research projects related to animals and biodiversity.", - details: zoodexDataSources.flatMap(source => source.items.map(item => ({ - name: item.name, - description: item.description, - tutorialMission: item.tutorialMission, - activeStructure: item.activeStructure, - identifier: item.identifier, - techId: item.techId, - }))), - }, - { - title: "Space Investigations", // Telescope - description: "Dive into astronomical research focused on planets, stars, and cosmic phenomena.", - details: telescopeDataSources.flatMap(source => source.items.map(item => ({ - name: item.name, - description: item.description, - tutorialMission: item.tutorialMission, - activeStructure: item.activeStructure, - identifier: item.identifier, - techId: item.techId, - }))), - }, - { - title: "Meteorological Studies", // Lidar - description: "Study weather patterns and cloud formations on various planets.", - details: lidarDataSources.flatMap(source => source.items.map(item => ({ - name: item.name, - description: item.description, - tutorialMission: item.tutorialMission, - activeStructure: item.activeStructure, - identifier: item.identifier, - techId: item.techId, - }))), - }, - ]; -}; - -export default function InitialiseChapterOneUser() { - const supabase = useSupabaseClient(); - const session = useSession(); - - const { activePlanet, updatePlanetLocation } = useActivePlanet(); - - const [step, setStep] = useState(0); - const [selectedCategory, setSelectedCategory] = useState(null); - const [selectedMission, setSelectedMission] = useState<{ - [x: string]: any; name: string; tutorialMission: number; activeStructure: number; identifier: string -} | null>(null); - const [isManualProgress, setIsManualProgress] = useState(false); - const [activeTutorialMission, setActiveTutorialMission] = useState(null); - const [confirmationMessage, setConfirmationMessage] = useState(null); - - const categories = combineCategories(); - - const introSteps = [ - "Welcome to Star Sailors!", - "Join us on a journey across the cosmos to discover and catalogue unique anomalies and help real scientists with their research", - "You'll be starting your training on Earth. You'll be able to choose to work on any projects you'd like - let's pick your first now!" - ]; - - useEffect(() => { - if (step < introSteps.length && !isManualProgress) { - const timer = setTimeout(() => setStep(step + 1), 4500); - return () => clearTimeout(timer); - } - }, [step, isManualProgress]); - - const handleBack = () => { - if (step > 0) { - setStep(step - 1); - } else { - setIsManualProgress(true); - } - - setSelectedCategory(null); - setSelectedMission(null); - setConfirmationMessage(null); - }; - - const handleNext = () => { - if (step < introSteps.length - 1) { - setStep(step + 1); - } else if (step === introSteps.length - 1) { - setStep(introSteps.length); - } - }; - - const handleCategoryClick = (category: Category) => { - setSelectedCategory(category); - setSelectedMission(null); - setConfirmationMessage(null); - }; - - const handleMissionSelect = (mission: { name: string; techId: number; tutorialMission: number; activeStructure: number; identifier: string }) => { - setSelectedMission(mission); - setActiveTutorialMission(mission.tutorialMission); - setConfirmationMessage(null); - }; - - const handleBackToCategories = () => { - setSelectedCategory(null); - }; - - const handleConfirmMission = async () => { - if (!session?.user?.id || !selectedMission) return; - - const initialiseUserMissionData = { - user: session.user.id, - time_of_completion: new Date().toISOString(), - mission: 10000001, - }; - - const chooseFirstClassificationMissionData = { - user: session.user.id, - time_of_completion: new Date().toISOString(), - mission: 10000002, - }; - - const structureCreationData = { - owner: session?.user.id, - item: selectedMission.activeStructure, - quantity: 1, - notes: "Created for user's first classification", - anomaly: activePlanet?.id || 69, - configuration: { - "Uses": 10, - "missions unlocked": [selectedMission.identifier], - }, - }; - - const researchedStructureData = { - user_id: session?.user.id, - tech_type: selectedMission.activeStructure, - tech_id: selectedMission.techId, - created_at: new Date().toISOString(), - }; - - try { - updatePlanetLocation(69); - const { error: missionError1 } = await supabase - .from('missions') - .insert([initialiseUserMissionData]); - - if (missionError1) { - throw missionError1; - }; - - const { error: missionError2 } = await supabase - .from('missions') - .insert([chooseFirstClassificationMissionData]); - - if (missionError2) { - throw missionError2; - }; - - const { error: inventoryError } = await supabase - .from("inventory") - .insert([structureCreationData]); - - if (inventoryError) { - throw inventoryError; - }; - - const { error: researchedError } = await supabase - .from("researched") - .insert([researchedStructureData]); - - setConfirmationMessage("Mission confirmed and added successfully!"); - } catch (error: any) { - setConfirmationMessage(`Error: ${error.message}`); - }; - }; - - return ( -
- -
-
- - {step < introSteps.length ? ( - - - {introSteps[step]} - - - ) : selectedCategory ? ( - selectedMission ? ( - -

- {selectedMission.name} -

-

Part of ({selectedCategory.description})

- - {confirmationMessage && ( -

{confirmationMessage}

- )} -
- ) : ( - -

- {selectedCategory.title} -

-

{selectedCategory.description}

-
    - {selectedCategory.details.map((mission, idx) => ( -
  • handleMissionSelect(mission)} - className="p-4 bg-[#364C61] hover:bg-[#2C3A4A] rounded-lg cursor-pointer transition-colors duration-300" - > - {mission.name} -
  • - ))} -
- -
- ) - ) : ( - -

- Choose a Project Category -

-
    - {categories.map((category, idx) => ( -
  • handleCategoryClick(category)} - className="p-4 bg-[#364C61] hover:bg-[#2C3A4A] rounded-lg cursor-pointer transition-colors duration-300" - > - {category.title} -
  • - ))} -
-
- )} -
-
-
- - {step < introSteps.length - 1 && ( - - )} -
-
-
- ); -}; \ No newline at end of file diff --git a/components/(scenes)/travel/SolarSystem.tsx b/components/(scenes)/travel/SolarSystem.tsx index 0fb9152c..e23131a3 100644 --- a/components/(scenes)/travel/SolarSystem.tsx +++ b/components/(scenes)/travel/SolarSystem.tsx @@ -312,29 +312,33 @@ export default function SwitchPlanet() { if (planetType) { const filterCompatibleMissions = () => { - const zoodexMissions = zoodexDataSources.flatMap((category) => - category.items.filter((item) => item.compatiblePlanetTypes.includes(planetType)) - ); - const physicsLabMissions = physicsLabDataSources.flatMap((category) => - category.items.filter((item) => item.compatiblePlanetTypes.includes(planetType)) - ); - const telescopeMissions = telescopeDataSources.flatMap((category) => - category.items.filter((item) => item.compatiblePlanetTypes.includes(planetType)) - ); - const roverMissions = roverDataSources.flatMap((category) => - category.items.filter((item) => item.compatiblePlanetTypes.includes(planetType)) - ); - const lidarMissions = lidarDataSources.flatMap((category) => - category.items.filter((item) => item.compatiblePlanetTypes.includes(planetType)) - ); - setCompatibleMissions([ - ...zoodexMissions, - ...physicsLabMissions, - ...telescopeMissions, - ...roverMissions, - ...lidarMissions, - ]); + const planetType = currentPlanet?.planetType; + if (planetType) { + // const zoodexMissions = zoodexDataSources.flatMap((category) => + // category.items.filter((item) => item.compatiblePlanetTypes.includes(planetType)) + // ); + const physicsLabMissions = physicsLabDataSources.flatMap((category) => + category.items.filter((item) => item.compatiblePlanetTypes.includes(planetType)) + ); + const telescopeMissions = telescopeDataSources.flatMap((category) => + category.items.filter((item) => item.compatiblePlanetTypes.includes(planetType)) + ); + const roverMissions = roverDataSources.flatMap((category) => + category.items.filter((item) => item.compatiblePlanetTypes.includes(planetType)) + ); + const lidarMissions = lidarDataSources.flatMap((category) => + category.items.filter((item) => item.compatiblePlanetTypes.includes(planetType)) + ); + setCompatibleMissions([ + // ...zoodexMissions, + ...physicsLabMissions, + ...telescopeMissions, + ...roverMissions, + ...lidarMissions, + ]); + } }; + filterCompatibleMissions(); }; diff --git a/components/Data/ZoodexDataSources.tsx b/components/Data/ZoodexDataSources.tsx index 8519d2c9..2027132f 100644 --- a/components/Data/ZoodexDataSources.tsx +++ b/components/Data/ZoodexDataSources.tsx @@ -1,8 +1,19 @@ 'use client'; -import { CloudDrizzleIcon, SunDimIcon, TelescopeIcon, TestTube } from 'lucide-react'; +import { CameraIcon, CloudDrizzleIcon, DogIcon, MicroscopeIcon, SunDimIcon, TelescopeIcon, TestTube } from 'lucide-react'; import { BurrowingOwlIcon } from '../../content/Icons/BurrowingOwl'; import { FishIcon } from '../../content/Icons/FishIcon'; +import { StarterTelescope } from '../Projects/Telescopes/Transiting'; +import { DailyMinorPlanet } from '../Projects/Telescopes/DailyMinorPlanet'; +import { PlanetFourProject } from '../Projects/Satellite/PlanetFour'; +import { TelescopeSunspotDetector } from '../Projects/Telescopes/Sunspots'; +import { TelescopeDiskDetector } from '../Projects/Telescopes/DiskDetector'; +import { StarterZoodexGallery } from '../Projects/Zoodex/ClassifyOthersAnimals'; +import CameraComponent from '../Projects/Zoodex/Upload/Camera'; +import { DataSourcesModal } from './unlockNewDataSources'; +import { BurrowingOwl } from '../Projects/Zoodex/burrowingOwls'; +import { PenguinWatch } from '../Projects/Zoodex/penguinWatch'; +import { ZoodexIguanas } from '../Projects/Zoodex/iguanasFromAbove'; export const zoodexDataSources = [ { @@ -100,7 +111,6 @@ export const telescopeDataSources = [ identifier: 'telescope-tess', researchId: 'planet-hunters-tess', researcher: 'zooniverse', - // icon: TelescopeIcon, unlocked: false, compatiblePlanetTypes: ['Lush', 'Frozen', 'Hellhole', 'Arid'], bestPlanetType: ['Lush', 'Frozen', 'Hellhole', 'Arid'], @@ -108,9 +118,9 @@ export const telescopeDataSources = [ activeStructure: 3103, researched: 'telescope-tess', techId: 1, - }, - // Other (non-transiting) planet candidates here e.g. microlensing, radial velocity - ], + dynamicComponent: + } + ] }, { category: 'Solar System Objects', @@ -128,6 +138,7 @@ export const telescopeDataSources = [ activeStructure: 3103, researched: 'telescope-minorPlanets', techId: 1, + dynamicComponent: }, { name: 'Planet Four', @@ -142,8 +153,9 @@ export const telescopeDataSources = [ activeStructure: 3103, researched: 'satellite-planetFour', techId: 1, - }, - ], + dynamicComponent: + } + ] }, { category: 'Solar observations', @@ -154,7 +166,6 @@ export const telescopeDataSources = [ identifier: 'telescope-sunspots', researchId: 'sunspot-detectives', researcher: 'zooniverse/teolixx', - // icon: SunDimIcon, unlocked: false, compatiblePlanetTypes: ['Lush', 'Frozen', 'Hellhole', 'Arid'], bestPlanetType: ['Lush', 'Frozen', 'Hellhole', 'Arid'], @@ -162,8 +173,9 @@ export const telescopeDataSources = [ activeStructure: 3103, researched: 'telescope-sunspots', techId: 5, - }, - ], + dynamicComponent: + } + ] }, { category: 'exo-Solar System Observations', @@ -181,11 +193,13 @@ export const telescopeDataSources = [ activeStructure: 3103, researched: 'telescope-diskDetective', techId: 5, - }, - ], - }, + dynamicComponent: + } + ] + } ]; + export const lidarDataSources = [ { category: 'Clouds', diff --git a/components/Structures/Structures.tsx b/components/Structures/Structures.tsx index f6c3d5f7..5f66588b 100644 --- a/components/Structures/Structures.tsx +++ b/components/Structures/Structures.tsx @@ -112,7 +112,7 @@ export default function StructuresOnPlanet() {

); - }; + }; return (
diff --git a/constants/Structures/Properties.tsx b/constants/Structures/Properties.tsx index befd70fe..a382c63a 100644 --- a/constants/Structures/Properties.tsx +++ b/constants/Structures/Properties.tsx @@ -121,7 +121,7 @@ export const StructuresConfig: StructureConfig = { // showInNoModal: false, // }, ], - }, + }, 3103: { name: "Transiting Telescope", labels: [ diff --git a/constants/Structures/Telescope.tsx b/constants/Structures/Telescope.tsx new file mode 100644 index 00000000..962cf5a7 --- /dev/null +++ b/constants/Structures/Telescope.tsx @@ -0,0 +1,81 @@ +import React, { useEffect, useState } from "react"; +import { telescopeDataSources } from "@/components/Data/ZoodexDataSources"; +import { TelescopeIcon } from "lucide-react"; +import { useActivePlanet } from "@/context/ActivePlanet"; +import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; + +const TelescopeComponent: React.FC = () => { + const supabase = useSupabaseClient(); + const session = useSession(); + const { activePlanet } = useActivePlanet(); + + const [configuration, setConfiguration] = useState(null); + const [hasTelescope, setHasTelescope] = useState(true); + const [selectedProject, setSelectedProject] = useState(null); + + useEffect(() => { + const fetchConfiguration = async () => { + if (!session || !activePlanet) { + return; + } + + const { data: inventoryData, error } = await supabase + .from('inventory') + .select('*') + .eq('owner', session.user.id) + .eq('item', 3103) + .eq('anomaly', activePlanet.id); + + if (inventoryData && inventoryData.length > 0) { + setConfiguration(inventoryData[0].configuration); + } else { + setHasTelescope(false); + } + }; + fetchConfiguration(); + }, [session, activePlanet, supabase]); + + if (!hasTelescope) { + return
You don't have a telescope in your inventory.
; + } + + if (!configuration) { + return
Loading configuration...
; + } + + const unlockedMissions = configuration['missions unlocked'] || []; + const availableProjects = telescopeDataSources + .flatMap(category => category.items) + .filter(project => unlockedMissions.includes(project.identifier)); + + return ( +
+

Telescope Projects

+
+ {availableProjects.length > 0 ? ( + availableProjects.map((project, index) => ( + + )) + ) : ( +

No missions unlocked yet for this telescope.

+ )} +
+ + {selectedProject && ( +
+

{selectedProject.name}

+ {selectedProject.dynamicComponent} +
+ )} +
+ ); +}; + +export default TelescopeComponent; \ No newline at end of file diff --git a/constants/Structures/Zoodex.tsx b/constants/Structures/Zoodex.tsx new file mode 100644 index 00000000..852748f8 --- /dev/null +++ b/constants/Structures/Zoodex.tsx @@ -0,0 +1,72 @@ +import React, { useEffect, useState } from "react"; +import { useActivePlanet } from "@/context/ActivePlanet"; +import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; +import { BirdIcon } from "lucide-react"; +import { zoodexDataSources } from "@/components/Data/ZoodexDataSources"; + +const ZoodexComponent: React.FC = () => { + const supabase = useSupabaseClient(); + const session = useSession(); + const { activePlanet } = useActivePlanet(); + const [configuration, setConfiguration] = useState(null); + const [hasZoodex, setHasZoodex] = useState(true); + + useEffect(() => { + const fetchConfiguration = async () => { + if (!session || !activePlanet) { + return; + } + + const { data: inventoryData, error } = await supabase + .from('inventory') + .select('*') + .eq('owner', session.user.id) + .eq('item', 3104) + .eq('anomaly', activePlanet.id); + + if (inventoryData && inventoryData.length > 0) { + setConfiguration(inventoryData[0].configuration); + } else { + setHasZoodex(false); + } + }; + fetchConfiguration(); + }, [session, activePlanet, supabase]); + + if (!hasZoodex) { + return
You don't have a Zoodex in your inventory.
; + } + + if (!configuration) { + return
Loading configuration...
; + } + + const unlockedMissions = configuration['missions unlocked'] || []; + // const availableProjects = zoodexDataSources + // .flatMap(category => category.items) + // .filter(project => unlockedMissions.includes(project.identifier)); + + return ( +
+

Zoodex Projects

+
+ {/* {availableProjects.length > 0 ? ( + availableProjects.map((project, index) => ( + + )) + ) : ( +

No missions unlocked yet for this Zoodex.

+ )} */} +
+
+ ); +}; + +export default ZoodexComponent; \ No newline at end of file