// Protocol Buffer Definition: FreeExile Player Hideout & Astral Waygates
// Schema-First Specification for Player Private Sanctum, 6-Portal Map Device, and World/Quest Portals.
// Adheres strictly to Backward Compatibility and Zero-Trust Server Authority.

syntax = "proto3";

package freeexile.hideout;

option go_package = "freeexile/hideout";
option java_package = "com.freeexile.proto.hideout";
option csharp_namespace = "FreeExile.Proto.Hideout";

// Available Themes for Player Hideout / Tiên Phủ Động Thiên
enum HideoutTheme {
  HIDEOUT_THEME_UNSPECIFIED = 0;
  ASTRAL_PEAK = 1;          // Thái Hư Tiên Phong (Lơ lửng giữa mây trời, trúc xanh, thác nước hư không)
  DRAGON_VALLEY = 2;        // Cổ Long U Cốc (Hang động cổ võ rồng thiêng, suối nước nóng, nham thạch)
  BAMBOO_SHRINE = 3;        // Tiêu Dao Trúc Uyển (Rừng trúc bạt ngàn, đình đài cổ kính VLTK1)
  LUNAR_SANCTUARY = 4;      // Minh Nguyệt Hàn Đàm (Đầm sen phát quang, hoa súng nở dưới ánh trăng)
}

// Portal Types in Hideout
enum HideoutPortalType {
  PORTAL_TYPE_UNSPECIFIED = 0;
  MAP_DEVICE_PORTAL = 1;    // Cổng Tinh Đồ Hư Không (Thuộc Thiết Bị 6 Cổng)
  WORLD_EXPLORATION_GATE = 2;// Cổng Vạn Giới Đi Bản Đồ Thế Giới Mở
  QUEST_BOUNTY_GATE = 3;    // Cổng Thiên Mệnh Đi Làm Nhiệm Vụ & Truy Nã
}

// Hideout Interactive Facilities
enum FacilityType {
  FACILITY_UNSPECIFIED = 0;
  CONSIGNMENT_STASH_VAULT = 1; // Rương Kỳ Trân & Sổ Cái 2PC
  PRIMAL_FORGE_CAULDRON = 2;   // Luyện Đan Lô & Lò Đúc Linh Thạch
  MERIDIAN_MEDITATION_MAT = 3; // Bát Mạch Đồ Đàn
  AGENT_ORB_ALTAR = 4;         // Định Hồn Thần Châu Đài (Uỷ Thác AI)
  ASTRAL_MAP_DEVICE = 5;       // Thiên Đạo Tinh Đồ Nghi (PoE2 6-Portal Device)
}

// Individual Portal State
message PortalInfo {
  string portal_id = 1;
  HideoutPortalType portal_type = 2;
  string destination_zone_id = 3;
  string destination_name = 4;
  int32 remaining_charges = 5;      // For map device (max 6 portals total)
  bool is_active = 6;
  float pos_x = 7;
  float pos_y = 8;
  float pos_z = 9;
  string visual_effect_color = 10;   // e.g. #a855f7 (Purple), #38bdf8 (Cyan), #fbbf24 (Gold)
}

// Astral Map Tablet Item Info (PoE2 Map System)
message AstralMapItem {
  string map_item_id = 1;
  string map_name = 2;
  int32 tier = 3;                   // Tier 1 to 16
  int32 item_quantity_bonus_pct = 4; // +35% Drop
  int32 item_rarity_bonus_pct = 5;   // +20% Rarity
  int32 monster_pack_size_pct = 6;   // +15% Monster density
  repeated string map_affixes = 7;   // e.g. ["+25% Sát Thương Hỏa", "Quái Vật Kháng Băng +30%"]
  string boss_name = 8;
}

// Enter Hideout
message EnterHideoutRequest {
  string player_id = 1;
  string target_player_id = 2;      // Own hideout or visiting friend/guildmate
}

message EnterHideoutResponse {
  bool success = 1;
  string hideout_id = 2;
  HideoutTheme theme = 3;
  float spawn_x = 4;
  float spawn_y = 5;
  repeated PortalInfo active_portals = 6;
  string error_message = 7;
}

// Activate 6-Portal Map Device
message ActivateMapDeviceRequest {
  string player_id = 1;
  AstralMapItem map_item = 2;
}

message ActivateMapDeviceResponse {
  bool success = 1;
  string map_instance_id = 2;
  int32 total_portals_opened = 3;   // Standard 6 portals
  int32 portals_remaining = 4;
  repeated PortalInfo portal_ring = 5;
  string error_message = 6;
}

// Enter a Portal
message EnterPortalRequest {
  string player_id = 1;
  string portal_id = 2;
}

message EnterPortalResponse {
  bool success = 1;
  string target_zone_id = 2;
  string target_instance_id = 3;
  float spawn_x = 4;
  float spawn_y = 5;
  int32 portals_remaining = 6;
  string error_message = 7;
}

// Configure World Gate Destination
message ConfigureWorldGateRequest {
  string player_id = 1;
  string target_zone_id = 2;        // Canonical open-world zone
}

message ConfigureWorldGateResponse {
  bool success = 1;
  PortalInfo updated_portal = 2;
  string error_message = 3;
}

// Configure Quest Gate Destination
message ConfigureQuestGateRequest {
  string player_id = 1;
  string quest_id = 2;              // Active quest from QuestEngine
}

message ConfigureQuestGateResponse {
  bool success = 1;
  PortalInfo updated_portal = 2;
  string quest_title = 3;
  string error_message = 4;
}

// Real-Time Notification: Hideout State Synchronized
message HideoutStateSyncNotice {
  string hideout_id = 1;
  string owner_id = 2;
  HideoutTheme theme = 3;
  int32 map_device_portals_remaining = 4;
  string active_map_name = 5;
  int32 active_map_tier = 6;
  repeated PortalInfo portals = 7;
  int64 timestamp_ms = 8;
}
