Skip to content

Commit

Permalink
🪹🏋🏻‍♀️ ↝ [SSG-28 SSP-21 SSG-22 SSM-10]: Completed mission & inventory…
Browse files Browse the repository at this point in the history
… configuration for launchpad mission group
  • Loading branch information
Gizmotronn committed Oct 4, 2024
1 parent 412b6c9 commit 9e2fd0c
Show file tree
Hide file tree
Showing 7 changed files with 366 additions and 181 deletions.
11 changes: 10 additions & 1 deletion app/api/gameplay/missions/planets/initialisation/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NextRequest, NextResponse } from "next/server";
// import { Mission } from "@/types/Missions";

export interface Mission {
id: number;
Expand Down Expand Up @@ -80,6 +79,16 @@ const planetInitialisationMissions: Mission[] = [
name: "Initialise Saturn",
anomaly: 60,
},
{
id: 600011,
name: "Initialise Enceladus",
anomaly: 61,
},
{
id: 600021,
name: "Initialise Titan",
anomaly: 62,
},
{
id: 700001,
name: "Initialise Uranus",
Expand Down
2 changes: 1 addition & 1 deletion app/api/gameplay/missions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const missions: Mission[] = [
{
id: 100000005,
name: "Pick new planet and travel",
},
}, // Plus planet initialisation missions

// Any resource collection missions...

Expand Down
168 changes: 87 additions & 81 deletions app/components/(scenes)/planetScene/SwitchPlanet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,78 +77,78 @@ const planets = [
planetType: 'Arid',
initialisationMissionId: 400001,
},
// {
// id: 50,
// name: "Jupiter",
// color: "bg-orange-300",
// stats: { gravity: "24.79 m/s²", temp: "-108°C" },
// anomaly: 50,
// planetType: 'Arid',
// initialisationMissionId: null,
// },
// {
// id: 55,
// name: "Europa",
// color: "bg-blue-200",
// stats: { gravity: "1.31 m/s²", temp: "-160°C" },
// anomaly: 51,
// planetType: 'Arid',
// initialisationMissionId: null,
// },
// {
// id: 52,
// name: "Io",
// color: "bg-yellow-400",
// stats: { gravity: "1.79 m/s²", temp: "-143°C" },
// anomaly: 52,
// planetType: 'Arid',
// initialisationMissionId: null,
// },
// {
// id: 51,
// name: "Amalthea",
// color: "bg-red-400",
// stats: { gravity: "0.026 m/s²", temp: "-113°C" },
// anomaly: 53,
// planetType: 'Arid',
// initialisationMissionId: null,
// },
// {
// id: 60,
// name: "Saturn",
// color: "bg-yellow-600",
// stats: { gravity: "10.44 m/s²", temp: "-139°C" },
// anomaly: 60,
// planetType: 'Arid',
// initialisationMissionId: 600001,
// },
// {
// id: 61,
// name: "Enceladus",
// color: "bg-white",
// stats: { gravity: "0.113 m/s²", temp: "-201°C" },
// anomaly: 61,
// planetType: 'Arid',
// initialisationMissionId: null,
// },
// {
// id: 70,
// name: "Uranus",
// color: "bg-cyan-300",
// stats: { gravity: "8.69 m/s²", temp: "-197°C" },
// anomaly: 70,
// planetType: 'Arid',
// initialisationMissionId: 700001,
// },
// {
// id: 80,
// name: "Neptune",
// color: "bg-blue-700",
// stats: { gravity: "11.15 m/s²", temp: "-214°C" },
// anomaly: 80,
// planetType: 'Arid',
// initialisationMissionId: 800001,
// },
{
id: 50,
name: "Jupiter",
color: "bg-orange-300",
stats: { gravity: "24.79 m/s²", temp: "-108°C" },
anomaly: 50,
planetType: 'Arid',
initialisationMissionId: null,
},
{
id: 55,
name: "Europa",
color: "bg-blue-200",
stats: { gravity: "1.31 m/s²", temp: "-160°C" },
anomaly: 51,
planetType: 'Arid',
initialisationMissionId: null,
},
{
id: 52,
name: "Io",
color: "bg-yellow-400",
stats: { gravity: "1.79 m/s²", temp: "-143°C" },
anomaly: 52,
planetType: 'Arid',
initialisationMissionId: null,
},
{
id: 51,
name: "Amalthea",
color: "bg-red-400",
stats: { gravity: "0.026 m/s²", temp: "-113°C" },
anomaly: 53,
planetType: 'Arid',
initialisationMissionId: null,
},
{
id: 60,
name: "Saturn",
color: "bg-yellow-600",
stats: { gravity: "10.44 m/s²", temp: "-139°C" },
anomaly: 60,
planetType: 'Arid',
initialisationMissionId: 600001,
},
{
id: 61,
name: "Enceladus",
color: "bg-white",
stats: { gravity: "0.113 m/s²", temp: "-201°C" },
anomaly: 61,
planetType: 'Arid',
initialisationMissionId: null,
},
{
id: 70,
name: "Uranus",
color: "bg-cyan-300",
stats: { gravity: "8.69 m/s²", temp: "-197°C" },
anomaly: 70,
planetType: 'Arid',
initialisationMissionId: 700001,
},
{
id: 80,
name: "Neptune",
color: "bg-blue-700",
stats: { gravity: "11.15 m/s²", temp: "-214°C" },
anomaly: 80,
planetType: 'Arid',
initialisationMissionId: 800001,
},
];

const usePlanetSwitcher = (initialIndex = 0) => {
Expand Down Expand Up @@ -273,7 +273,7 @@ export function PlanetSwitcher() {

const moveItemsToNewPlanet = async (newPlanetId: number) => {
if (session?.user?.id) {
const itemsToMove = [3108, 3107]; // Rocket and Launchpad item IDs
const itemsToMove = [3108, 3107];

try {
await Promise.all(
Expand All @@ -296,18 +296,29 @@ export function PlanetSwitcher() {

const handlePlanetClick = async (planet: any) => {
if (planet.anomaly !== activePlanet?.id) {
await moveItemsToNewPlanet(planet.anomaly); // Move items before changing the planet
const { error: missonsError } = await supabase
.from('missions')
.insert([initialisePlanetMissionData]);

await moveItemsToNewPlanet(planet.anomaly);
updatePlanetLocation(planet.anomaly);
}
};
};

const isVisited = classificationsByPlanet[currentPlanet.anomaly]?.length > 0;
const planetDetails = planetStats?.find((planet) => planet.id === currentPlanet.initialisationMissionId);
const initialisationMission = currentPlanet.initialisationMissionId;

const initialisePlanetMissionData = {
user: session?.user.id,
time_of_completion: new Date().toISOString(),
mission: initialisationMission,
};

return (
<div className="flex items-center justify-center text-white p-4">
<div className="w-full max-w-md">
<div className="relative overflow-hidden">
<div className="">
<AnimatePresence mode="wait">
<motion.div
key={currentPlanet.name}
Expand Down Expand Up @@ -385,11 +396,6 @@ export function PlanetSwitcher() {
<p>You haven't visited this planet yet.</p>
)}
</div>
{planetDetails?.planetType ? (
<MissionList planetType={planetDetails.planetType} />
) : (
<p>Planet type information not available.</p>
)}
{planetDetails?.planetType ? (
<MissionList planetType={planetDetails.planetType} />
) : (
Expand Down
Loading

0 comments on commit 9e2fd0c

Please sign in to comment.