Skip to content

Commit a67a619

Browse files
committed
Merge branch 'apollo2'
# Conflicts: # src/components/ProfileModal.tsx
2 parents efb10bf + c42c690 commit a67a619

6 files changed

Lines changed: 137 additions & 35 deletions

File tree

package-lock.json

Lines changed: 25 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/OrbitSystem.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { AlienProfile } from '../data/mockAliens';
44
import { useAppContext } from '../context/AppContext';
55
import ProfileModal from './ProfileModal';
66
import MatchOverlay from './MatchOverlay';
7+
import { getCompatibility } from '../utils/compatibility';
78

89
export default function OrbitSystem() {
910
const { preferences, addMatch, matches } = useAppContext();
@@ -25,6 +26,10 @@ export default function OrbitSystem() {
2526
!activeIds.includes(a.id)
2627
);
2728

29+
// Sort available aliens by compatibility descending, so the queue is ordered
30+
// from highest match to lowest match. The next alien pulled will always be the highest remaining match.
31+
available.sort((a, b) => getCompatibility(b, preferences) - getCompatibility(a, preferences));
32+
2833
let changed = false;
2934
const newActiveIds = [...activeIds];
3035

@@ -159,11 +164,12 @@ export default function OrbitSystem() {
159164
</div>
160165

161166
{/* Orbit Rings and Aliens */}
162-
{activeIds.map((id, i) => {
163-
if (!id) return null; // If no alien is available for this slot, don't render it
164-
165-
const alien = mockAliens.find(a => a.id === id);
166-
if (!alien) return null;
167+
{activeIds
168+
.map(id => id ? mockAliens.find(a => a.id === id) : null)
169+
.filter((a): a is AlienProfile => a !== null && a !== undefined)
170+
// Sort by compatibility descending so the highest match is in the innermost track
171+
.sort((a, b) => getCompatibility(b, preferences) - getCompatibility(a, preferences))
172+
.map((alien, i) => {
167173

168174
// Assign each slot to a distinct track (0 to 4)
169175
const rx = 120 + (i * 65);

src/components/ProfileModal.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useState, useEffect } from 'react';
22
import type { AlienProfile } from '../data/mockAliens';
33
import { X, Heart, Info, Globe, Wind } from 'lucide-react';
4+
import { useAppContext } from '../context/AppContext';
5+
import { getCompatibility } from '../utils/compatibility';
46

57
interface ProfileModalProps {
68
alien: AlienProfile;
@@ -11,6 +13,8 @@ interface ProfileModalProps {
1113

1214
export default function ProfileModal({ alien, onClose, onMatch, onDismiss }: ProfileModalProps) {
1315
const [swipeDirection, setSwipeDirection] = useState<'left' | 'right' | null>(null);
16+
const { preferences } = useAppContext();
17+
const compatibility = getCompatibility(alien, preferences);
1418

1519
useEffect(() => {
1620
setSwipeDirection(null);
@@ -119,13 +123,13 @@ export default function ProfileModal({ alien, onClose, onMatch, onDismiss }: Pro
119123

120124
{/* Compatibility Badge */}
121125
<div style={{
122-
background: `linear-gradient(135deg, ${alien.compatibilityPercent >= 80 ? 'var(--color-primary), var(--color-secondary)' : 'rgba(234, 222, 218, 0.2), rgba(234, 222, 218, 0.1)'})`,
126+
background: `linear-gradient(135deg, ${compatibility >= 80 ? 'var(--color-primary), var(--color-secondary)' : 'rgba(234, 222, 218, 0.2), rgba(234, 222, 218, 0.1)'})`,
123127
padding: '8px 16px',
124128
borderRadius: '20px',
125129
fontWeight: 'bold',
126-
boxShadow: alien.compatibilityPercent >= 80 ? '0 4px 15px rgba(217, 3, 104, 0.4)' : 'none'
130+
boxShadow: compatibility >= 80 ? '0 4px 15px rgba(217, 3, 104, 0.4)' : 'none'
127131
}}>
128-
{alien.compatibilityPercent.toFixed(1)}% Match
132+
{compatibility.toFixed(1)}% Match
129133
</div>
130134
</div>
131135

src/data/mockAliens.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const mockAliens: AlienProfile[] = [
2323
{
2424
id: "alien-1",
2525
name: "Glaxion",
26-
alienType: "Neon Synth",
26+
alienType: "Alien",
2727
limbs: 4,
2828
size: "Medium",
2929
distanceAU: 4.2,
@@ -39,7 +39,7 @@ export const mockAliens: AlienProfile[] = [
3939
{
4040
id: "alien-2",
4141
name: "Zorblax",
42-
alienType: "Aquatic Siren",
42+
alienType: "Alien",
4343
limbs: 8,
4444
size: "Small",
4545
distanceAU: 12.8,
@@ -55,7 +55,7 @@ export const mockAliens: AlienProfile[] = [
5555
{
5656
id: "alien-3",
5757
name: "Vex'tar",
58-
alienType: "Draconian",
58+
alienType: "Alien",
5959
limbs: 4,
6060
size: "Large",
6161
distanceAU: 1.5,
@@ -71,7 +71,7 @@ export const mockAliens: AlienProfile[] = [
7171
{
7272
id: "alien-4",
7373
name: "Crystalia",
74-
alienType: "Crystalline Entity",
74+
alienType: "Alien",
7575
limbs: 4,
7676
size: "Medium",
7777
distanceAU: 25.4,
@@ -87,7 +87,7 @@ export const mockAliens: AlienProfile[] = [
8787
{
8888
id: "alien-5",
8989
name: "Spore'rel",
90-
alienType: "Fungal Sporeling",
90+
alienType: "Alien",
9191
limbs: 6,
9292
size: "Small",
9393
distanceAU: 8.9,
@@ -103,7 +103,7 @@ export const mockAliens: AlienProfile[] = [
103103
{
104104
id: "alien-6",
105105
name: "Lyra",
106-
alienType: "Plasma Being",
106+
alienType: "Alien",
107107
limbs: 0,
108108
size: "Medium",
109109
distanceAU: 55.0,
@@ -119,7 +119,7 @@ export const mockAliens: AlienProfile[] = [
119119
{
120120
id: "alien-7",
121121
name: "Lumina",
122-
alienType: "Celestial Guide",
122+
alienType: "Hybrid",
123123
limbs: 4,
124124
size: "Large",
125125
distanceAU: 12.4,
@@ -135,7 +135,7 @@ export const mockAliens: AlienProfile[] = [
135135
{
136136
id: "alien-8",
137137
name: "Zarok",
138-
alienType: "High Councilor",
138+
alienType: "Hybrid",
139139
limbs: 4,
140140
size: "Medium",
141141
distanceAU: 8.1,
@@ -151,7 +151,7 @@ export const mockAliens: AlienProfile[] = [
151151
{
152152
id: "alien-9",
153153
name: "Squish",
154-
alienType: "Forest Slime",
154+
alienType: "Alien",
155155
limbs: 0,
156156
size: "Small",
157157
distanceAU: 3.3,
@@ -167,7 +167,7 @@ export const mockAliens: AlienProfile[] = [
167167
{
168168
id: "alien-10",
169169
name: "Xeno",
170-
alienType: "Apex Predator",
170+
alienType: "Alien",
171171
limbs: 4,
172172
size: "Colossal",
173173
distanceAU: 35.0,
@@ -183,7 +183,7 @@ export const mockAliens: AlienProfile[] = [
183183
{
184184
id: "alien-11",
185185
name: "Cyra",
186-
alienType: "Void Walker",
186+
alienType: "Hybrid",
187187
limbs: 4,
188188
size: "Medium",
189189
distanceAU: 66.6,
@@ -199,7 +199,7 @@ export const mockAliens: AlienProfile[] = [
199199
{
200200
id: "alien-12",
201201
name: "Ignis",
202-
alienType: "Royal Envoy",
202+
alienType: "Human",
203203
limbs: 4,
204204
size: "Medium",
205205
distanceAU: 2.1,
@@ -215,7 +215,7 @@ export const mockAliens: AlienProfile[] = [
215215
{
216216
id: "alien-13",
217217
name: "Sparky",
218-
alienType: "Luminous Sprite",
218+
alienType: "Alien",
219219
limbs: 4,
220220
size: "Small",
221221
distanceAU: 18.9,
@@ -231,7 +231,7 @@ export const mockAliens: AlienProfile[] = [
231231
{
232232
id: "alien-14",
233233
name: "Kaelen",
234-
alienType: "Jungle Prince",
234+
alienType: "Human",
235235
limbs: 4,
236236
size: "Medium",
237237
distanceAU: 9.5,

src/utils/compatibility.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import type { AlienProfile } from '../data/mockAliens';
2+
import type { UserPreferences } from '../context/AppContext';
3+
4+
// Size proximity
5+
const sizeOrder = ['Small', 'Medium', 'Large', 'Colossal'];
6+
7+
// Type proximity
8+
const typeOrder = ['Human', 'Hybrid', 'Alien'];
9+
10+
export function getCompatibility(alien: AlienProfile, prefs: UserPreferences | null): number {
11+
if (!prefs) return 50.0;
12+
13+
let score = 40; // Base score
14+
15+
// Size Match (max 25)
16+
if (prefs.size === alien.size) {
17+
score += 25;
18+
} else if (prefs.size === 'No preference' || !prefs.size) {
19+
score += 20;
20+
} else {
21+
const userSizeIdx = sizeOrder.indexOf(prefs.size);
22+
const alienSizeIdx = sizeOrder.indexOf(alien.size);
23+
if (userSizeIdx !== -1 && alienSizeIdx !== -1) {
24+
const diff = Math.abs(userSizeIdx - alienSizeIdx);
25+
if (diff === 1) score += 15; // Close
26+
else if (diff === 2) score += 5; // Farther
27+
// diff of 3 is 0 points
28+
}
29+
}
30+
31+
// Type Match (max 25)
32+
if (prefs.alienType === 'Open to all' || !prefs.alienType) {
33+
score += 20;
34+
} else if (prefs.alienType === alien.alienType) {
35+
score += 25;
36+
} else {
37+
const userTypeIdx = typeOrder.indexOf(prefs.alienType);
38+
const alienTypeIdx = typeOrder.indexOf(alien.alienType);
39+
if (userTypeIdx !== -1 && alienTypeIdx !== -1) {
40+
const diff = Math.abs(userTypeIdx - alienTypeIdx);
41+
if (diff === 1) score += 15; // Human -> Hybrid, or Hybrid -> Alien
42+
}
43+
}
44+
45+
// Distance Match (max 10)
46+
if (prefs.maxDistanceAU > 0) {
47+
const distanceScore = Math.max(0, 1 - (alien.distanceAU / prefs.maxDistanceAU));
48+
score += distanceScore * 10;
49+
} else {
50+
score += 5;
51+
}
52+
53+
// Cap between 10.0 and 99.9
54+
return Math.min(99.9, Math.max(10.0, Math.round(score * 10) / 10));
55+
}

0 commit comments

Comments
 (0)