syntax = "proto3";

package hyapp.robot.v1;

option go_package = "hyapp.local/api/proto/robot/v1;robotv1";

// RequestMeta 是 robot-service 内部 RPC 的租户和追踪上下文；不要把 app_code 放到业务字段里绕过统一鉴权链路。
message RequestMeta {
  string request_id = 1;
  string caller = 2;
  int64 actor_user_id = 3;
  int64 sent_at_ms = 4;
  string app_code = 5;
}

message Robot {
  string app_code = 1;
  string robot_scope = 2;
  string game_id = 3;
  string room_scene = 4;
  int64 user_id = 5;
  string status = 6;
  int64 created_by_admin_id = 7;
  int64 created_at_ms = 8;
  int64 updated_at_ms = 9;
  int64 last_used_at_ms = 10;
  int64 used_count = 11;
}

message ListGameRobotsRequest {
  RequestMeta meta = 1;
  string game_id = 2;
  string status = 3;
  int32 page_size = 4;
  string cursor = 5;
}

message ListGameRobotsResponse {
  repeated Robot robots = 1;
  string next_cursor = 2;
  int64 server_time_ms = 3;
}

message RegisterGameRobotsRequest {
  RequestMeta meta = 1;
  string game_id = 2;
  repeated int64 user_ids = 3;
}

message RegisterGameRobotsResponse {
  repeated Robot robots = 1;
  int64 server_time_ms = 2;
}

message PickGameRobotRequest {
  RequestMeta meta = 1;
  string game_id = 2;
  string match_id = 3;
  int64 selected_at_ms = 4;
  repeated int64 exclude_user_ids = 5;
}

message GameRobotResponse {
  Robot robot = 1;
  int64 server_time_ms = 2;
}

message SetGameRobotStatusRequest {
  RequestMeta meta = 1;
  string game_id = 2;
  int64 user_id = 3;
  string status = 4;
}

message DeleteGameRobotRequest {
  RequestMeta meta = 1;
  string game_id = 2;
  int64 user_id = 3;
}

message DeleteGameRobotResponse {
  bool deleted = 1;
  int64 server_time_ms = 2;
}

message ListRoomRobotsRequest {
  RequestMeta meta = 1;
  string room_scene = 2;
  string status = 3;
  int32 page_size = 4;
  string cursor = 5;
}

message ListRoomRobotsResponse {
  repeated Robot robots = 1;
  string next_cursor = 2;
  int64 server_time_ms = 3;
}

message RegisterRoomRobotsRequest {
  RequestMeta meta = 1;
  string room_scene = 2;
  repeated int64 user_ids = 3;
}

message RegisterRoomRobotsResponse {
  repeated Robot robots = 1;
  int64 server_time_ms = 2;
}

message SetRoomRobotStatusRequest {
  RequestMeta meta = 1;
  string room_scene = 2;
  int64 user_id = 3;
  string status = 4;
}

message DeleteRoomRobotRequest {
  RequestMeta meta = 1;
  string room_scene = 2;
  int64 user_id = 3;
}

message DeleteRoomRobotResponse {
  bool deleted = 1;
  int64 server_time_ms = 2;
}

message PickRoomRobotRequest {
  RequestMeta meta = 1;
  string room_scene = 2;
  string room_id = 3;
  int64 selected_at_ms = 4;
}

message RoomRobotResponse {
  Robot robot = 1;
  int64 server_time_ms = 2;
}

service GameRobotService {
  rpc ListGameRobots(ListGameRobotsRequest) returns (ListGameRobotsResponse);
  rpc RegisterGameRobots(RegisterGameRobotsRequest) returns (RegisterGameRobotsResponse);
  rpc PickGameRobot(PickGameRobotRequest) returns (GameRobotResponse);
  rpc SetGameRobotStatus(SetGameRobotStatusRequest) returns (GameRobotResponse);
  rpc DeleteGameRobot(DeleteGameRobotRequest) returns (DeleteGameRobotResponse);
}

service RoomRobotService {
  rpc ListRoomRobots(ListRoomRobotsRequest) returns (ListRoomRobotsResponse);
  rpc RegisterRoomRobots(RegisterRoomRobotsRequest) returns (RegisterRoomRobotsResponse);
  rpc PickRoomRobot(PickRoomRobotRequest) returns (RoomRobotResponse);
  rpc SetRoomRobotStatus(SetRoomRobotStatusRequest) returns (RoomRobotResponse);
  rpc DeleteRoomRobot(DeleteRoomRobotRequest) returns (DeleteRoomRobotResponse);
}
