-- Chattyness Enumeration Types
-- PostgreSQL 18
--
-- All ENUM types used across the database
-- Load via: psql -f schema/types/001_enums.sql

\set ON_ERROR_STOP on

BEGIN;

-- =============================================================================
-- Server-Level Enums
-- =============================================================================

-- Server-wide reputation tiers (earned through time and achievements)
CREATE TYPE server.reputation_tier AS ENUM (
    'guest',       -- No account, temporary session
    'member',      -- Registered account
    'established', -- 1 day + achievements
    'trusted',     -- 1 week + achievements
    'elder'        -- 1 month + achievements
);
COMMENT ON TYPE server.reputation_tier IS 'Server-wide reputation levels earned through time and activity';

-- Server-level roles
CREATE TYPE server.server_role AS ENUM (
    'owner',      -- Server owner, full control
    'admin',      -- Server administrator
    'moderator'   -- Cross-realm moderation
);
COMMENT ON TYPE server.server_role IS 'Administrative roles at the server level';

-- Audio category
CREATE TYPE server.audio_category AS ENUM (
    'sound_effect',
    'ambient',
    'music',
    'voice'
);

-- Reserved name type
CREATE TYPE server.reserved_name_type AS ENUM (
    'username',
    'realm_name',
    'both'
);

-- Prop origin source (moved from props schema)
CREATE TYPE server.prop_origin AS ENUM (
    'server_library',  -- From server global library
    'realm_library',   -- From realm-specific library
    'user_upload'      -- User-uploaded content
);
COMMENT ON TYPE server.prop_origin IS 'Source of prop creation';

-- Prop transferability (moved from props schema)
CREATE TYPE server.transferability AS ENUM (
    'transferable',  -- Can be traded/given to others
    'soulbound'      -- Bound to original recipient
);
COMMENT ON TYPE server.transferability IS 'Whether prop can change ownership';

-- Prop portability (moved from props schema)
CREATE TYPE server.portability AS ENUM (
    'portable',      -- Can be used across realms
    'realm_locked'   -- Only usable in origin realm
);
COMMENT ON TYPE server.portability IS 'Whether prop can be used outside origin realm';

-- Avatar layer (moved from props schema)
CREATE TYPE server.avatar_layer AS ENUM (
    'skin',        -- Background layer (behind user, body/face)
    'clothes',     -- Middle layer (with user, worn items)
    'accessories'  -- Foreground layer (in front of user, held/attached items)
);
COMMENT ON TYPE server.avatar_layer IS 'Z-layer for avatar prop positioning: skin (behind), clothes (with), accessories (front)';

-- Emotion state for avatar overlays (moved from props schema)
CREATE TYPE server.emotion_state AS ENUM (
    'neutral',
    'happy',
    'sad',
    'angry',
    'surprised',
    'thinking',
    'laughing',
    'crying',
    'love',
    'confused',
    'sleeping',
    'wink'
);
COMMENT ON TYPE server.emotion_state IS 'Emotional expression overlay for avatars';

-- Moderation action type (moved from moderation schema)
CREATE TYPE server.action_type AS ENUM (
    'warning',
    'mute',
    'kick',
    'ban',
    'unban',
    'prop_removal',
    'message_deletion'
);
COMMENT ON TYPE server.action_type IS 'Type of moderation action taken';

-- Report status (moved from moderation schema)
CREATE TYPE server.report_status AS ENUM (
    'pending',
    'investigating',
    'resolved',
    'dismissed'
);
COMMENT ON TYPE server.report_status IS 'Current state of a user report';

-- Ban scope (moved from moderation schema)
CREATE TYPE server.ban_scope AS ENUM (
    'server',   -- Banned from entire server
    'realm'     -- Banned from specific realm
);
COMMENT ON TYPE server.ban_scope IS 'Scope of ban enforcement';

-- Content filter action (moved from moderation schema)
CREATE TYPE server.filter_action AS ENUM (
    'block',     -- Prevent message from sending
    'flag',      -- Allow but flag for review
    'replace'    -- Replace matched content
);
COMMENT ON TYPE server.filter_action IS 'Action to take when content filter matches';

-- =============================================================================
-- Authentication Enums
-- =============================================================================

-- User account tags for feature gating and access control
CREATE TYPE auth.user_tag AS ENUM (
    'guest',
    'unvalidated',
    'validated_email',
    'validated_social',
    'validated_oauth2',
    'premium'
);
COMMENT ON TYPE auth.user_tag IS 'User account tags for feature gating and access control';

-- User account status
CREATE TYPE auth.account_status AS ENUM (
    'active',
    'suspended',
    'banned',
    'deleted'
);
COMMENT ON TYPE auth.account_status IS 'Current state of user account';

-- Authentication provider
CREATE TYPE auth.auth_provider AS ENUM (
    'local',      -- Username/password
    'oauth_google',
    'oauth_discord',
    'oauth_github'
);
COMMENT ON TYPE auth.auth_provider IS 'Authentication method used for account';

-- =============================================================================
-- Realm Enums
-- =============================================================================

-- Realm privacy settings
CREATE TYPE realm.realm_privacy AS ENUM (
    'public',     -- Anyone can enter
    'unlisted',   -- Not in directory, but accessible via link
    'private'     -- Invite only
);
COMMENT ON TYPE realm.realm_privacy IS 'Visibility and access level for realms';

-- Realm-level roles
CREATE TYPE realm.realm_role AS ENUM (
    'owner',      -- Full control of realm
    'moderator',  -- Moderation within realm
    'builder',    -- Can edit scenes
    'member'      -- Standard member
);
COMMENT ON TYPE realm.realm_role IS 'Permission roles within a specific realm';

-- Scene dimension mode
CREATE TYPE realm.dimension_mode AS ENUM (
    'fixed',      -- Fixed dimensions, scrollable
    'viewport'    -- Scales to viewport
);
COMMENT ON TYPE realm.dimension_mode IS 'How scene dimensions are handled';

-- =============================================================================
-- Scene Enums
-- =============================================================================

-- Instance type (renamed from realm.channel_type)
CREATE TYPE scene.instance_type AS ENUM (
    'public',     -- Default public instance
    'private'     -- Invite-only instance
);
COMMENT ON TYPE scene.instance_type IS 'Instance visibility and access type';

-- Spot type (interactive regions) - moved from realm schema
CREATE TYPE scene.spot_type AS ENUM (
    'normal',     -- Generic interactive region
    'door',       -- Navigates to another scene
    'trigger'     -- Fires on enter/exit, no click needed
);
COMMENT ON TYPE scene.spot_type IS 'Type of interactive spot behavior';

-- =============================================================================
-- Chat Enums
-- =============================================================================

-- Message type
CREATE TYPE chat.message_type AS ENUM (
    'normal',     -- Standard chat message
    'emote',      -- Action/emote (/me)
    'shout',      -- Server-wide broadcast
    'whisper',    -- Private direct message
    'system'      -- System announcement
);
COMMENT ON TYPE chat.message_type IS 'Category of chat message';

COMMIT;
