Skip to content

Commit 2a5e5c9

Browse files
committed
🫘🎈 ↝ [SSM-57 SSM-55 SSM-56 SSM-40 SSC-30 SSM-54]: Mission guide with new content, views & configuration
1 parent 1cb47ff commit 2a5e5c9

File tree

11 files changed

+654
-236
lines changed

11 files changed

+654
-236
lines changed

app/api/gameplay/inventory/route.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const inventoryItems: InventoryItem[] = [
3838
{
3939
id: 3103, name: 'Telescope', description: 'Space-based observations & classifications', icon_url: '/assets/Items/Telescope.png', ItemCategory: 'Structure', locationType: 'Surface'
4040
},
41-
{
42-
id: 3104, name: "Zoodex", description: "Populate your planet with some animals to gain an understanding of animal behaviour on your planet and aide local research back home", cost: 1, icon_url: "/assets/Items/Pokedex.png", ItemCategory: "Structure", parentItem: null, itemLevel: 1, locationType: "Surface"
41+
{ // Previously referred to as #Zoodex-3104
42+
id: 3104, name: "Biodome", description: "Populate your planet with some animals to gain an understanding of animal behaviour on your planet and aide local research back home", cost: 1, icon_url: "/assets/Items/Pokedex.png", ItemCategory: "Structure", parentItem: null, itemLevel: 1, locationType: "Surface"
4343
},
4444
{
4545
id: 3105,

app/api/gameplay/missions/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface Mission {
1212
chapter?: number;
1313
component?: React.ComponentType<any>;
1414
};
15-
15+
1616
const missions: Mission[] = [
1717
// Chapter One Missions
1818
{

app/page.tsx

+3-8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import AllAutomatonsOnActivePlanet from "@/components/Structures/Auto/AllAutomat
3737
import { EarthViewLayout } from "@/components/(scenes)/planetScene/layout";
3838
import Onboarding from "./scenes/onboarding/page";
3939
import VerticalToolbar from "@/components/Layout/Toolbar";
40+
import StructureMissionGuide from "@/components/Layout/Guide";
4041

4142
export default function Home() {
4243
const session = useSession();
@@ -95,7 +96,7 @@ export default function Home() {
9596
<AllAutomatonsOnActivePlanet />
9697
</center>
9798
</div>
98-
<div className="w-full py-2">
99+
<div className="w-full py-2"><StructureMissionGuide />
99100
</div>
100101
</EarthViewLayout>
101102
// 60: <SaturnView />,
@@ -119,17 +120,11 @@ export default function Home() {
119120
);
120121
};
121122

122-
if (activePlanet?.id === null) {
123-
return (
124-
<Onboarding />
125-
);
126-
};
127-
128123
if (activePlanet?.id == 35) {
129124
return (
130125
<GlobeView />
131126
);
132127
};
133128

134-
return planetViews[activePlanet?.id] || <EarthView />;
129+
return planetViews[activePlanet?.id] || <Onboarding />;
135130
};

app/scenes/onboarding/page.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react";
2-
import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react";
32
import { EarthScene } from "../earth/scene";
43
import InitialiseChapterOneUser from "@/components/(scenes)/chapters/one/InitialiseUser";
54
import InventoryPage from "@/components/Inventory/Grid/Grid";
@@ -10,10 +9,10 @@ import VerticalToolbar from "@/components/Layout/Toolbar";
109
export default function Onboarding () {
1110
return (
1211
<EarthScene
13-
// topSection={<EnhancedWeatherEvents />}
12+
topSection={<EnhancedWeatherEvents />}
1413
middleSection={<MissionSelector />}
15-
toolbar={<VerticalToolbar />}
14+
// toolbar={<VerticalToolbar />}
1615
// bottomSection={<InventoryPage />}
1716
/>
18-
);
17+
);
1918
};

components/Data/ZoodexDataSources.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const zoodexDataSources = [
9393
export const telescopeDataSources = [
9494
{
9595
category: 'Planets',
96-
items: [
96+
items: [
9797
{
9898
name: 'Transiting Exoplanet Survey Satellite Search',
9999
description: 'Hunt for exoplanet candidates using lightcurve data',

components/Layout/Guide.tsx

+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
import React, { useEffect, useState } from "react";
2+
import { Button } from "../ui/button";
3+
import { Card, CardContent } from "../ui/card";
4+
import { motion, AnimatePresence } from "framer-motion";
5+
import { ChevronLeft, ChevronRight, CloudHail, HelpCircle, LightbulbIcon, Telescope, TreeDeciduous } from "lucide-react";
6+
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
7+
import MissionPathway from "../Missions/Pathway";
8+
9+
interface Mission {
10+
id: number;
11+
name: string;
12+
description: string;
13+
icon: React.ElementType;
14+
color: string;
15+
};
16+
17+
interface DialogueStep {
18+
text: string
19+
requiredMissions: string[]
20+
};
21+
22+
const astronomyMissions: Mission[] = [
23+
{
24+
id: 3000001 | 20000004 | 3000002,
25+
name: "Complete an astronomy mission using your telescope",
26+
description: "Click on the 'Telescope' structure to make some classifications",
27+
icon: Telescope,
28+
color: 'text-cyan-300',
29+
},
30+
{
31+
id: 10000001,
32+
name: "This is a test mission",
33+
description: 'Not needed',
34+
icon: LightbulbIcon,
35+
color: 'text-yellow-300',
36+
},
37+
];
38+
39+
const biologistMissions: Mission[] = [
40+
{
41+
id: 3000004 | 3000004,
42+
name: "Classify some animals using your Biodome",
43+
description: "Click on the 'Biodome' structure to make some classifications",
44+
icon: TreeDeciduous,
45+
color: 'text-green-300',
46+
},
47+
];
48+
49+
const meteorologyMissions: Mission[] = [
50+
{
51+
id: 3000010 | 20000007,
52+
name: "Study some weather events using your atmospheric probe",
53+
description: "Click on your LIDAR module to make some classifications",
54+
icon: CloudHail,
55+
color: 'text-blue-300',
56+
},
57+
];
58+
59+
// Research station - walk the user through this. Then upload data, verify/vet (consensus), then we introduce travel. Add a "close"/swipe-down option so that the tutorial section can be hidden/minimised. Then we go through the guide for the different views....and determine the differentials from Pathway.tsx and this new list
60+
// As well as researching for other projects/mission modules that aren't in `mission-selector`
61+
62+
const dialogueSteps: DialogueStep[] = [
63+
64+
];
65+
66+
export default function StructureMissionGuide() {
67+
const supabase = useSupabaseClient();
68+
const session = useSession();
69+
const [completedMissions, setCompletedMissions] = useState<number[]>([]);
70+
const [loading, setLoading] = useState(true);
71+
const [currentCategory, setCurrentCategory] = useState(0);
72+
const [minimized, setMinimized] = useState(false); // State to handle minimization
73+
74+
const categories = [
75+
{ missions: astronomyMissions, name: 'Astronomer' },
76+
{ missions: biologistMissions, name: 'Biologist' },
77+
{ missions: meteorologyMissions, name: 'Meteorologist' },
78+
];
79+
80+
useEffect(() => {
81+
async function fetchCompletedMissions() {
82+
if (!session?.user?.id) return;
83+
84+
const { data, error } = await supabase
85+
.from('missions')
86+
.select('mission')
87+
.eq('user', session.user.id);
88+
89+
if (error) {
90+
console.error("Error fetching completed missions:", error);
91+
} else {
92+
const completedMissionIds = data.map((mission: { mission: number }) => mission.mission);
93+
setCompletedMissions(completedMissionIds);
94+
}
95+
96+
setLoading(false);
97+
}
98+
99+
fetchCompletedMissions();
100+
}, [session, supabase]);
101+
102+
const handleNextCategory = () => {
103+
setCurrentCategory((prevCategory) => (prevCategory + 1) % categories.length);
104+
};
105+
106+
const handlePreviousCategory = () => {
107+
setCurrentCategory((prevCategory) => (prevCategory - 1 + categories.length) % categories.length);
108+
};
109+
110+
const toggleMinimize = () => {
111+
setMinimized(!minimized);
112+
};
113+
114+
return (
115+
<div className="p-4 max-w-6xl mx-auto font-mono">
116+
{minimized ? (
117+
<Button onClick={toggleMinimize} className="bg-blue-600 text-white flex items-center space-x-2">
118+
<HelpCircle className="w-5 h-5" />
119+
<span>Help</span>
120+
</Button>
121+
) : (
122+
<Card className="overflow-hidden relative bg-gradient-to-r from-gray-900 via-gray-800 to-gray-900 border-2 border-gray-700">
123+
<CardContent className="p-4">
124+
<div className="flex justify-between mb-4 items-center">
125+
{/* Mission Group Header */}
126+
<h2 className="text-xl font-semibold text-gray-300">
127+
Mission guide for {categories[currentCategory].name} pathway
128+
</h2>
129+
130+
<Button
131+
onClick={toggleMinimize}
132+
className="bg-gray-700 text-gray-300 hover:bg-gray-600 px-2 py-1 text-sm"
133+
>
134+
Minimize
135+
</Button>
136+
</div>
137+
138+
<div className="flex justify-between mb-4">
139+
<Button
140+
onClick={handlePreviousCategory}
141+
className="bg-gray-700 text-gray-300 hover:bg-gray-600 px-2 py-1 text-sm"
142+
>
143+
<ChevronLeft className="h-4 w-4" />
144+
</Button>
145+
<Button
146+
onClick={handleNextCategory}
147+
className="bg-blue-600 text-white hover:bg-blue-500 px-2 py-1 text-sm"
148+
>
149+
<ChevronRight className="h-4 w-4" />
150+
</Button>
151+
</div>
152+
153+
<div className="grid grid-cols-1 gap-2">
154+
{loading ? (
155+
<p>Loading missions...</p>
156+
) : (
157+
categories[currentCategory].missions.map((mission) => (
158+
<Card
159+
key={mission.id}
160+
className={`cursor-pointer hover:shadow-lg transition-all duration-300 ${
161+
completedMissions.includes(mission.id) ? 'bg-gray-700' : 'bg-gray-800'
162+
} border border-gray-600 relative overflow-hidden`}
163+
>
164+
<CardContent className="p-2 flex items-center">
165+
<mission.icon className={`w-6 h-6 mr-2 ${mission.color}`} />
166+
<div>
167+
<h3 className={`text-xs font-semibold ${mission.color}`}>{mission.name}</h3>
168+
{completedMissions.includes(mission.id) ? (
169+
<p className="text-xs text-gray-400 line-through decoration-dotted decoration-green-400">
170+
{mission.description}
171+
</p>
172+
) : (
173+
<p className="text-xs text-gray-400">{mission.description}</p>
174+
)}
175+
</div>
176+
</CardContent>
177+
</Card>
178+
))
179+
)}
180+
</div>
181+
</CardContent>
182+
</Card>
183+
)}
184+
</div>
185+
);
186+
};

components/Layout/Toolbar.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default function VerticalToolbar() {
2020

2121
return (
2222
<div className="z-50">
23-
{/* Desktop Toolbar */}
2423
<div className="hidden md:block fixed left-4 top-1/4 transform -translate-y-1/2">
2524
<nav className="bg-[#1E3A4C] rounded-xl shadow-lg backdrop-blur-md bg-opacity-80 p-2">
2625
<ul className="flex flex-col space-y-4">
@@ -30,16 +29,20 @@ export default function VerticalToolbar() {
3029
<a
3130
onMouseEnter={() => setHovered(label)}
3231
onMouseLeave={() => setHovered(null)}
33-
className={`flex items-center space-x-2 px-4 py-3 rounded-full transition-all duration-300
32+
className={`flex items-center px-4 py-3 rounded-full transition-all duration-300 relative
3433
${pathname === href
3534
? "bg-white text-[#1E3A4C] shadow-md"
3635
: "text-white hover:bg-white/10"}`}
3736
aria-label={label}
3837
>
3938
<Icon className="w-6 h-6" />
40-
{(pathname === href || hovered === label) && (
41-
<span className="text-sm font-medium">{label}</span>
42-
)}
39+
<span
40+
className={`absolute left-12 opacity-0 transition-opacity duration-300 ${
41+
hovered === label || pathname === href ? 'opacity-100' : ''
42+
} text-sm font-medium whitespace-nowrap bg-[#1E3A4C] bg-opacity-90 text-white px-2 py-1 rounded-md`}
43+
>
44+
{label}
45+
</span>
4346
</a>
4447
</Link>
4548
</li>
@@ -53,7 +56,6 @@ export default function VerticalToolbar() {
5356
</nav>
5457
</div>
5558

56-
{/* Mobile Toolbar with Gear Icon */}
5759
<div className="block md:hidden fixed left-4 bottom-4">
5860
<button
5961
onClick={() => setIsMenuOpen(!isMenuOpen)}
@@ -70,7 +72,7 @@ export default function VerticalToolbar() {
7072
<li key={label}>
7173
<Link legacyBehavior href={href}>
7274
<a
73-
onClick={() => setIsMenuOpen(false)} // Close menu after selection
75+
onClick={() => setIsMenuOpen(false)}
7476
className={`flex items-center space-x-2 px-4 py-3 rounded-full transition-all duration-300
7577
${pathname === href
7678
? "bg-white text-[#1E3A4C] shadow-md"

components/Missions/Pathway.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type MissionRoute = {
2828
researchStructureId?: number;
2929
inventoryStructureId?: number;
3030
route?: string;
31-
infoText?: string;
31+
infoText?: string;
3232
component?: React.ReactNode;
3333
planet: string;
3434
};

0 commit comments

Comments
 (0)