1
0
Fork 0
polaris-task-force/src/collections/server/RespawnTickets.ts

36 lines
1.5 KiB
TypeScript

import { CollectionConfig } from "payload";
import { requirePermission } from "@/utils/access-control/hasPermission";
/**
* Per-player respawn ticket balances. Tickets are awarded automatically when a
* mission is "settled" (see src/lib/respawn-tickets/index.ts): each attendee
* earns 1 ticket for a "yes" RSVP, 0.5 for "tentative", 0.25 for "no", and
* nothing when they attend without an RSVP. Balances accumulate across
* missions and are served to the Arma 3 mod via the arma-bridge tickets
* route, which loads them into the game at mission start.
*
* Written internally by the settlement lib (overrideAccess); GMs can also
* adjust balances manually in the admin panel.
*/
export const RespawnTickets: CollectionConfig = {
slug: "respawn-tickets",
admin: { group: "Server", useAsTitle: "user", defaultColumns: ["user", "balance"] },
access: {
read: requirePermission("respawn-tickets:read"),
create: requirePermission("respawn-tickets:create"),
update: requirePermission("respawn-tickets:update"),
delete: requirePermission("respawn-tickets:delete"),
},
fields: [
{ name: "user", type: "relationship", relationTo: "users", required: true, unique: true, index: true },
{
name: "balance",
type: "number",
defaultValue: 0,
admin: {
description:
"Accumulated respawn tickets (1 per yes-attended op, 0.5 tentative, 0.25 no). Settlement adjusts automatically; GMs can adjust manually.",
},
},
],
};