syntax = "proto3";

package rpc_world;

//房间相关服务
service Room {
  //创建房间时通知
  rpc CreateRoom (CreateRoomRequest) returns (CreateRoomReply) {}
 
  //加入房间时通知
  rpc JoinRoom (JoinRoomRequest) returns (JoinRoomReply) {}
  
  //销毁房间时通知
  rpc DestroyRoom (DestroyRoomRequest) returns (DestroyRoomReply) {}
 
  //房间变化时通知
  rpc ModifyRoomInfo (ModifyRoomInfoRequest) returns (ModifyRoomInfoReply) {}

  //获取房间唯一id
  rpc GetNewRoomID (GetRoomIDRequest) returns (GetRoomIDReply) {}
 
  //检查一个玩家id是否是俱乐部的管理员id
  rpc CheckClubManager (CheckClubManagerRequest) returns (CheckClubManagerReply) {}
  
  //检查一个玩家id是否是指定俱乐部的成员（管理员也是成员）
  rpc CheckClubMember (CheckClubMemberRequest) returns (CheckClubMemberReply) {}

  //玩家买入通知
  rpc PlayerBuyin (PlayerBuyinRequest) returns (PlayerBuyinReply) {}

//为同步实时数据新增 2017-2-24
  //获取玩家数据
  rpc GetUserData (GetUserDataRequest) returns (GetUserDataReply) {}

  //操作玩家金币
  rpc WorldOprateUserGold (WorldOprateUserGoldRequest) returns (WorldOprateUserGoldReply) {}

//检查是否能够创建俱乐部牌局
  rpc CheckCreateClubRoom (CheckCreateClubRoomRequest) returns (CheckCreateClubRoomReply) {}

  //击中牌型
  rpc HitCardType (HitCardTypeRequest) returns (HitCardTypeReply) {}

  //抽水入jackpot
  rpc DrawinJackpot (DrawinJackpotRequest) returns (DrawinJackpotReply) {}

  //获取房间所对应的联盟俱乐部
  rpc GetUserAllianceClubs (GetUserAllianceClubsRequest) returns (GetUserAllianceClubsReply) {}
  
  //获取联盟俱乐部买入额度
  rpc GetAllianceBuyinLimit(GetAllianceBuyinLimitRequest) returns (GetAllianceBuyinLimitReply) {}

  //设置联盟俱乐部当前已买入额度
  rpc SetAllianceCurBuyinLimit(SetAllianceCurBuyinLimitRequest) returns (SetAllianceCurBuyinLimitReply) {}

  //检查是否能够创建俱乐部牌局
  rpc CheckClubsMember (CheckClubsMemberRequest) returns (CheckClubsMemberReply) {}
	
  //通知World 玩家当前上台的金币剩余数额
  rpc WorldOperateUserLeftGold(WorldOperateUserLeftGoldRequest) returns (WorldOperateUserLeftGoldReply) {}

  //通知world Game已经重新启动  需要清除发现列表信息  以及返还玩家带上桌的金币
  rpc NotifyWorldGameRestart(NotifyWorldGameRestartRequest) returns (NotifyWorldGameRestartReply) {}
  
  //存储收益数据
  rpc StoreIncome (StoreIncomeRequest) returns (StoreIncomeReply) {}
}

//创建房间时通知请求参数
message CreateRoomRequest {
	uint32 create_player_id = 1;
	string creator_name = 2;
	uint32 club_id = 3;
	int32 game_mode = 4; //区分普通牌局/比赛/其它游戏类型
	string room_name = 5; 
	int32 player_count  = 6;   
	int64 small_blind  = 7;   
	int64 big_blind  = 8;  
	int64 buyin_min  = 9;   
	int64 buyin_max  = 10;  
	uint32 create_time = 11;
	bool  buyin_control = 12; 
	bool  insurance = 13; 
	bool  anti_cheating = 14; 
	bool  straddle = 15; 
	bool  rand_seat = 16; 
	int32 ante = 17;
	
	int32 player_count_max 	= 18; //牌桌最大人数
	int32 owner_type 	    = 19; //区分普通牌具/俱乐部牌局/定制俱乐部牌局
	
	int32 rule_time_limit = 20; //牌局时长对应8个时长类型
	uint32 room_id = 21; //房间id
    int32 game_status = 22; //1:牌局准备中； 2:牌局进行中
    uint32 start_time = 23;//未开始=0
    bool is_associated_jackpot          = 24; //是否关联jackpot
	int32 rule_blind_enum 				= 25; //牌局限定大小盲注对应id
	bool is_allin_allfold               = 26; //是否是allin allfold
	repeated uint32 alliance_ids         = 27; //联盟id集合
	bool is_need_statistic              = 28; //是否是game真正创建的牌局（用来计算俱乐部牌局数）
	uint32 extra_time					= 29; //房主主动增加的时间秒数
	bool short_fullhouse_flush_straight_three = 30;
	bool is_opened_drawback = 31;
	bool is_force_showcard = 32;
}

