Compare commits
4 commits
9a0b78fcf0
...
969ca75a70
| Author | SHA1 | Date | |
|---|---|---|---|
| 969ca75a70 | |||
| c65fd436b1 | |||
| 32365e6612 | |||
| db98adbcee |
10 changed files with 39293 additions and 25 deletions
20
CHANGELOG.md
20
CHANGELOG.md
|
|
@ -1,5 +1,25 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
# v0.8.1
|
||||||
|
|
||||||
|
Threat estimates now read at a glance on the mission page, a Discord release-notes command ships, and the Labor Crew panel loads correctly again.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- **Threat assessment.** Staff can now estimate how likely the unit is to meet each enemy force type. From the new Intelligence tab on a mission, add rows pairing a force type with a likelihood (Very Unlikely to Very Likely). The mission page renders it as a color-coded dossier table, shaded from slate to red by severity, with a smart icon per force type (helicopter, plane, armor, infantry, and more). Leave the list empty to hide the table.
|
||||||
|
|
||||||
|
- **Release notes for Discord.** A new `/changelog` command posts release notes straight to Discord, so the community sees what shipped without opening the site.
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- The `/changelog` command now supports version ranges, so release notes can span a set of tags.
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- **Labor Crew panel loads.** The game-structures panel for Labor Crews was not loading its data correctly and now renders as intended.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
# v0.8.0
|
# v0.8.0
|
||||||
|
|
||||||
This release is about helping the community grow. You can now earn XP for contributing, the wiki got a fresh new look, and the world map is simpler to browse.
|
This release is about helping the community grow. You can now earn XP for contributing, the wiki got a fresh new look, and the world map is simpler to browse.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "polaris-task-force",
|
"name": "polaris-task-force",
|
||||||
"version": "0.8.0",
|
"version": "0.8.1",
|
||||||
"description": "Web app for the Arma 3 unit Polaris Task Force. Uses Next.js for client- and server-side rendering, with a Postgres database and some other neat libraries.",
|
"description": "Web app for the Arma 3 unit Polaris Task Force. Uses Next.js for client- and server-side rendering, with a Postgres database and some other neat libraries.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import { MissionObjectives } from "@/components/frontend/intelligence/MissionObj
|
||||||
import { hasPermission } from "@/utils/access-control/hasPermission";
|
import { hasPermission } from "@/utils/access-control/hasPermission";
|
||||||
import { redactText } from "@/lib/redaction";
|
import { redactText } from "@/lib/redaction";
|
||||||
import { MissionFactions } from "@/components/frontend/intelligence/MissionFactions";
|
import { MissionFactions } from "@/components/frontend/intelligence/MissionFactions";
|
||||||
|
import { MissionThreatAssessment } from "@/components/frontend/intelligence/MissionThreatAssessment";
|
||||||
import { MissionRoles } from "@/components/frontend/intelligence/MissionRoles";
|
import { MissionRoles } from "@/components/frontend/intelligence/MissionRoles";
|
||||||
import { MissionRoleSignups } from "@/components/frontend/intelligence/MissionRoleSignups";
|
import { MissionRoleSignups } from "@/components/frontend/intelligence/MissionRoleSignups";
|
||||||
import { MissionLogistics } from "@/components/frontend/intelligence/MissionLogistics";
|
import { MissionLogistics } from "@/components/frontend/intelligence/MissionLogistics";
|
||||||
|
|
@ -506,6 +507,11 @@ export default async function MissionDetailPage({ params }: MissionDetailPagePro
|
||||||
</ItemContent>
|
</ItemContent>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
|
<MissionThreatAssessment
|
||||||
|
likelihoods={mission.threatAssessment?.likelihoods ?? null}
|
||||||
|
missionId={mission.id}
|
||||||
|
/>
|
||||||
|
|
||||||
<MissionBriefingSection briefing={mission.briefing ?? null} />
|
<MissionBriefingSection briefing={mission.briefing ?? null} />
|
||||||
|
|
||||||
<MissionObjectives
|
<MissionObjectives
|
||||||
|
|
|
||||||
|
|
@ -757,6 +757,57 @@ export const Missions: CollectionConfig = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Intelligence",
|
||||||
|
description:
|
||||||
|
"Analyst estimates of the threat the unit is likely to face during this operation.",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "threatAssessment",
|
||||||
|
type: "group",
|
||||||
|
label: "Threat Assessment",
|
||||||
|
admin: {
|
||||||
|
description:
|
||||||
|
"Likelihood that the unit will encounter each enemy force type during the mission. Rendered as a color-coded table on the mission page.",
|
||||||
|
},
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "likelihoods",
|
||||||
|
type: "array",
|
||||||
|
labels: { singular: "Likelihood", plural: "Likelihoods" },
|
||||||
|
admin: {
|
||||||
|
description:
|
||||||
|
"One row per enemy force type. Leave empty to hide the table on the mission page.",
|
||||||
|
},
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "category",
|
||||||
|
type: "text",
|
||||||
|
required: true,
|
||||||
|
admin: {
|
||||||
|
description:
|
||||||
|
'Enemy force type, e.g. "Light Infantry", "Armor", "Rotary Air".',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "likelihood",
|
||||||
|
type: "select",
|
||||||
|
required: true,
|
||||||
|
defaultValue: "possible",
|
||||||
|
options: [
|
||||||
|
{ label: "Very Unlikely", value: "veryUnlikely" },
|
||||||
|
{ label: "Unlikely", value: "unlikely" },
|
||||||
|
{ label: "Possible", value: "possible" },
|
||||||
|
{ label: "Likely", value: "likely" },
|
||||||
|
{ label: "Very Likely", value: "veryLikely" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Dedicated Server",
|
label: "Dedicated Server",
|
||||||
description: "Server-specific details, like the IP, port, mission file, mod list, etc.",
|
description: "Server-specific details, like the IP, port, mission file, mod list, etc.",
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { UsersIcon } from "lucide-react";
|
import { UsersIcon } from "lucide-react";
|
||||||
import { toast, useDocumentInfo, useField } from "@payloadcms/ui";
|
import { toast, useAllFormFields, useDocumentInfo } from "@payloadcms/ui";
|
||||||
|
import { reduceFieldsToValues } from "payload/shared";
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
|
@ -25,20 +26,45 @@ interface LaborEdit {
|
||||||
unitSalary: string;
|
unitSalary: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LaborCrewPanel() {
|
/** Form-state shape of a laborRequirements row (collection field names). */
|
||||||
const documentInfo = useDocumentInfo();
|
interface LaborRequirementRow {
|
||||||
const laborRequirementsField = useField<{
|
classification?: number | { id: number } | null;
|
||||||
classificationId?: number | null;
|
|
||||||
requiredHeadcount?: number | null;
|
requiredHeadcount?: number | null;
|
||||||
maxHeadcount?: number | null;
|
maxHeadcount?: number | null;
|
||||||
enforcedSalary?: number | null;
|
enforcedSalary?: number | null;
|
||||||
}[]>({
|
}
|
||||||
path: "laborRequirements",
|
|
||||||
});
|
/** Relationship values arrive as raw ids (depth=0) or populated objects. */
|
||||||
|
function relId(value: unknown): number | null {
|
||||||
|
if (typeof value === "number") return value;
|
||||||
|
if (value !== null && typeof value === "object" && "id" in value) {
|
||||||
|
const id = (value as { id: unknown }).id;
|
||||||
|
return typeof id === "number" ? id : null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LaborCrewPanel() {
|
||||||
|
const documentInfo = useDocumentInfo();
|
||||||
|
const [formFields] = useAllFormFields();
|
||||||
|
|
||||||
|
// Array fields store only a row count at their own path in Payload's form
|
||||||
|
// state; rebuild the actual rows from the flattened field tree instead.
|
||||||
|
const laborRequirements = useMemo(() => {
|
||||||
|
const data = reduceFieldsToValues(formFields, true) as {
|
||||||
|
laborRequirements?: LaborRequirementRow[];
|
||||||
|
};
|
||||||
|
return Array.isArray(data.laborRequirements) ? data.laborRequirements : [];
|
||||||
|
}, [formFields]);
|
||||||
|
|
||||||
|
const requirementsKey = JSON.stringify(laborRequirements);
|
||||||
|
const requirementsRef = useRef(laborRequirements);
|
||||||
|
requirementsRef.current = laborRequirements;
|
||||||
|
|
||||||
const [crew, setCrew] = useState<LaborCrew[]>([]);
|
const [crew, setCrew] = useState<LaborCrew[]>([]);
|
||||||
const [edits, setEdits] = useState<Record<number, LaborEdit>>({});
|
const [edits, setEdits] = useState<Record<number, LaborEdit>>({});
|
||||||
const [loadingClassifications, setLoadingClassifications] = useState(false);
|
const [loadingClassifications, setLoadingClassifications] = useState(false);
|
||||||
|
const [loadFailed, setLoadFailed] = useState(false);
|
||||||
const [savingId, setSavingId] = useState<number | null>(null);
|
const [savingId, setSavingId] = useState<number | null>(null);
|
||||||
|
|
||||||
// Fetch classifications and current crew from REST
|
// Fetch classifications and current crew from REST
|
||||||
|
|
@ -47,31 +73,50 @@ export function LaborCrewPanel() {
|
||||||
|
|
||||||
async function loadData() {
|
async function loadData() {
|
||||||
setLoadingClassifications(true);
|
setLoadingClassifications(true);
|
||||||
|
setLoadFailed(false);
|
||||||
try {
|
try {
|
||||||
|
const staffingParams = new URLSearchParams({
|
||||||
|
depth: "0",
|
||||||
|
limit: "100",
|
||||||
|
"where[structure][equals]": String(documentInfo.id),
|
||||||
|
"where[positionType][equals]": "labor",
|
||||||
|
"where[status][equals]": "active",
|
||||||
|
});
|
||||||
const [classificationsRes, crewRes] = await Promise.all([
|
const [classificationsRes, crewRes] = await Promise.all([
|
||||||
fetch("/api/labor-classifications?depth=0"),
|
fetch("/api/labor-classifications?depth=0&limit=100"),
|
||||||
fetch(`/api/npc-staffing?where.structure.id=${documentInfo.id}&depth=0`),
|
fetch(`/api/npc-staffing?${staffingParams.toString()}`),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
|
|
||||||
const classifications = (await classificationsRes.json()).docs as LaborClassificationOption[];
|
if (!classificationsRes.ok || !crewRes.ok) {
|
||||||
const crewDocs = await crewRes.json();
|
throw new Error(
|
||||||
|
`Labor data request failed (classifications ${classificationsRes.status}, staffing ${crewRes.status})`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const classificationsBody = await classificationsRes.json();
|
||||||
|
const crewBody = await crewRes.json();
|
||||||
|
const classifications = classificationsBody?.docs as
|
||||||
|
| LaborClassificationOption[]
|
||||||
|
| undefined;
|
||||||
|
if (!Array.isArray(classifications)) {
|
||||||
|
throw new Error("Unexpected labor classifications response shape");
|
||||||
|
}
|
||||||
|
const crewDocs: any[] = Array.isArray(crewBody?.docs) ? crewBody.docs : [];
|
||||||
|
|
||||||
// Build crew list from laborRequirements + current npc-staffing docs
|
// Build crew list from laborRequirements + current npc-staffing docs
|
||||||
const requirementList = laborRequirementsField.value ?? [];
|
const requirementList = requirementsRef.current;
|
||||||
const newCrew: LaborCrew[] = requirementList.flatMap((req) => {
|
const newCrew: LaborCrew[] = requirementList.flatMap((req) => {
|
||||||
const classification = classifications.find(
|
const classification = classifications.find(
|
||||||
(c) => c.id === req.classificationId,
|
(c) => c.id === relId(req.classification),
|
||||||
);
|
);
|
||||||
if (!classification) return [];
|
if (!classification) return [];
|
||||||
|
|
||||||
const crewMembers = (crewDocs.docs ?? []).filter(
|
const crewMembers = crewDocs.filter(
|
||||||
(m: any) =>
|
(m) => relId(m.laborClassification) === classification.id,
|
||||||
m.positionType === "labor" &&
|
|
||||||
m.laborClassification?.id === classification.id,
|
|
||||||
);
|
);
|
||||||
const headcount = crewMembers.reduce((sum: number, m: any) => sum + (m.headcount ?? 1), 0);
|
const headcount = crewMembers.reduce((sum, m) => sum + (m.headcount ?? 1), 0);
|
||||||
const unitSalary = crewMembers[0]?.salary ?? classification.defaultUnitSalary ?? 0;
|
const unitSalary = crewMembers[0]?.salary ?? classification.defaultUnitSalary ?? 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -86,7 +131,9 @@ export function LaborCrewPanel() {
|
||||||
});
|
});
|
||||||
|
|
||||||
setCrew(newCrew);
|
setCrew(newCrew);
|
||||||
} catch {
|
} catch (err) {
|
||||||
|
console.error("[LaborCrewPanel] Failed to load labor data", err);
|
||||||
|
setLoadFailed(true);
|
||||||
toast.error("Failed to load labor data");
|
toast.error("Failed to load labor data");
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingClassifications(false);
|
setLoadingClassifications(false);
|
||||||
|
|
@ -95,7 +142,10 @@ export function LaborCrewPanel() {
|
||||||
|
|
||||||
if (documentInfo.id) loadData();
|
if (documentInfo.id) loadData();
|
||||||
return () => { cancelled = true; };
|
return () => { cancelled = true; };
|
||||||
}, [documentInfo.id, laborRequirementsField.value]);
|
// requirementsKey tracks the labor requirements content; requirementsRef
|
||||||
|
// always holds the latest rows without retriggering the effect.
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [documentInfo.id, requirementsKey]);
|
||||||
|
|
||||||
function getEdit(crewItem: LaborCrew): LaborEdit {
|
function getEdit(crewItem: LaborCrew): LaborEdit {
|
||||||
return edits[crewItem.classificationId] ?? {
|
return edits[crewItem.classificationId] ?? {
|
||||||
|
|
@ -186,6 +236,10 @@ export function LaborCrewPanel() {
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{loadingClassifications ? (
|
{loadingClassifications ? (
|
||||||
<p className="text-sm text-muted-foreground">Loading crew data...</p>
|
<p className="text-sm text-muted-foreground">Loading crew data...</p>
|
||||||
|
) : loadFailed ? (
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
Labor data could not be loaded. Reload the page to try again.
|
||||||
|
</p>
|
||||||
) : crew.length === 0 ? (
|
) : crew.length === 0 ? (
|
||||||
<p className="text-sm text-muted-foreground">No labor classifications configured for this structure.</p>
|
<p className="text-sm text-muted-foreground">No labor classifications configured for this structure.</p>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -246,6 +300,7 @@ export function LaborCrewPanel() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => void handleSave(item)}
|
onClick={() => void handleSave(item)}
|
||||||
|
|
|
||||||
330
src/components/frontend/intelligence/MissionThreatAssessment.tsx
Normal file
330
src/components/frontend/intelligence/MissionThreatAssessment.tsx
Normal file
|
|
@ -0,0 +1,330 @@
|
||||||
|
import {
|
||||||
|
BiohazardIcon,
|
||||||
|
BinocularsIcon,
|
||||||
|
CastleIcon,
|
||||||
|
FlameIcon,
|
||||||
|
HelicopterIcon,
|
||||||
|
PackageIcon,
|
||||||
|
PlaneIcon,
|
||||||
|
PlaneTakeoffIcon,
|
||||||
|
RadarIcon,
|
||||||
|
RadioIcon,
|
||||||
|
RocketIcon,
|
||||||
|
ShieldIcon,
|
||||||
|
ShipIcon,
|
||||||
|
TruckIcon,
|
||||||
|
UsersIcon,
|
||||||
|
type LucideIcon,
|
||||||
|
} from "lucide-react";
|
||||||
|
|
||||||
|
type Likelihood = "veryUnlikely" | "unlikely" | "possible" | "likely" | "veryLikely";
|
||||||
|
|
||||||
|
interface LikelihoodEntry {
|
||||||
|
category: string;
|
||||||
|
likelihood: Likelihood;
|
||||||
|
id?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MissionThreatAssessmentProps {
|
||||||
|
likelihoods: LikelihoodEntry[] | null;
|
||||||
|
/** Optional mission id, used to derive the deterministic REF code in the strip. */
|
||||||
|
missionId?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tactical dossier readout of the analyst threat estimate. Higher likelihood of
|
||||||
|
* an enemy force type reads as more dangerous, so the ramp runs cool (slate) for
|
||||||
|
* "Very Unlikely" up to red for "Very Likely". The value is always spelled out,
|
||||||
|
* so color is reinforcement only, never the sole signal.
|
||||||
|
*/
|
||||||
|
const likelihoodStyles: Record<
|
||||||
|
Likelihood,
|
||||||
|
{ label: string; className: string; dot: string }
|
||||||
|
> = {
|
||||||
|
veryUnlikely: { label: "Very Unlikely", className: "text-slate-300", dot: "bg-slate-300" },
|
||||||
|
unlikely: { label: "Unlikely", className: "text-sky-400", dot: "bg-sky-400" },
|
||||||
|
possible: { label: "Possible", className: "text-amber-400", dot: "bg-amber-400" },
|
||||||
|
likely: { label: "Likely", className: "text-orange-400", dot: "bg-orange-400" },
|
||||||
|
veryLikely: { label: "Very Likely", className: "text-red-400", dot: "bg-red-400" },
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heuristic force-type glyph. Categories are free text, so we match on
|
||||||
|
* substrings in priority order (first hit wins): specific platforms before
|
||||||
|
* generic domains, and air-defense before the bare "defense" catch-all. Unknown
|
||||||
|
* categories simply render without an icon. Keywords are lowercase; matching is
|
||||||
|
* case-insensitive `includes`.
|
||||||
|
*/
|
||||||
|
const CATEGORY_ICON_RULES: { Icon: LucideIcon; keywords: string[] }[] = [
|
||||||
|
{ Icon: HelicopterIcon, keywords: ["heli", "rotary", "rotor", "chopper", "dustoff"] },
|
||||||
|
{
|
||||||
|
Icon: PlaneIcon,
|
||||||
|
keywords: [
|
||||||
|
"plane",
|
||||||
|
"jet",
|
||||||
|
"aircraft",
|
||||||
|
"fighter",
|
||||||
|
"bomber",
|
||||||
|
"fixed-wing",
|
||||||
|
"fixed wing",
|
||||||
|
"air wing",
|
||||||
|
"airwing",
|
||||||
|
"air support",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ Icon: PlaneTakeoffIcon, keywords: ["drone", "uav", "quadcopter", "fpv", "mavic", "loitering"] },
|
||||||
|
{
|
||||||
|
Icon: ShieldIcon,
|
||||||
|
keywords: [
|
||||||
|
"air defense",
|
||||||
|
"air defence",
|
||||||
|
"airdefence",
|
||||||
|
"iads",
|
||||||
|
"anti-air",
|
||||||
|
"antiair",
|
||||||
|
"surface-to-air",
|
||||||
|
"sam site",
|
||||||
|
"patriot",
|
||||||
|
"tunguska",
|
||||||
|
"pantsir",
|
||||||
|
"shilka",
|
||||||
|
"tor-m2",
|
||||||
|
"tor m2",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Icon: RocketIcon,
|
||||||
|
keywords: [
|
||||||
|
"rocket",
|
||||||
|
"missile",
|
||||||
|
"artillery",
|
||||||
|
"arty",
|
||||||
|
"mortar",
|
||||||
|
"howitzer",
|
||||||
|
"mlrs",
|
||||||
|
"cannon",
|
||||||
|
"gun line",
|
||||||
|
"gunline",
|
||||||
|
"field gun",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Icon: ShipIcon,
|
||||||
|
keywords: [
|
||||||
|
"naval",
|
||||||
|
"navy",
|
||||||
|
"ship",
|
||||||
|
"boat",
|
||||||
|
"maritime",
|
||||||
|
"amphibious",
|
||||||
|
"harbor",
|
||||||
|
"harbour",
|
||||||
|
"riverine",
|
||||||
|
"lhd",
|
||||||
|
"srf",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Icon: TruckIcon,
|
||||||
|
keywords: [
|
||||||
|
"armor",
|
||||||
|
"armour",
|
||||||
|
"tank",
|
||||||
|
"afv",
|
||||||
|
"apc",
|
||||||
|
"ifv",
|
||||||
|
"mbt",
|
||||||
|
"mech",
|
||||||
|
"technical",
|
||||||
|
"gun truck",
|
||||||
|
"mrap",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Icon: UsersIcon,
|
||||||
|
keywords: [
|
||||||
|
"infantry",
|
||||||
|
"rifle",
|
||||||
|
"foot",
|
||||||
|
"dismount",
|
||||||
|
"soldier",
|
||||||
|
"troop",
|
||||||
|
"grunt",
|
||||||
|
"para",
|
||||||
|
"ranger",
|
||||||
|
"commando",
|
||||||
|
"squad",
|
||||||
|
"insurgent",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Icon: CastleIcon,
|
||||||
|
keywords: [
|
||||||
|
"static",
|
||||||
|
"fortif",
|
||||||
|
"bunker",
|
||||||
|
"defense",
|
||||||
|
"defence",
|
||||||
|
"outpost",
|
||||||
|
"emplacement",
|
||||||
|
"objective",
|
||||||
|
"obstacle",
|
||||||
|
"minefield",
|
||||||
|
"landmine",
|
||||||
|
"ied",
|
||||||
|
"ambush",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Icon: BinocularsIcon,
|
||||||
|
keywords: [
|
||||||
|
"recon",
|
||||||
|
"scout",
|
||||||
|
"surveil",
|
||||||
|
"observation",
|
||||||
|
"spotter",
|
||||||
|
"sniper",
|
||||||
|
"designator",
|
||||||
|
"jtac",
|
||||||
|
"marc",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Icon: RadarIcon,
|
||||||
|
keywords: ["radar", "sensor", "counter-battery", "counter battery", "sigint", "c4isr", "c4i"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Icon: RadioIcon,
|
||||||
|
keywords: ["comms", "communication", "radio", "electronic", "jammer", "ecm", "signal", "network"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Icon: PackageIcon,
|
||||||
|
keywords: [
|
||||||
|
"logistic",
|
||||||
|
"supply",
|
||||||
|
"resupply",
|
||||||
|
"convoy",
|
||||||
|
"fuel",
|
||||||
|
"ammo",
|
||||||
|
"ammunition",
|
||||||
|
"transport",
|
||||||
|
"cargo",
|
||||||
|
"truck",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ Icon: FlameIcon, keywords: ["flame", "incendiary", "thermite", "phosphorus"] },
|
||||||
|
{
|
||||||
|
Icon: BiohazardIcon,
|
||||||
|
keywords: ["chemical", "biochem", "cbrn", "nbc", "radiolog", "toxic", "nerve agent", "mustard"],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function resolveCategoryIcon(category: string): LucideIcon | null {
|
||||||
|
const value = category.toLowerCase();
|
||||||
|
for (const rule of CATEGORY_ICON_RULES) {
|
||||||
|
if (rule.keywords.some((keyword) => value.includes(keyword))) {
|
||||||
|
return rule.Icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MissionThreatAssessment({
|
||||||
|
likelihoods,
|
||||||
|
missionId,
|
||||||
|
}: MissionThreatAssessmentProps) {
|
||||||
|
if (!likelihoods || likelihoods.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const refCode = missionId != null ? String(missionId).padStart(3, "0") : null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
aria-label="Threat Assessment"
|
||||||
|
className="relative overflow-hidden rounded-none border border-border/70 bg-card"
|
||||||
|
>
|
||||||
|
{/* Faint grid texture: constant opacity, never brightens. */}
|
||||||
|
<div
|
||||||
|
aria-hidden="true"
|
||||||
|
className="pointer-events-none absolute inset-0 z-[1] opacity-[0.04]"
|
||||||
|
style={{
|
||||||
|
backgroundImage:
|
||||||
|
"linear-gradient(to right, white 1px, transparent 1px), linear-gradient(to bottom, white 1px, transparent 1px)",
|
||||||
|
backgroundSize: "28px 28px",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Corner brackets. */}
|
||||||
|
<div aria-hidden="true" className="pointer-events-none absolute inset-2 z-30">
|
||||||
|
<span className="absolute left-0 top-0 size-3 border-l border-t border-white/25" />
|
||||||
|
<span className="absolute right-0 top-0 size-3 border-r border-t border-white/25" />
|
||||||
|
<span className="absolute bottom-0 left-0 size-3 border-b border-l border-white/25" />
|
||||||
|
<span className="absolute bottom-0 right-0 size-3 border-b border-r border-white/25" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Classification strip. */}
|
||||||
|
<div
|
||||||
|
aria-hidden="true"
|
||||||
|
className="relative z-20 flex items-center justify-between border-b border-white/15 bg-black/50 px-5 py-1.5 backdrop-blur-sm"
|
||||||
|
>
|
||||||
|
<span className="flex items-center gap-1.5 font-mono text-[9px] uppercase tracking-widest text-white/60">
|
||||||
|
<RadarIcon className="size-3" />
|
||||||
|
Threat Assessment // Intel
|
||||||
|
</span>
|
||||||
|
{refCode && (
|
||||||
|
<span className="font-mono text-[9px] uppercase tracking-widest text-white/60">
|
||||||
|
REF {refCode}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Likelihood rows. */}
|
||||||
|
<table className="relative z-10 w-full border-collapse text-sm">
|
||||||
|
<caption className="sr-only">
|
||||||
|
Likelihood of encountering each enemy force type during this operation.
|
||||||
|
</caption>
|
||||||
|
<thead>
|
||||||
|
<tr className="border-b border-white/15">
|
||||||
|
<th
|
||||||
|
scope="col"
|
||||||
|
className="px-5 pb-2 pt-3 text-left font-mono text-[9px] font-medium uppercase tracking-widest text-white/40"
|
||||||
|
>
|
||||||
|
Force Type
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
|
scope="col"
|
||||||
|
className="px-5 pb-2 pt-3 text-right font-mono text-[9px] font-medium uppercase tracking-widest text-white/40"
|
||||||
|
>
|
||||||
|
Likelihood
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody className="divide-y divide-white/10">
|
||||||
|
{likelihoods.map((entry, index) => {
|
||||||
|
const style = likelihoodStyles[entry.likelihood] ?? likelihoodStyles.possible;
|
||||||
|
const Icon = resolveCategoryIcon(entry.category);
|
||||||
|
return (
|
||||||
|
<tr key={entry.id ?? `${entry.category}-${index}`}>
|
||||||
|
<th scope="row" className="px-5 py-2.5 text-left align-middle">
|
||||||
|
<span className="flex items-center gap-2 font-mono text-xs font-medium uppercase tracking-wider text-white/70">
|
||||||
|
{Icon && <Icon aria-hidden="true" className="size-3.5 shrink-0 text-white/40" />}
|
||||||
|
<span>{entry.category}</span>
|
||||||
|
</span>
|
||||||
|
</th>
|
||||||
|
<td className="px-5 py-2.5 text-right align-middle">
|
||||||
|
<span
|
||||||
|
className={`inline-flex items-center justify-end gap-2 whitespace-nowrap font-mono text-xs font-semibold uppercase tracking-wider ${style.className}`}
|
||||||
|
>
|
||||||
|
<span aria-hidden="true" className={`size-1.5 shrink-0 ${style.dot}`} />
|
||||||
|
{style.label}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
38748
src/migrations/20261010_050644_add_mission_threat_assessment.json
Normal file
38748
src/migrations/20261010_050644_add_mission_threat_assessment.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
||||||
|
|
||||||
|
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||||
|
await db.execute(sql`
|
||||||
|
CREATE TYPE "public"."enum_missions_threat_assessment_likelihoods_likelihood" AS ENUM('veryUnlikely', 'unlikely', 'possible', 'likely', 'veryLikely');
|
||||||
|
CREATE TABLE "missions_threat_assessment_likelihoods" (
|
||||||
|
"_order" integer NOT NULL,
|
||||||
|
"_parent_id" integer NOT NULL,
|
||||||
|
"id" varchar PRIMARY KEY NOT NULL,
|
||||||
|
"category" varchar NOT NULL,
|
||||||
|
"likelihood" "enum_missions_threat_assessment_likelihoods_likelihood" DEFAULT 'possible' NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE "missions_threat_assessment_likelihoods" ADD CONSTRAINT "missions_threat_assessment_likelihoods_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."missions"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
CREATE INDEX "missions_threat_assessment_likelihoods_order_idx" ON "missions_threat_assessment_likelihoods" USING btree ("_order");
|
||||||
|
CREATE INDEX "missions_threat_assessment_likelihoods_parent_id_idx" ON "missions_threat_assessment_likelihoods" USING btree ("_parent_id");`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
||||||
|
await db.execute(sql`
|
||||||
|
DROP TABLE "missions_threat_assessment_likelihoods" CASCADE;
|
||||||
|
DROP TYPE "public"."enum_missions_threat_assessment_likelihoods_likelihood";`)
|
||||||
|
}
|
||||||
|
|
@ -119,6 +119,7 @@ import * as migration_20261007_183000_add_missing_mcp_key_capabilities from './2
|
||||||
import * as migration_20261009_160740_add_campaign_on_hold_status from './20261009_160740_add_campaign_on_hold_status';
|
import * as migration_20261009_160740_add_campaign_on_hold_status from './20261009_160740_add_campaign_on_hold_status';
|
||||||
import * as migration_20261009_185259_add_wiki_featured_curation from './20261009_185259_add_wiki_featured_curation';
|
import * as migration_20261009_185259_add_wiki_featured_curation from './20261009_185259_add_wiki_featured_curation';
|
||||||
import * as migration_20261009_201920_add_contribution_entries from './20261009_201920_add_contribution_entries';
|
import * as migration_20261009_201920_add_contribution_entries from './20261009_201920_add_contribution_entries';
|
||||||
|
import * as migration_20261010_050644_add_mission_threat_assessment from './20261010_050644_add_mission_threat_assessment';
|
||||||
|
|
||||||
export const migrations = [
|
export const migrations = [
|
||||||
{
|
{
|
||||||
|
|
@ -724,6 +725,11 @@ export const migrations = [
|
||||||
{
|
{
|
||||||
up: migration_20261009_201920_add_contribution_entries.up,
|
up: migration_20261009_201920_add_contribution_entries.up,
|
||||||
down: migration_20261009_201920_add_contribution_entries.down,
|
down: migration_20261009_201920_add_contribution_entries.down,
|
||||||
name: '20261009_201920_add_contribution_entries'
|
name: '20261009_201920_add_contribution_entries',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
up: migration_20261010_050644_add_mission_threat_assessment.up,
|
||||||
|
down: migration_20261010_050644_add_mission_threat_assessment.down,
|
||||||
|
name: '20261010_050644_add_mission_threat_assessment'
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -3784,6 +3784,24 @@ export interface Mission {
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
}[]
|
}[]
|
||||||
| null;
|
| null;
|
||||||
|
/**
|
||||||
|
* Likelihood that the unit will encounter each enemy force type during the mission. Rendered as a color-coded table on the mission page.
|
||||||
|
*/
|
||||||
|
threatAssessment?: {
|
||||||
|
/**
|
||||||
|
* One row per enemy force type. Leave empty to hide the table on the mission page.
|
||||||
|
*/
|
||||||
|
likelihoods?:
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* Enemy force type, e.g. "Light Infantry", "Armor", "Rotary Air".
|
||||||
|
*/
|
||||||
|
category: string;
|
||||||
|
likelihood: 'veryUnlikely' | 'unlikely' | 'possible' | 'likely' | 'veryLikely';
|
||||||
|
id?: string | null;
|
||||||
|
}[]
|
||||||
|
| null;
|
||||||
|
};
|
||||||
gameDetails: {
|
gameDetails: {
|
||||||
serverDetails: {
|
serverDetails: {
|
||||||
serverIp: string;
|
serverIp: string;
|
||||||
|
|
@ -8994,6 +9012,17 @@ export interface MissionsSelect<T extends boolean = true> {
|
||||||
threatLevel?: T;
|
threatLevel?: T;
|
||||||
id?: T;
|
id?: T;
|
||||||
};
|
};
|
||||||
|
threatAssessment?:
|
||||||
|
| T
|
||||||
|
| {
|
||||||
|
likelihoods?:
|
||||||
|
| T
|
||||||
|
| {
|
||||||
|
category?: T;
|
||||||
|
likelihood?: T;
|
||||||
|
id?: T;
|
||||||
|
};
|
||||||
|
};
|
||||||
gameDetails?:
|
gameDetails?:
|
||||||
| T
|
| T
|
||||||
| {
|
| {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue