syntax = "proto3"; package game_event; option go_package = ".;game_event"; option java_package = "com.gmail.dangnguyendota.event"; option java_outer_classname = "GameServerEvent"; // Request represents a request message that can contain various types of requests. message Request { oneof message { // leave_room is a request to leave a room. RequestLeaveRoom leave_room = 1; // send_chat_message is a request to send a chat message. RequestSendChatMessage send_chat_message = 2; // create_room is a request to create a new room. RequestCreateRoom create_room = 3; // join_room is a request to join an existing room. RequestJoinRoom join_room = 4; // join_any_room is a request to join any available room. RequestJoinAnyRoom join_any_room = 5; // get_room_list is a request to get a list of rooms. RequestGetRoomList get_room_list = 6; // data_send is a request to send data. RequestDataSend data_send = 7; // room_config is a request to configure a room. RequestRoomConfig room_config = 8; // find_room is a request to find a specific room. RequestFindRoom find_room = 10; // free_users_list is a request to get a list of free users. RequestGetListFreeUsers free_users_list = 11; // invite is a request to invite a user. RequestInvite invite = 12; } } // Response represents a response message that can contain various types of responses. message Response { oneof message { // error is a response containing an error message. ResponseError error = 1; // game_message is a response containing a game message. ResponseGameMessage game_message = 2; // chat_message is a response containing a chat message. ResponseChatMessage chat_message = 3; // room_list is a response containing a list of rooms. ResponseRoomList room_list = 4; // room_config is a response containing room configuration details. ResponseRoomConfig room_config = 5; // find_room is a response containing details of a found room. ResponseFindRoom find_room = 9; // free_users_list is a response containing a list of free users. ResponseGetListFreeUsers free_users_list = 10; // invite is a response containing an invitation. ResponseInvite invite = 11; // someone_invited_you is a response indicating that someone has invited you. ResponseSomeoneInvitedYou someone_invited_you = 12; } } message ResponseError { // 100: lỗi ko tìm thấy payload trong req // 101: payload type bị sai // 102: có người đang login tài khoản này rồi // 103: không tìm thấy phòng // 104: id phòng không hợp lệ // 105: phòng đang bị tạm dừng không thể thực hiện tao tác // 106: sảnh đã đầy // 108: sai mật khẩu // 109: không thể tham gia vào phòng này // 110: quá nhiều yêu cầu đang được xử lý, vui lòng chờ // 111: yêu cầu đã quá hạn thời gian chờ tối đa // 113: phòng đã đầy // 114: bạn đang chơi ở phòng khác // 115: không tìm thấy mức cược này // 116: không tìm thấy thông tin người chơi // 117: bạn không thể tạo phòng // 118: bạn không trong phòng này // 119: gửi gói join 2 lần // 120: ko đủ tiền uint32 code = 1; // gắm tag cho lỗi để client detect lỗi này là do gói nào gửi lên bị // error không gắn tag thì default = 0 // 100: RequestGetRoomConfig // 101: RequestCreateRoom // 102: RequestJoinRoom // 103: RequestJoinAnyRoom // 104: RequestGetRoomList // 105: RequestAutoExit // 106: RequestSendData // 107: RequestSendChat // 108: RequestFindRoom // 109: RequestGetListFreeUsers // 110: RequestInvite uint32 tag = 2; } message Player { int32 user_id = 1; int32 avatar = 2; string name = 3; int32 vip = 4; } // mời người chơi khác vào phòng message RequestInvite { int32 room_id = 1; string password = 2; int32 user_id = 3; } message ResponseInvite { int32 user_id = 1; } // gói này gửi khi có người mời bạn vào phòng message ResponseSomeoneInvitedYou { int32 user_id = 1; string name = 2; int32 avatar = 3; int32 room_id = 4; string password = 5; } // lấy danh sách người chơi có thể jon vào bàn với mức cược bet và đang ko chơi game nào message RequestGetListFreeUsers { int64 bet = 1; } message ResponseGetListFreeUsers { repeated Player players = 1; } // tìm phòng message RequestFindRoom { int32 room_id = 1; } message ResponseFindRoom { int32 room_id = 1; // true thì hiện ô nhập mật khẩu cho user bool is_private = 2; } // yêu cầu join room chỉ định sẵn message RequestJoinRoom { int32 room_id = 1; // password nếu có, nếu room ko phải private thì để trống string password = 2; // true nếu ngồi xem chứ không chơi (tạm thời chưa làm tính năng này nên đề false) bool is_viewer = 3; } // tạo phòng message RequestCreateRoom { // mức cược bàn int64 bet = 1; // mật khẩu trong TH là private room, nếu ko thì đặt là rỗng string password = 2; // số lượng người chơi tối đa int32 max_players = 3; // tên room string name = 4; } // yêu cầu vào 1 bàn bất kì message RequestJoinAnyRoom { // mức cược bàn int64 bet = 1; // số người chơi tối đa // nếu = 0 thì lấy tất cả các bàn // nếu != 0 thì sẽ lấy các bàn có max player = số này uint32 max_players = 2; } // lấy danh sách phòng message RequestGetRoomList { // mức cược int64 bet = 1; } // thông tin phòng message Room { int32 room_id = 1; // true nếu là private room bool is_private = 2; int64 bet = 3; int32 create_time = 4; // max_players :số người chơi tối đa // number_of_players :số người đang trong room // label : hiển thị tên room hoặc tên người chơi trong room map metadata = 5; // tên room string name = 6; } // trả về danh sách phòng message ResponseRoomList { int64 bet = 1; repeated Room rooms = 2; } // yêu cầu rời phòng message RequestLeaveRoom { int32 room_id = 1; } // có người chơi nào đó gửi chat message ResponseChatMessage { int32 room_id = 1; int32 user_id = 2; string message = 3; string name = 4; int32 vip = 5; } // gửi tin nhắn vào 1 room, gói này chỉ để dùng cho chat message RequestSendChatMessage { int32 room_id = 1; string message = 2; repeated int32 to = 3; bool is_private_chat = 4; } // loại phòng message RoomType { // mức cược int64 bet = 1; // ccu của mức cược này int32 ccu = 2; // true nếu có thể chơi ở mức cược này bool joinable = 3; // vip của user int32 vip_min = 4; int32 vip_max = 5; // số game đã chơi int32 number_of_played_games_min = 6; int32 number_of_played_games_max = 7; // tiền vào bàn int64 chip_amount_min = 8; int64 chip_amount_max = 9; // level của user int32 level_min = 10; int32 level_max = 11; } // yêu cầu lấy room config message RequestRoomConfig { } // trả về danh sách config của các loại phòng message ResponseRoomConfig { repeated RoomType room_types = 1; // true nếu disable tạo bàn bool disable_create = 2; // true nếu disable tìm bàn bool disable_find = 3; // true nếu disable list bàn bool disable_get_list = 4; // true nếu disable chọn mức cược (ấn vào không được mà chi ấn dc playnow) bool disable_select = 5; // true nếu nhảy vào game luôn bool play_now = 6; // mức cược tốt nhất int64 best_choice = 7; } // gửi gói tin vào trong room message RequestDataSend { // room id cần gửi int32 room_id = 1; oneof msg { // data gửi về bytes data = 2; RequestAutoLeave auto_leave = 3; } } // yêu cầu rời phòng message RequestAutoLeave { } // gói tin được gửi về từ room của người chơi message ResponseGameMessage { int32 room_id = 1; oneof msg { bytes data = 2; ResponseAutoLeave auto_leave = 4; ResponseResetGame reset_game = 5; ResponseUserLeft user_left = 6; ResponseStartCountdown start_countdown = 7; ResponseUserJoined user_joined = 8; ResponseStartGame start_game = 9; } int32 create_time = 3; } // người chơi vừa vào phòng message ResponseUserJoined { int32 user_id = 1; string name = 2; int64 chip = 3; int32 avatar = 4; // chỗ ngồi, từ 0 -> max seat int32 seat = 5; int32 room_id = 6; // 0 = view đang ngồi xem // 1 = play đang chơi game int32 state = 7; int32 vip = 8; int32 level = 9; } // người chơi thoát phòng message ResponseUserLeft { int32 user_id = 1; // true nếu người chơi bị disconnect bool disconnect = 2; } message ResponseAutoLeave { int32 user_id = 1; // true nếu hết ván sẽ tự động out room bool auto_exit = 2; } // chuyển trạng thái game về dạng ban đầu chưa bắt đầu ván message ResponseResetGame { message Player { int32 user_id = 1; string name = 2; int64 chip = 3; int32 avatar = 4; // chỗ ngồi, từ 0 -> max seat int32 seat = 5; // 0 = view đang ngồi xem // 1 = play đang chơi game int32 state = 7; int32 vip = 8; int32 level = 9; } repeated Player players = 1; } message ResponseStartCountdown { int32 seconds = 1; // gói tin in game bytes data = 2; } message ResponseStartGame { message Player { int32 user_id = 1; string name = 2; int64 chip = 3; int32 avatar = 4; // chỗ ngồi, từ 0 -> max seat int32 seat = 5; // 0 = view đang ngồi xem // 1 = play đang chơi game int32 state = 7; int32 vip = 8; int32 level = 9; } // danh sách player repeated Player players = 1; // data in game, tương tự gói game message nhưng mà cho vào đây bytes data = 2; }