Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔩🎾 ↝ [SSG-50]: Community station initialisation #162

Merged
merged 17 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
bd5ca03
🥋🍾 ↝ [SSM-24 SSM-22]: Starting module for Lidar/JVH
Gizmotronn Oct 20, 2024
fd830b5
🥑📇 ↝ [SSM-22]: Content & formulae for DMP, P4, AI4M
Gizmotronn Oct 21, 2024
af58b39
⛳️🪱 ↝ [SSM-30]: Scaffolding for community station components
Gizmotronn Oct 22, 2024
5d589a4
🐟🩳 ↝ [SSM-30]: Forking UnownedStructures in EditMode.tsx for Communit…
Gizmotronn Oct 22, 2024
f89d120
👙🧌 ↝ [SSM-30 SSM-31]: Working on global view of community stations
Gizmotronn Oct 22, 2024
78c1268
🦃🧞 ↝ [SSM-30 SSM-31]: Stations are now being created with p/m config
Gizmotronn Oct 23, 2024
00fbefe
🥣📯 ↝ [SSM-1 SSM-30 SSM-31]: Stations are now displaying their configu…
Gizmotronn Oct 23, 2024
ec4f11d
🗑️🤾🏻‍♂️ ↝ [SSM-33 SSM-34]: Projects can now be unlocked in community …
Gizmotronn Oct 23, 2024
b55e4c5
🏝️⚙️ ↝ [SSM-33 SSM-34 SSG-51]: Some new cm ideas & fixing some buildt…
Gizmotronn Oct 23, 2024
2c0b791
🔩🤽🏻‍♂️ ↝ [SSG-30 SSG-52 SSM-32]: Some basic UI/component hotfixes and…
Gizmotronn Oct 24, 2024
57216fa
🗽🌧️ ↝ [SSM-28 SSM-1 SSM-32]: Starting with the field guide UI for res…
Gizmotronn Oct 24, 2024
56fb789
🐱🍀️ ↝ [SSM-28 SSM-49 SSM-15]: Field guide to restart tutorial and som…
Gizmotronn Oct 25, 2024
4e9c657
🪹🪢️ ↝ [SSM-51 SSG-57 SSG-56 SSG-54 SSM-15]: More UI bugs fixed around…
Gizmotronn Oct 25, 2024
d456810
🥼🦷 ↝ [SSM-16 SSM-21]: Feed now shows configuration & anomalies data w…
Gizmotronn Oct 26, 2024
e3d9c90
👄🥻 ↝ [SSM-53 SSM-22 SSM-38 SSM-23]: Tutorial for DMP and trying (fail…
Gizmotronn Oct 26, 2024
92b6e38
💇🏻🏄🏼‍♀️ ↝ [SSM-15 SSM-38]: Community missions are presented alongside…
Gizmotronn Oct 26, 2024
755523d
🛷🌙 ↝ [SSM-1 SSM-39 SSM-35 SSM-36]: Some final UI, documentation fixes…
Gizmotronn Oct 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
60 changes: 60 additions & 0 deletions app/api/gameplay/communityStations/projects/31011/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { NextRequest, NextResponse } from 'next/server';

interface Project {
id: string;
name: string;
identifier: string;
missionRoute: number;
};

interface Mission {
id: string;
name: string;
type: string;
project: string;
missionRouteId?: number;
};

interface CommunityStationConfig {
stationName: string;
inventoryItemId: number;
projects: Project[];
missions: Mission[];
};

const greenhouseStation: CommunityStationConfig = {
stationName: "Greenhouse",
inventoryItemId: 31011,
projects: [
{
id: "1",
name: "Wildwatch Burrowing Owls",
identifier: "zoodex-burrOwls",
missionRoute: 3000002,
},
{
id: "2",
name: "Iguanas from Above",
identifier: "zoodex-iguanasFromAbove",
missionRoute: 3000004,
},
],
missions: [
{
id: "1",
name: "Spot an owl in the wild",
type: "Upload",
project: "1",
},
{
id: "2",
name: "Track iguana movement",
type: "Analysis",
project: "2",
},
],
};

export async function GET(req: NextRequest) {
return NextResponse.json(greenhouseStation);
};
110 changes: 110 additions & 0 deletions app/api/gameplay/communityStations/projects/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { NextRequest, NextResponse } from 'next/server';
import React from 'react';

import { BurrowingOwl } from '@/components/Projects/Zoodex/burrowingOwls';
import { ZoodexIguanas } from '@/components/Projects/Zoodex/iguanasFromAbove';

interface Project {
id: string;
name: string;
identifier: string;
component: React.ComponentType;
missionRoute: number;
structure: string;
// isUnlocked: boolean; // Uncomment if needed
// level: number; // Uncomment if needed
}

interface Mission {
id: string;
name: string;
type: string;
// completionRate: number; // Uncomment if needed
project: string;
// level: number; // Uncomment if needed
// isUnlocked: boolean; // Uncomment if needed
}

interface CommunityStationConfig {
stationName: string;
inventoryItemId: number;
projects: Project[];
missions: Mission[];
}

const greenhouseStation: CommunityStationConfig = {
stationName: "Greenhouse",
inventoryItemId: 31011,
projects: [
{
id: "1",
name: "Wildwatch Burrowing Owls",
identifier: "zoodex-burrowingOwls",
component: BurrowingOwl,
structure: "Zoodex",
missionRoute: 3000002,
},
{
id: "2",
name: "Iguanas from Above",
identifier: "zoodex-iguanasFromAbove",
component: ZoodexIguanas,
structure: "Zoodex",
missionRoute: 3000004,
},
],
missions: [
{
id: "1",
name: "Spot an owl in the wild",
type: "Upload",
project: "1",
},
{
id: "2",
name: "Track iguana movement",
type: "Analysis",
project: "2",
},
],
};

const weatherBalloonStation: CommunityStationConfig = {
stationName: "Weather balloon",
inventoryItemId: 31012,
projects: [],
missions: [
{
id: "1",
name: "Determine planet type to allow for population of relevant anomalies, and then attribute some clouds",
type: "Upload",
project: "1",
},
],
};

const spaceTelescopeStation: CommunityStationConfig = {
stationName: "Space telescope",
inventoryItemId: 31013,
projects: [],
missions: [
{
id: "1",
name: "Map planet type based on lightcurve information", // and then we can attribute/participate other missions/projects",
type: "Upload",
project: "1",
},
],
};

export async function GET(req: NextRequest) {
const response = {
stations: [
greenhouseStation,
weatherBalloonStation,
spaceTelescopeStation,
],
};

return NextResponse.json(response);
};
28 changes: 27 additions & 1 deletion app/api/gameplay/inventory/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface InventoryItem {
description: string;
cost?: number;
icon_url: string;
ItemCategory: string;
ItemCategory: string;
parentItem?: number | null;
itemLevel?: number;
locationType?: string;
Expand Down Expand Up @@ -84,6 +84,32 @@ const inventoryItems: InventoryItem[] = [
ItemCategory: "Structure",
locationType: 'Surface',
},

// Community stations
{
id: 31011,
name: "Greenhouse",
description: "Collect and study biological anomalies across multiple locations",
icon_url: "/assets/Items/Greenhouse.png",
ItemCategory: 'CommunityStation',
locationType: 'Surface',
},
{
id: 31012,
name: "Weather balloon",
description: "Collect and study weather events and entities more closely in your planet's atmosphere",
icon_url: "/assets/Items/WeatherBalloon.png",
ItemCategory: 'CommunityStation',
locationType: 'Atmosphere',
},
{
id: 31013,
name: "Space Telescope",
description: "Collect & compare discoveries more readily per-location", // to-update
icon_url: "/assets/Items/SpaceTelescope.png",
ItemCategory: 'CommunityStation',
locationType: 'Orbital',
},

// Tests
{
Expand Down
49 changes: 49 additions & 0 deletions app/auth/onlineUsers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use client';

import React, { useState, useEffect } from "react";
import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react";

export default function OnlineUserList() {
const supabase = useSupabaseClient();
const session = useSession(); // Session must be loaded first
const [onlineUsers, setOnlineUsers] = useState(0);

useEffect(() => {
// Wait until session is ready
if (!session?.user?.id) return;

const roomOne = supabase.channel('room_01', {
config: {
presence: {
key: session.user.id, // Ensure session user id is used correctly
},
},
});

roomOne
.on('presence', { event: 'sync' }, () => {
const currentPresenceState = roomOne.presenceState();
const onlineUsersCount = Object.keys(currentPresenceState).length;
setOnlineUsers(onlineUsersCount);
})
.on('presence', { event: 'join' }, ({ key, newPresences }) => {
console.log('User joined:', key, newPresences);
})
.on('presence', { event: 'leave' }, ({ key, leftPresences }) => {
console.log('User left:', key, leftPresences);
})
.subscribe();

// Clean up the subscription on unmount
return () => {
roomOne.unsubscribe();
};
}, [session?.user?.id, supabase]);

return (
<div className="flex items-center gap-1">
<div className="h-4 w-4 bg-green-500 rounded-full animate-pulse"></div>
<h1 className='text-sm text-gray-400'>{onlineUsers} Online</h1>
</div>
);
};
3 changes: 2 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { Analytics } from "@vercel/analytics/react"
import { MissionProvider } from "@/context/MissionContext";
import TutorialPopup from "../content/Dialogue/helpButton";
import AppLayout from "@/components/Layout/Layout";
import Header from "@/components/ui/Header";

interface RootLayoutProps {
children: ReactNode;
}
};

export default function RootLayout({ children }: RootLayoutProps) {
const [supabaseClient] = useState(() => createPagesBrowserClient());
Expand Down
2 changes: 0 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"use client"

import { OnboardingLayout } from "@/components/Template";
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
import { Landing } from "@/components/landing";
import { useEffect, useState } from "react";
import LoginPage from "./auth/LoginModal";
import OnboardingWindow from "../components/(scenes)/chapters/(onboarding)/window";
Expand Down
10 changes: 9 additions & 1 deletion app/scenes/globe/Structures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { StructuresConfigForSandbox } from "@/constants/Structures/SandboxProper
import { InventoryStructureItem, StructureItemDetail } from "@/types/Items";
import { useActivePlanet } from "@/context/ActivePlanet";
import "../../../styles/Anims/StarterStructureAnimations.css";
import { CreateCommunityStation } from "@/components/Structures/Build/MakeCommunityStation";

interface StructuresOnPlanetProps {
onStructuresFetch: (
Expand Down Expand Up @@ -105,6 +106,9 @@ export default function StructuresOnPlanet({ onStructuresFetch }: StructuresOnPl

return (
<div className="relative">
<div className="mx-3">
<CreateCommunityStation />
</div>
<div className={`grid grid-cols-3 gap-1 gap-y-3 relative ${userStructuresOnPlanet.length === 1 ? 'justify-center' : ''}`}>
{userStructuresOnPlanet.map((structure) => {
const itemDetail = itemDetails.get(structure.item);
Expand Down Expand Up @@ -136,7 +140,11 @@ export default function StructuresOnPlanet({ onStructuresFetch }: StructuresOnPl
onClose={handleClose}
/>
)}
<UnownedSurfaceStructures />
<div className="m">
<div className="mx-3">
<UnownedSurfaceStructures />
</div>
</div>
</div>
);
};
Loading
Loading