feat(npc-dialogue): add text flag type to player flags
This commit is contained in:
parent
3b33c45df0
commit
38eb8ff771
5 changed files with 37430 additions and 5 deletions
|
|
@ -46,9 +46,10 @@ export const PlayerFlags: CollectionConfig = {
|
|||
type: "select",
|
||||
required: true,
|
||||
defaultValue: "boolean",
|
||||
options: ["boolean", "number"],
|
||||
options: ["boolean", "number", "text"],
|
||||
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.",
|
||||
},
|
||||
},
|
||||
{
|
||||
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,
|
||||
indexes: [{ fields: ["user", "key"], unique: true }],
|
||||
|
|
|
|||
37386
src/migrations/20261006_195605_add_text_flag_type.json
Normal file
37386
src/migrations/20261006_195605_add_text_flag_type.json
Normal file
File diff suppressed because it is too large
Load diff
18
src/migrations/20261006_195605_add_text_flag_type.ts
Normal file
18
src/migrations/20261006_195605_add_text_flag_type.ts
Normal 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";`)
|
||||
}
|
||||
|
|
@ -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_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_195605_add_text_flag_type from './20261006_195605_add_text_flag_type';
|
||||
|
||||
export const migrations = [
|
||||
{
|
||||
|
|
@ -664,6 +665,11 @@ export const migrations = [
|
|||
{
|
||||
up: migration_20261006_155244_add_global_flag_support.up,
|
||||
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'
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -2553,9 +2553,9 @@ export interface PlayerFlag {
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
|
@ -2564,6 +2564,10 @@ export interface PlayerFlag {
|
|||
* A missing numeric flag counts as 0.
|
||||
*/
|
||||
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;
|
||||
createdAt: string;
|
||||
}
|
||||
|
|
@ -7846,6 +7850,7 @@ export interface PlayerFlagsSelect<T extends boolean = true> {
|
|||
flagType?: T;
|
||||
boolValue?: T;
|
||||
numberValue?: T;
|
||||
textValue?: T;
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue