// Protocol Buffer Definition: FreeExile Social Engine & Real-Time Presence
// Schema-First Specification for Friend Management, Real-Time Presence Sync,
// Bidirectional Blacklists, and Guild Roster R3 Teleportation Targets.

syntax = "proto3";

package freeexile.social;

option go_package = "freeexile/social";
option java_package = "com.freeexile.proto.social";
option csharp_namespace = "FreeExile.Proto.Social";

// Friendship Relationship Status
enum FriendRelationStatus {
  RELATION_UNSPECIFIED = 0;
  PENDING_SENT = 1;      // Đã gửi lời mời, chờ đối phương đồng ý
  PENDING_RECEIVED = 2;  // Nhận được lời mời, có thể đồng ý hoặc từ chối
  ACCEPTED = 3;          // Bạn bè chính thức
  BLOCKED = 4;           // Đã đưa vào danh sách chặn
}

// Real-Time Online Presence Status
enum OnlinePresenceStatus {
  STATUS_OFFLINE = 0;
  STATUS_ONLINE = 1;
  STATUS_AFK = 2;
  STATUS_IN_COMBAT = 3;
}

// Social Operation Error Codes
enum SocialErrorCode {
  SOCIAL_OK = 0;
  SOCIAL_ERR_PLAYER_NOT_FOUND = 1;
  SOCIAL_ERR_ALREADY_FRIENDS = 2;
  SOCIAL_ERR_REQUEST_ALREADY_SENT = 3;
  SOCIAL_ERR_REQUEST_NOT_FOUND = 4;
  SOCIAL_ERR_FRIEND_LIST_FULL = 5;       // Tối đa 100 bạn bè
  SOCIAL_ERR_TARGET_FRIEND_LIST_FULL = 6;
  SOCIAL_ERR_BLOCKED_BY_TARGET = 7;
  SOCIAL_ERR_TARGET_IS_SELF = 8;
  SOCIAL_ERR_NOTE_TOO_LONG = 9;          // Tối đa 64 ký tự
  SOCIAL_ERR_RATE_LIMITED = 10;
}

// Guild Member Hierarchy Roles
enum GuildMemberRole {
  GUILD_ROLE_UNSPECIFIED = 0;
  GUILD_MEMBER = 1;    // Huynh Đệ / Thành viên
  GUILD_OFFICER = 2;   // Trưởng Lão
  GUILD_MASTER = 3;    // Bang Chủ / Đầu Lĩnh
}

// Friend Record with Real-Time Presence Metadata
message FriendEntry {
  string account_id = 1;
  string friend_account_id = 2;
  string friend_name = 3;
  string friend_class = 4;
  int32 friend_level = 5;
  string current_zone_id = 6;
  string current_zone_name = 7;
  OnlinePresenceStatus presence_status = 8;
  string friend_note = 9;                // Ghi chú bạn bè (max 64 chars)
  FriendRelationStatus status = 10;
  int64 created_at_ms = 11;
  int64 last_seen_ms = 12;
}

// Blocked Player Record
message BlockedPlayerEntry {
  string account_id = 1;
  string blocked_account_id = 2;
  string blocked_name = 3;
  int64 blocked_at_ms = 4;
}

// Guild Member Record with Presence for Teleport Targeting
message GuildRosterMember {
  string player_id = 1;
  string player_name = 2;
  string character_class = 3;
  int32 level = 4;
  GuildMemberRole role = 5;
  string current_zone_id = 6;
  string current_zone_name = 7;
  OnlinePresenceStatus presence_status = 8;
  int64 last_seen_ms = 9;
}

// Request / Response Messages

message SendFriendRequestRequest {
  string account_id = 1;
  string target_name_or_id = 2;
}

message SendFriendRequestResponse {
  bool success = 1;
  SocialErrorCode error_code = 2;
  string error_message = 3;
}

message FriendRequestNotice {
  string sender_account_id = 1;
  string sender_name = 2;
  string sender_class = 3;
  int32 sender_level = 4;
  int64 timestamp_ms = 5;
}

message RespondFriendRequestRequest {
  string account_id = 1;
  string target_account_id = 2;
  bool accept = 3;
}

message RespondFriendRequestResponse {
  bool success = 1;
  FriendEntry friend_entry = 2;
  SocialErrorCode error_code = 3;
  string error_message = 4;
}

message RemoveFriendRequest {
  string account_id = 1;
  string friend_account_id = 2;
}

message RemoveFriendResponse {
  bool success = 1;
  SocialErrorCode error_code = 2;
  string error_message = 3;
}

message BlockPlayerRequest {
  string account_id = 1;
  string target_account_id = 2;
}

message BlockPlayerResponse {
  bool success = 1;
  SocialErrorCode error_code = 2;
  string error_message = 3;
}

message UnblockPlayerRequest {
  string account_id = 1;
  string target_account_id = 2;
}

message UnblockPlayerResponse {
  bool success = 1;
  SocialErrorCode error_code = 2;
  string error_message = 3;
}

message SetFriendNoteRequest {
  string account_id = 1;
  string friend_account_id = 2;
  string friend_note = 3;
}

message SetFriendNoteResponse {
  bool success = 1;
  SocialErrorCode error_code = 2;
  string error_message = 3;
}

message GetFriendListRequest {
  string account_id = 1;
}

message GetFriendListResponse {
  repeated FriendEntry friends = 1;
  int32 total_online = 2;
}

message GetBlockListRequest {
  string account_id = 1;
}

message GetBlockListResponse {
  repeated BlockedPlayerEntry blocked_players = 1;
}

message GetGuildRosterRequest {
  string guild_id = 1;
}

message GetGuildRosterResponse {
  repeated GuildRosterMember members = 1;
  int32 total_online = 2;
}

// Real-Time Push Notification: Presence Updated
message PresenceUpdateNotice {
  string account_id = 1;
  string character_name = 2;
  string character_class = 3;
  int32 level = 4;
  string current_zone_id = 5;
  string current_zone_name = 6;
  OnlinePresenceStatus status = 7;
  int64 timestamp_ms = 8;
}