message JoinAllianceInfo {
  uint32 club_id = 1;
  uint32 join_time = 2;
}

message AllianceItem {
  string alliance_name = 1;
  repeated uint32 Clubids = 2;
  repeated JoinAllianceInfo infos = 3;
  uint32 alli_creater_uid = 4;
}

//创建房间时通知返回参数
message CreateRoomReply {
  string message = 1;
	int64 profit_scale = 2;//盈利规模
	int64 drawin_amout = 3;//抽水数额
	repeated uint32 alliance_club_ids = 4;//联盟俱乐部ids
	map<uint32, AllianceItem> mapAllianceClubIds = 5; // 
	repeated uint32 club_adminids = 6;//俱乐部管理员ids
}

//加入房间时通知请求参数
message JoinRoomRequest {
	uint32 room_id = 1;
	uint32 user_id = 2;
	bool is_alliance = 3;
}

//加入房间时通知返回参数
message JoinRoomReply {
  string message = 1;
}

//销毁房间时通知请求参数
message DestroyRoomRequest {
	  uint32 id = 1;
      uint32 club_id = 2;
}

//销毁房间时通知返回参数
message DestroyRoomReply {
  string message = 1;
}

//房间信息变化时通知请求参数
message ModifyRoomInfoRequest {
  uint32 id = 1;				  //房间id
  int32 player_count  = 2;    //当前人数
  int32 game_status = 3; //1:牌局准备中； 2:牌局进行中
  uint32 start_time = 4; //未开始=0；已点击开始=点击时间
  uint32 extra_time = 5; //房主主动增加的时间秒数
}

//房间信息变化时通知返回参数
message ModifyRoomInfoReply {
  string message = 1;
}


//获取房间唯一id信息请求
message GetRoomIDRequest {
    string name = 1; // 房间名字（占位而已，暂时没有作用）
	uint32 playerid = 2; //请求者的玩家id 用于snowflak空间
}

//房间唯一id信息返回
message GetRoomIDReply {
  string room_uuid = 1; //room的全局唯一字符串id（同cf 的uuid）
  uint32 roomid = 2; //房间的int 6位数唯一id
  uint64 uuid_int = 3; //int uuid
}


//检查是否是俱乐部管理员请求
message CheckClubManagerRequest {
    uint32 playerid = 1; //玩家id
    uint32 clubid   = 2; //俱乐部id
}

//检查是否是俱乐部管理员响应
message CheckClubManagerReply {
  bool result = 1; //true : 玩家是管理员； false:玩家不是管理员
}

 //检查一个玩家id是否是指定俱乐部的成员（管理员也是成员）请求
message CheckClubMemberRequest {
    uint32 playerid = 1; //玩家id
    uint32 clubid   = 2; //俱乐部id
}

//检查一个玩家id是否是指定俱乐部的成员响应
message CheckClubMemberReply {
  bool result = 1; //true : 玩家是成员； false:玩家不是成员
} 

//玩家买入时通知请求参数
message PlayerBuyinRequest {
	uint32 user_id = 1;
	uint32 club_id = 2; //俱乐部id
}

//玩家买入时通知返回参数
message PlayerBuyinReply {
  string message = 1;
}

//为同步实时数据新增 2017-2-24
//获取玩家数据信息请求
message GetUserDataRequest {
    uint32 user_id = 1; //玩家id
}

//获取玩家数据信息返回
message GetUserDataReply {
	uint32 user_id = 1; //玩家id
	string user_name = 2; //用户名
	int32 gender = 3; //性别
	uint64 diamond_num = 4;//钻石数量
	int64 user_gold = 5;//用户金币
	string avatar_thumb = 6;//用户头像
	string marks = 7;//签名
}

enum FeeType {
	Enum_game 			        = 0;
	Enum_InteractiveExpression  = 1;
	Enum_SendCardFun  			= 2;
	Enum_MTT 			        = 3;
	Enum_SNG 			        = 4;
}

//操作玩家金币请求
message WorldOprateUserGoldRequest {
	uint32 user_id = 1; //玩家id
    int32 operate_type = 2; //1:增加金币 2：扣除金币
	int64 gold_num = 3; //钻石数量
	uint64 room_id = 4; //房间id
	FeeType fee_type = 5;//扣费类型
}

//操作玩家金币返回
message WorldOprateUserGoldReply {
	int32 err_num = 1; //错误码 1：没错误 2：金币数额不足 
	int64 gold_before = 2;
	int64 gold_after  = 3; 
}

//检查俱乐部牌局创建请求
message CheckCreateClubRoomRequest {
  uint32 user_id = 1; //创建牌局玩家id
  uint32 club_id = 2; //俱乐部id
}

//检查俱乐部牌局创建返回
message CheckCreateClubRoomReply {
int32 err_num = 1; //错误码 1：成功，可以创建；74：不是俱乐部管理员，不能创建；75：俱乐部等级不够开启更多房间；76：其他错误 

}

