import { Column, CreateDateColumn, Entity, Index, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn, } from 'typeorm'; import { Character } from '../../characters/entities/character.entity'; import type { LocationPointOfInterestContent, LocationPrimaryActionContent, LocationRewardPreviewContent, LocationType, } from '../local-location.types'; import { LocationConnection } from './location-connection.entity'; @Entity({ name: 'location_definitions' }) @Index('IDX_location_definitions_key', ['key'], { unique: true }) export class LocationDefinition { @PrimaryGeneratedColumn('uuid', { name: 'id' }) id!: string; @Column({ name: 'key', type: 'varchar', length: 100 }) key!: string; @Column({ name: 'name', type: 'varchar', length: 150 }) name!: string; @Column({ name: 'description', type: 'text' }) description!: string; @Column({ name: 'region_key', type: 'varchar', length: 100 }) regionKey!: string; @Column({ name: 'min_recommended_level', type: 'integer' }) minRecommendedLevel!: number; @Column({ name: 'max_recommended_level', type: 'integer' }) maxRecommendedLevel!: number; @Column({ name: 'danger_level', type: 'integer' }) dangerLevel!: number; @Column({ name: 'is_safe', type: 'boolean' }) isSafe!: boolean; @Column({ name: 'hunting_enabled', type: 'boolean' }) huntingEnabled!: boolean; @Column({ name: 'artwork_path', type: 'varchar', length: 255 }) artworkPath!: string; // --- Local location view (spec §4, §10) ----------------------------------- // `description`/`artworkPath` above stay untouched: the map and the hunt // screen keep rendering them. The `local*` columns below feed the local // location view, which needs a longer scene description and a wide artwork. @Column({ name: 'region_name', type: 'varchar', length: 150 }) regionName!: string; @Column({ name: 'region_tier_label', type: 'varchar', length: 50 }) regionTierLabel!: string; @Column({ name: 'location_type', type: 'varchar', length: 50 }) locationType!: LocationType; @Column({ name: 'local_description', type: 'text' }) localDescription!: string; @Column({ name: 'local_artwork_path', type: 'varchar', length: 255 }) localArtworkPath!: string; @Column({ name: 'local_points_of_interest', type: 'jsonb' }) localPointsOfInterest!: LocationPointOfInterestContent[]; @Column({ name: 'local_primary_actions', type: 'jsonb' }) localPrimaryActions!: LocationPrimaryActionContent[]; @Column({ name: 'local_reward_preview', type: 'jsonb' }) localRewardPreview!: LocationRewardPreviewContent[]; @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt!: Date; @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' }) updatedAt!: Date; @OneToMany(() => Character, (character) => character.currentLocation) characters!: Character[]; @OneToMany(() => LocationConnection, (connection) => connection.fromLocation) outgoingConnections!: LocationConnection[]; @OneToMany(() => LocationConnection, (connection) => connection.toLocation) incomingConnections!: LocationConnection[]; }