1
0
Fork 0
polaris-task-force/src/collections/world/ResourceNodes.ts
Z8MB1E 5f06039697 feat(world): game map collections with basemaps, map permissions, and meter proximity
Add maps basemap config (world size, image/tiles mode, zoom defaults, isActive), map-roads, map-zones, and resource-nodes collections with maps:* permissions. Track game-structures map placement, meter coordinates, and label visibility/priority. Bump proximityThreshold to meters and adapt side-op map creation plus test fixtures to the new required fields.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-09-16 23:13:57 -04:00

73 lines
1.8 KiB
TypeScript

import { CollectionConfig } from "payload";
import { requirePermission } from "@/utils/access-control/hasPermission";
import { validatePosition } from "@/lib/map/points";
/**
* Map resource nodes (deposits, forests, wells, ...). Display + placement
* validation only: blueprints with resourcesInRange require a matching node
* within range. Nodes do not produce anything.
*/
export const ResourceNodes: CollectionConfig = {
slug: "resource-nodes",
admin: {
group: "World",
useAsTitle: "name",
},
access: {
read: ({ req }) => !!req.user,
create: requirePermission("maps:create"),
update: requirePermission("maps:update"),
delete: requirePermission("maps:delete"),
},
fields: [
{
name: "name",
type: "text",
required: true,
admin: {
description: 'Node label (e.g. "North copper deposit").',
},
},
{
name: "description",
type: "textarea",
admin: {
description: "Shown in the node's tooltip and popup on the map.",
},
},
{
name: "map",
type: "relationship",
relationTo: "maps",
required: true,
},
{
name: "resources",
type: "relationship",
relationTo: "resources",
hasMany: true,
required: true,
admin: {
description: "Every resource this node yields (e.g. copper AND oil).",
},
},
{
name: "position",
type: "json",
required: true,
validate: validatePosition,
admin: {
description: "[x, y] tuple in meters on the map grid.",
},
},
{
name: "richness",
type: "number",
defaultValue: 100,
min: 0,
admin: {
description: "Display-only abundance rating for the map UI.",
},
},
],
};