1
0
Fork 0

feat(npc-dialogue): add text flag type to player flags

This commit is contained in:
Jason Fraley 2026-10-06 16:09:10 -04:00
parent 3b33c45df0
commit 38eb8ff771
5 changed files with 37430 additions and 5 deletions

View file

@ -46,9 +46,10 @@ export const PlayerFlags: CollectionConfig = {
type: "select", type: "select",
required: true, required: true,
defaultValue: "boolean", defaultValue: "boolean",
options: ["boolean", "number"], options: ["boolean", "number", "text"],
admin: { admin: {
description: "Boolean flags read as true/false; numeric flags track statistics.", description:
"Boolean flags read as true/false; numeric flags track statistics; text flags carry a string that conversations can interpolate with {{key}}.",
}, },
}, },
{ {
@ -69,6 +70,15 @@ export const PlayerFlags: CollectionConfig = {
description: "A missing numeric flag counts as 0.", description: "A missing numeric flag counts as 0.",
}, },
}, },
{
name: "textValue",
type: "text",
admin: {
condition: (_data, blockData) => blockData?.flagType === "text",
description:
"Inserted into conversation text wherever {{key}} appears. May contain dialogue markup like {green}NOMINAL{/}. A missing text flag reads as empty.",
},
},
], ],
timestamps: true, timestamps: true,
indexes: [{ fields: ["user", "key"], unique: true }], indexes: [{ fields: ["user", "key"], unique: true }],

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,18 @@
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
ALTER TYPE "public"."enum_player_flags_flag_type" ADD VALUE 'text';
ALTER TABLE "player_flags" ADD COLUMN "text_value" varchar;`)
}
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "player_flags" ALTER COLUMN "flag_type" SET DATA TYPE text;
ALTER TABLE "player_flags" ALTER COLUMN "flag_type" SET DEFAULT 'boolean'::text;
DROP TYPE "public"."enum_player_flags_flag_type";
CREATE TYPE "public"."enum_player_flags_flag_type" AS ENUM('boolean', 'number');
ALTER TABLE "player_flags" ALTER COLUMN "flag_type" SET DEFAULT 'boolean'::"public"."enum_player_flags_flag_type";
ALTER TABLE "player_flags" ALTER COLUMN "flag_type" SET DATA TYPE "public"."enum_player_flags_flag_type" USING "flag_type"::"public"."enum_player_flags_flag_type";
ALTER TABLE "player_flags" DROP COLUMN "text_value";`)
}

View file

@ -109,6 +109,7 @@ import * as migration_20261005_063613_add_game_npc_image from './20261005_063613
import * as migration_20261005_185014_add_player_flags from './20261005_185014_add_player_flags'; import * as migration_20261005_185014_add_player_flags from './20261005_185014_add_player_flags';
import * as migration_20261006_000000_add_npc_dialogue_and_activity_fields from './20261006_000000_add_npc_dialogue_and_activity_fields'; import * as migration_20261006_000000_add_npc_dialogue_and_activity_fields from './20261006_000000_add_npc_dialogue_and_activity_fields';
import * as migration_20261006_155244_add_global_flag_support from './20261006_155244_add_global_flag_support'; import * as migration_20261006_155244_add_global_flag_support from './20261006_155244_add_global_flag_support';
import * as migration_20261006_195605_add_text_flag_type from './20261006_195605_add_text_flag_type';
export const migrations = [ export const migrations = [
{ {
@ -664,6 +665,11 @@ export const migrations = [
{ {
up: migration_20261006_155244_add_global_flag_support.up, up: migration_20261006_155244_add_global_flag_support.up,
down: migration_20261006_155244_add_global_flag_support.down, down: migration_20261006_155244_add_global_flag_support.down,
name: '20261006_155244_add_global_flag_support' name: '20261006_155244_add_global_flag_support',
},
{
up: migration_20261006_195605_add_text_flag_type.up,
down: migration_20261006_195605_add_text_flag_type.down,
name: '20261006_195605_add_text_flag_type'
}, },
]; ];

View file

@ -2553,9 +2553,9 @@ export interface PlayerFlag {
*/ */
key: string; key: string;
/** /**
* Boolean flags read as true/false; numeric flags track statistics. * Boolean flags read as true/false; numeric flags track statistics; text flags carry a string that conversations can interpolate with {{key}}.
*/ */
flagType: 'boolean' | 'number'; flagType: 'boolean' | 'number' | 'text';
/** /**
* A missing boolean flag counts as false. * A missing boolean flag counts as false.
*/ */
@ -2564,6 +2564,10 @@ export interface PlayerFlag {
* A missing numeric flag counts as 0. * A missing numeric flag counts as 0.
*/ */
numberValue?: number | null; numberValue?: number | null;
/**
* Inserted into conversation text wherever {{key}} appears. May contain dialogue markup like {green}NOMINAL{/}. A missing text flag reads as empty.
*/
textValue?: string | null;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
} }
@ -7846,6 +7850,7 @@ export interface PlayerFlagsSelect<T extends boolean = true> {
flagType?: T; flagType?: T;
boolValue?: T; boolValue?: T;
numberValue?: T; numberValue?: T;
textValue?: T;
updatedAt?: T; updatedAt?: T;
createdAt?: T; createdAt?: T;
} }