New Game collection reinforcement-pools (name, faction, armaFactions, available, enabled) with manual-edit audit via reinforcement:adjust. The events hook applies reinforcement.spawn/.refund deltas (soft limits, no floor, idempotent by eventId) before the game's next pull, and a new GET /api/arma/v1/reinforcements endpoint serves enabled pools to the server.
35 lines
1 KiB
TypeScript
35 lines
1 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { requireArmaServer } from "@/lib/arma-bridge/server";
|
|
|
|
export const runtime = "nodejs";
|
|
export const dynamic = "force-dynamic";
|
|
|
|
/**
|
|
* Called by the Arma 3 bridge (get_reinforcements) on the server's ~15 s
|
|
* reinforcement cycle. Returns every enabled reinforcement pool with its
|
|
* current balance and the Arma faction classes it counts, so the game can
|
|
* attribute curator placements and render the Zeus HUD.
|
|
*/
|
|
export async function GET(req: NextRequest) {
|
|
const auth = await requireArmaServer(req);
|
|
if (auth instanceof NextResponse) return auth;
|
|
const { payload } = auth;
|
|
|
|
const pools = await payload.find({
|
|
collection: "reinforcement-pools",
|
|
where: { enabled: { equals: true } },
|
|
limit: 200,
|
|
depth: 0,
|
|
overrideAccess: true,
|
|
});
|
|
|
|
return NextResponse.json({
|
|
ok: true,
|
|
pools: pools.docs.map((pool) => ({
|
|
poolId: pool.id,
|
|
name: pool.name,
|
|
available: pool.available ?? 0,
|
|
armaFactions: pool.armaFactions ?? [],
|
|
})),
|
|
});
|
|
}
|