syntax = "proto3";

package freeexile.chat;

enum ChatChannel {
    CHANNEL_UNSPECIFIED = 0;
    CHANNEL_WORLD = 1;      // Toàn cõi Vô Định Hoang Giới (Server-wide, rate limited, tiêu hao Chân Khí)
    CHANNEL_ZONE = 2;       // Khu vực hiện tại (Bản đồ / Phân vùng AOI)
    CHANNEL_GUILD = 3;      // Bang Hội / Tông Môn nội bộ
    CHANNEL_PARTY = 4;      // Tổ đội săn Boss / Vượt Ải
    CHANNEL_WHISPER = 5;    // Mật thư riêng tư 1-1
    CHANNEL_SYSTEM = 6;     // Thông báo Thiên Đạo (Boss xuất thế, đập đồ Thái Cổ thành công)
    CHANNEL_RECRUIT = 7;    // Chiêu mộ hiệp lữ / Lập đội
    CHANNEL_FEEDBACK = 8;   // Kênh Góp Ý & Hỗ Trợ Kỹ Thuật (Direct GM / Dev Pipeline)
}

message ItemAffix {
    string affix_id = 1;
    string stat_name = 2;
    float stat_value = 3;
    bool is_implicit = 4;
}

message ItemLinkSnapshot {
    string item_uuid = 1;
    string item_name_key = 2;
    int32 rarity = 3;           // 1: Phàm, 2: Linh, 3: Cực, 4: Thần, 5: Thái Cổ
    int32 element = 4;          // 1: Kim, 2: Mộc, 3: Thủy, 4: Hỏa, 5: Thổ
    int32 quality = 5;          // 0-20%
    int32 item_level = 6;
    repeated ItemAffix affixes = 7;
    string crafter_name = 8;
    string hmac_signature = 9;  // Chữ ký xác thực Server HMAC-SHA256 (Chống spoof đồ giả)
    int64 created_at_ms = 10;
}

message ChatMessage {
    string message_id = 1;
    int64 sender_id = 2;
    string sender_name = 3;
    string sender_title = 4;    // Danh hiệu võ học (Kiếm Thánh, Độc Vương)
    string sender_guild_tag = 5;
    ChatChannel channel = 6;
    int64 target_id = 7;        // Dành cho kênh WHISPER
    string raw_content = 8;
    string filtered_content = 9; // Nội dung đã được lọc từ ngữ nhạy cảm
    repeated ItemLinkSnapshot linked_items = 10;
    int64 timestamp_ms = 11;
    bool is_censored = 12;
    int32 moderation_risk_score = 13; // Điểm rủi ro (Spam, RMT, Lừa đảo)
}

message SendChatRequest {
    int64 sender_id = 1;
    ChatChannel channel = 2;
    int64 target_id = 3;
    string content = 4;
    repeated string link_item_uuids = 5; // Danh sách UUID vật phẩm người chơi muốn khoe
}

message SendChatResponse {
    bool success = 1;
    string error_message = 2;
    string message_id = 3;
    int64 cooldown_remaining_ms = 4; // Thời gian hồi kẹp kênh thế giới (Anti-spam)
}

message QueryItemSnapshotRequest {
    string item_uuid = 1;
    string hmac_signature = 2;
}

message QueryItemSnapshotResponse {
    bool is_valid = 1;
    ItemLinkSnapshot item_snapshot = 2;
}