message UserCard{
	int32 card_level = 1;
	uint32 seat_id = 2;
	uint32 award_player_id = 3;
}

// 击中牌型请求奖励
message HitCardTypeRequest {
  repeated UserCard cards = 1;
  uint32 club_id = 2; //俱乐部id
  int32 blind_level = 3; //盲注级别
  uint32 room_id = 4; //房间id
  uint64 game_UUIDInt = 5; //牌局id
  uint64 room_UUIDInt = 6; //房间id
  uint32 Create_player_id = 7; //房间创建者id 
}

message UserCardAward{
	uint32 award_player_id = 1;
	uint32 seat_id = 2;
	int64 award_amount = 3;
	int32 card_level = 4;
	int64 award2_club_fund = 5;
}

// 击中牌型返回奖励
message HitCardTypeReply {
  repeated UserCardAward cardAwards = 1;
  uint32 club_id = 2; //俱乐部id
  int32 blind_level = 3; //盲注级别
  uint32 room_id = 4; //房间id
  int64 total_award_amount = 5;
  int32 err_num = 6; //错误码 1：没错误 2：数据库错误
}

//符合条件的玩家抽水如jackpot
message DrawinJackpotRequest {
  uint32 club_id = 1; //俱乐部id
  int32 blind_level = 2; //盲注级别
  int64 drawin_amout = 3; //抽取金额
  uint64 room_id = 4; //房间id
}

//符合条件的玩家抽水如jackpot
message DrawinJackpotReply {
  int32 err_num = 1; //错误码 1：成功
}

//获取玩家联盟相关的俱乐部
message GetUserAllianceClubsRequest {
    uint32 user_id = 1; //玩家id
	uint32 room_id = 2; //房间id
}

message clubInfo{
	uint32 club_id = 1;
	uint32 creater_id = 2;
	string club_name = 3;
}

//获取玩家数据信息返回
message GetUserAllianceClubsReply {
  repeated clubInfo club_infos         = 1; //联盟id集合
  int32 err_num = 2; //错误码 1：没错误 2：数据库错误
  repeated uint32 club_createrids         = 3; //俱乐部创建者id集合
}

message GetAllianceBuyinLimitRequest {
    uint32 alliance_id = 1; //联盟id
	uint32 club_id = 2; //俱乐部id
}

message GetAllianceBuyinLimitReply {
  int64 MaxBuyinLimit = 1;
  int64 CurBuyinLimit = 2;
  bool contorl_buyin = 3;
  int32 err_num = 4; //错误码 1：没错误 2：数据库错误
}

message SetAllianceCurBuyinLimitRequest {
    uint32 alliance_id = 1; //联盟id
	uint32 club_id = 2; //俱乐部id
	int32 CurBuyinLimit = 3; //当前已用额度
}

message SetAllianceCurBuyinLimitReply {
  int32 err_num = 1; //错误码 1：没错误 2：数据库错误
}

//检查是否为创建者俱乐部的成员
message CheckClubsMemberRequest {
  uint32 club_createrid = 1; //俱乐部创建者
  uint32 user_id = 2; //玩家id
}

//检查是否为创建者俱乐部的成员
message CheckClubsMemberReply {
  bool is_club_member = 1;
  int32 err_num = 2; // 其他错误 
}

//通知world玩家剩余在桌上的金币
message WorldOperateUserLeftGoldRequest {
	uint32 user_id = 1;	//玩家id
	int32 left_gold = 2;	//剩余在桌上的金币数量
	uint32 roomid = 3;	//当前房间id
}

//通知world玩家剩余在桌上的金币
message WorldOperateUserLeftGoldReply {
	int32 error = 1;  //错误码
	int32 gold_value = 2; //操作后的买入金币的值
}

message NotifyWorldGameRestartRequest {

}

message NotifyWorldGameRestartReply {
	int32 error = 1;
}

message ClubCreaterUIDIncome {
	uint32 UID = 1;
	int64 fee = 2;
	int64 insurance = 3;
	int64 jackpot = 4;
}

message AlliCreaterUIDIncome {
	uint32 UID = 1;
	int64 fee = 2;
	int64 insurance = 3;
	int64 jackpot = 4;
}

message ProxIncome {
	int64 fee = 1;
	int64 insurance = 2;
	int64 jackpot = 3;
}

message PlatformIncome {
	int64 fee = 1;
	int64 insurance = 2;
	int64 jackpot = 3;
}

message StoreIncomeRequest {
	repeated ClubCreaterUIDIncome ccuid_income    = 1; //俱乐部创建者收益
	repeated AlliCreaterUIDIncome acuid_income    = 2; //联盟创建者（玩家）收益
	ProxIncome           proxy_income    = 3; //总代收益
	PlatformIncome       platform_income = 4; //平台收益
}

message StoreIncomeReply {
	int32 error = 1;
}
