import config from "@payload-config"; import { getPayload } from "payload"; import { headers as nextHeaders } from "next/headers"; import Link from "next/link"; import { ArrowLeftIcon, ScaleIcon } from "lucide-react"; import { getRelationContext } from "@/lib/intelligence/factionRelationLedger"; import { formatScore, pairKey, relationBand, RELATION_BANDS, RELATION_BAND_CLASSES, } from "@/lib/intelligence/factionRelations"; export const metadata = { title: "Faction Relations | Polaris Task Force", }; const TYPE_ORDER: Record = { playerFaction: 0, majorFaction: 1, minorFaction: 2, corporation: 3, special: 4, }; export default async function FactionRelationsPage() { const payload = await getPayload({ config }); const { user } = await payload.auth({ headers: await nextHeaders(), canSetHeaders: false, }); const context = await getRelationContext(payload, user); // Player faction first, then majors down to specials, so the matrix reads in // the same order the faction list uses. const factions = [...context.factions].sort( (a, b) => (TYPE_ORDER[a.type] ?? 99) - (TYPE_ORDER[b.type] ?? 99), ); return (
Back to Factions

Faction Relations

Each row reads how that faction currently regards each column, accumulated from recorded events. The two directions of a relationship are independent, so one faction can respect another that despises it.

Scale {RELATION_BANDS.map((band) => ( {band.label} ))}
{factions.length === 0 ? (

No factions found.

) : (
{factions.map((faction) => ( ))} {factions.map((subject) => ( {factions.map((target) => { if (target.id === subject.id) { return ( ); } const score = context.scores.get(pairKey(subject.id, target.id)) ?? 0; const band = relationBand(score); return ( ); })} ))}
Regards {faction.name}
{subject.name} - {formatScore(score)}
)}

Entries are recorded from the admin panel under Intelligence, Relation Entries. Scores are clamped to -100..100, and a zero can mean a clean slate or events that cancelled out.

); }