syntax = "proto3";

package freeexile.map_zone;

// Loại hình phân khu thế giới
enum ZoneType {
  ZONE_TYPE_UNSPECIFIED = 0;
  ZONE_TYPE_SANCTUARY = 1;         // Thành trì an toàn, cấm PvP, trung tâm giao dịch & rèn đúc
  ZONE_TYPE_OPEN_WORLD = 2;       // Dã ngoại mở, quái vật, dã sinh, boss hoàng kim
  ZONE_TYPE_DUNGEON_INSTANCE = 3; // Phó bản độc lập (Party / Solo, giới hạn thời gian & mạng)
  ZONE_TYPE_SECRET_CHAMBER = 4;   // Mật thất cổ võ, kỳ ngộ ẩn ngẫu nhiên, tự động sụp đổ
}

// Môi trường khí tượng & dị biến tự nhiên
enum ZoneEnvironment {
  ENV_UNSPECIFIED = 0;
  ENV_NORMAL = 1;                 // Bình thường
  ENV_SANDSTORM = 2;              // Bão cát vô định: Giảm tầm nhìn, giảm tốc độ di chuyển
  ENV_MIASMA_TOXIC = 3;           // Chướng khí độc: Rút sinh lực liên tục
  ENV_FREEZING_CHILL = 4;         // Hàn băng thấu xương: Giảm tốc độ xuất chiêu & né tránh
  ENV_SCORCHING_HEAT = 5;         // Luyện ngục dung nham: Sát thương Hỏa chu kỳ
  ENV_VOID_CORRUPTION = 6;        // Dị tượng hư không: Không gian biến dạng, quái mang hào quang
}

// Thông tin điểm truyền tống (Thần Hành Trận)
message WaypointData {
  string waypoint_id = 1;
  string name = 2;
  string zone_id = 3;
  float x = 4;
  float y = 5;
  float z = 6;
  bool is_unlocked = 7;
}

// Thông tin cổng dịch chuyển ranh giới bản đồ
message ZonePortalData {
  string portal_id = 1;
  string name = 2;
  string source_zone_id = 3;
  float source_x = 4;
  float source_y = 5;
  string target_zone_id = 6;
  float target_x = 7;
  float target_y = 8;
  uint32 min_level = 9;
  string required_quest_id = 10;
}

// Dữ liệu bản đồ chi tiết trả về client
message ZoneInfoPayload {
  string zone_id = 1;
  string name = 2;
  ZoneType zone_type = 3;
  ZoneEnvironment environment = 4;
  uint32 min_level = 5;
  float bounds_width = 6;
  float bounds_height = 7;
  repeated WaypointData waypoints = 8;
  repeated ZonePortalData portals = 9;
  repeated string npc_ids = 10;
}

// Yêu cầu và phản hồi bước qua Cổng Truyền Tống
message EnterZoneRequest {
  string player_id = 1;
  string portal_id = 2;
  uint32 player_level = 3;
}

message EnterZoneResponse {
  bool success = 1;
  string error_message = 2;
  ZoneInfoPayload current_zone = 3;
  float spawn_x = 4;
  float spawn_y = 5;
}

// Dịch chuyển nhanh qua Thần Hành Trận
message WaypointTeleportRequest {
  string player_id = 1;
  string target_waypoint_id = 2;
}

message WaypointTeleportResponse {
  bool success = 1;
  string error_message = 2;
  string target_zone_id = 3;
  float target_x = 4;
  float target_y = 5;
}

// Khai mở Phó Bản Cổ Trận
message CreateInstanceRequest {
  string template_id = 1;
  string leader_player_id = 2;
  repeated string member_player_ids = 3;
  uint32 leader_level = 4;
}

message CreateInstanceResponse {
  bool success = 1;
  string error_message = 2;
  string instance_id = 3;
  uint32 current_layer = 4;
  uint32 max_layers = 5;
  uint32 time_limit_sec = 6;
  uint32 lives_remaining = 7;
}

// Đồng bộ tiến độ ải phó bản
message InstanceProgressSyncNotice {
  string instance_id = 1;
  uint32 current_layer = 2;
  uint32 max_layers = 3;
  uint32 lives_remaining = 4;
  bool is_completed = 5;
  bool is_failed = 6;
}

// Thông báo phát hiện Mật Thất Cổ Võ (Cơ duyên xuất hiện)
message SecretChamberRevealNotice {
  string chamber_id = 1;
  string template_id = 2;
  string chamber_name = 3;
  string portal_zone_id = 4;
  float portal_x = 5;
  float portal_y = 6;
  uint64 collapse_timestamp_ms = 7;
}

message EnterSecretChamberRequest {
  string player_id = 1;
  string chamber_id = 2;
}

message EnterSecretChamberResponse {
  bool success = 1;
  string error_message = 2;
  string chamber_zone_id = 3;
  uint64 remaining_time_sec = 4;
}

// Đồng bộ tỷ lệ khám phá bản đồ
message MapExplorationSyncNotice {
  string zone_id = 1;
  float exploration_percent = 2;
  repeated string unlocked_waypoint_ids = 3;
}
