Skip to content

Commit

Permalink
🍕🐰 ↝ [SGV2-76]: Missions now linked with components & confirmed to be…
Browse files Browse the repository at this point in the history
… working
  • Loading branch information
Gizmotronn committed Jun 15, 2024
1 parent 474f472 commit 18cc509
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 53 deletions.
45 changes: 2 additions & 43 deletions Classifications/ClassificationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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);
};
Expand Down
14 changes: 14 additions & 0 deletions Classifications/RoverContent/RoverImageClassification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ export const RoverClassificationFromItem32: React.FC<RoverClassificationFromItem
content: content,
})
.single();

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

const { error: missionError } = await supabase
.from('missions')
.insert([missionData]);

if (missionError) {
throw missionError;
};

if (error) {
throw error;
Expand Down
10 changes: 5 additions & 5 deletions app/api/gameplay/missions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ const missions: Mission[] = [
{ id: 7, name: "Build telescope", description: "Build a telescope & subsequent modules to learn more about your planet", rewards: [13]}, // Meaningless/stub reward
{ id: 8, name: "Make classification", description: "Classify the validity of your planet by looking at your TIC ID", rewards: [13, 13, 13, 16] ,}, // Gives the user the constituent parts to make a surveyor module for their telescope
{ id: 9, name: "Collect resources part 2", description: "Collect resources to build your mining station", rewards: []},
{ id: 10, name: "Build mining station", description: "By doing this you can now collect omega resources", rewards: []},
{ id: 10, name: "Build mining station", description: "By doing this you can now collect omega resources", rewards: []}, // Not included
{ id: 11, name: "Collect resources from station", description: "You can now build your cloud-spotting telescope!", rewards: []},
{ id: 12, name: "Build Meteorology tool", description: "You can now classify clouds on your planet!", rewards: []},
{ id: 13, name: "Create cloud classification", description: "You can now classify clouds on your planet!", rewards: []},
{ id: 14, name: "Collect resources for camera module", description: "You can now classify clouds on your planet!", rewards: []},
{ id: 15, name: "Craft camera module", description: "You can now classify clouds on your planet!", rewards: []},
{ id: 16, name: "Craft camera receiver station", description: "You can now classify clouds on your planet!", rewards: []},
{ id: 15, name: "Craft camera module", description: "You can now classify clouds on your planet!", rewards: []}, // Not included
{ id: 16, name: "Craft camera receiver station", description: "You can now classify clouds on your planet!", rewards: []}, // Not included
{ id: 17, name: "Collect a photo", description: "You can now classify clouds on your planet!", rewards: []},
{ id: 18, name: "Make classification of photo", description: "You can now classify clouds on your planet!", rewards: []},
{ id: 19, name: "Go mining for surveyor parts", description: "You can now classify clouds on your planet!", rewards: []},
{ id: 20, name: "Build surveyor structure", description: "You can now classify clouds on your planet!", rewards: []},
{ id: 19, name: "Go mining for surveyor parts", description: "You can now classify clouds on your planet!", rewards: []}, // Not included
{ id: 20, name: "Build surveyor structure", description: "You can now classify clouds on your planet!", rewards: []}, // Not included
{ id: 21, name: "Make surveyor classification", description: "You can now classify clouds on your planet!", rewards: []},
];

Expand Down
4 changes: 2 additions & 2 deletions app/missions/two/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function MissionGroupTwo() {
<SingleAutomatonCraftItem craftItemId={30} />
</Card>
<Card placeholder="" onPointerEnterCapture={() => {}} onPointerLeaveCapture={() => {}}>
<MiningStationPlaceable /> {/* target={11} /> */}
<MiningStationPlaceable missionId={11} />
</Card>
<Card placeholder="" onPointerEnterCapture={() => {}} onPointerLeaveCapture={() => {}}>
{/* <SingleAutomatonCraftItem craftItemId={26} /> */}
Expand All @@ -59,7 +59,7 @@ export default function MissionGroupTwo() {
<MeteorologyToolPlaceable />
</Card>
<Card placeholder="" onPointerEnterCapture={() => {}} onPointerLeaveCapture={() => {}}>
<MiningStationPlaceable />
<MiningStationPlaceable missionId={14}/>
</Card>
<Card placeholder="" onPointerEnterCapture={() => {}} onPointerLeaveCapture={() => {}}>
<CreateStructureWithItemRequirementinfo craftingItemId={31} />
Expand Down
2 changes: 1 addition & 1 deletion auth/UserProfileFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions components/Gameplay/Inventory/Automatons/Automaton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 15 additions & 1 deletion components/Gameplay/Inventory/Structures/Automatons/Modules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down
23 changes: 22 additions & 1 deletion components/Gameplay/Inventory/Structures/Mining.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<MiningStationPlaceableProps> = ({ missionId }) => {
const supabase = useSupabaseClient();
const session = useSession();

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -384,6 +403,8 @@ export default function MiningStationPlaceable() {
);
};

export default MiningStationPlaceable;

export const MiningStructureModal: React.FC<MiningStructureModalProps> = ({ isOpen, onClose, ownedItem, structure }) => {
const { activePlanet } = useActivePlanet();

Expand Down
14 changes: 14 additions & 0 deletions components/Gameplay/Inventory/Structures/Structure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions components/Gameplay/Inventory/Structures/Telescopes/Telescopes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 18cc509

Please sign in to comment.