//------------------------------------------------------------------------- // 请求搜索牌桌 public void requestSearchDesktop(DesktopSearchFilter search_filter) { // 开始转菊花 //UiHelper.CreateWaiting("正在找牌桌...", false); DesktopSearchFilter = search_filter; PlayerLobbyRequest lobby_request; lobby_request.id = PlayerLobbyRequestId.SearchDesktop; lobby_request.data = EbTool.protobufSerialize(search_filter); CoApp.rpc(MethodType.c2sPlayerLobbyRequest, lobby_request); }
//--------------------------------------------------------------------- // 请求查询可以立即玩的桌子 async Task <DesktopInfo> ICellDesktopService.searchDesktopAuto(DesktopRequestPlayerEnter request_enter) { Logger.Info("searchDesktopAuto()"); DesktopInfo desktop_info = null; // 根据玩家属性限定搜索条件 DesktopSearchFilter desktop_search_filter = new DesktopSearchFilter(); desktop_search_filter.is_vip = request_enter.is_vip; desktop_search_filter.seat_num = 6; desktop_search_filter.is_seat_full = false; desktop_search_filter.desktop_tableid = 1; var grain_desktopservice = GrainFactory.GetGrain <ICellDesktopService>(0); List <DesktopInfo> list_desktop = await grain_desktopservice.searchDesktop(desktop_search_filter); if (list_desktop == null || list_desktop.Count == 0) { goto End; } string desktop_etguid = list_desktop[0].desktop_etguid; // 进入桌子 var grain_desktop = GrainFactory.GetGrain <ICellDesktop>(new Guid(desktop_etguid)); desktop_info = await grain_desktop.s2sGetDesktopInfo(); End: if (desktop_info == null) { desktop_info = new DesktopInfo(); } return(desktop_info); }
//------------------------------------------------------------------------- public void enterLobby(DesktopSearchFilter search_filter) { InLobby = true; requestSearchDesktop(search_filter); }
//--------------------------------------------------------------------- // 请求根据查询条件查找桌子 async Task <List <DesktopInfo> > ICellDesktopService.searchDesktop(DesktopSearchFilter desktop_search_filter) { Logger.Info("searchDesktop()"); string query = string.Format(@"SELECT {0}, {1}, {2}, {3}, {4}, {5}, {6} FROM Fishing as QueryDesktop WHERE seat_num=$1 and game_speed=$2 and is_vip=$3 and desktop_tableid=$4 LIMIT 10;" , "desktop_etguid" , "seat_num" , "game_speed" , "desktop_tableid" , "list_seat_player" , "seat_player_num" , "all_player_num"); IQueryRequest query_request = QueryRequest.Create(query) .ScanConsistency(ScanConsistency.RequestPlus) .AddPositionalParameter(desktop_search_filter.seat_num) .AddPositionalParameter(desktop_search_filter.is_vip) .AddPositionalParameter(desktop_search_filter.desktop_tableid); var result = await DbClientCouchbase.Instance.Bucket.QueryAsync <QueryDesktop>(query_request); List <DesktopInfo> list_desktop = new List <DesktopInfo>(); if (result.Success) { // 对结果集进行处理 foreach (var i in result.Rows) { QueryDesktop query_desktop = i; if (string.IsNullOrEmpty(query_desktop.desktop_etguid)) { continue; } DesktopInfo desktop_info = new DesktopInfo(); desktop_info.desktop_etguid = query_desktop.desktop_etguid; desktop_info.seat_num = query_desktop.seat_num; desktop_info.is_vip = desktop_search_filter.is_vip; desktop_info.desktop_tableid = desktop_search_filter.desktop_tableid; desktop_info.seat_player_num = query_desktop.seat_player_num; desktop_info.all_player_num = query_desktop.all_player_num; desktop_info.list_seat_player = new List <DesktopPlayerInfo>(); if (query_desktop.list_seat_player != null) { foreach (var j in query_desktop.list_seat_player) { DesktopPlayerInfo info = new DesktopPlayerInfo(); info.seat_index = j.seat_index; info.player_etguid = j.player_etguid; info.nick_name = j.nick_name; info.icon = j.icon; info.chip = j.chip; desktop_info.list_seat_player.Add(info); } } list_desktop.Add(desktop_info); } } // Couchbase中没有找到桌子,则创建一批符合条件的桌子 if (list_desktop.Count < 10) { //for (int i = 0; i < 10; i++) { // 创建桌子 var grain_desktop = GrainFactory.GetGrain <ICellDesktop>(Guid.NewGuid()); string desktop_etguid = grain_desktop.GetPrimaryKey().ToString(); //GetLogger().Info("GrainCellDesktopService.searchDesktop() 创建新桌子,DesktopEtGuid={0}", desktop_etguid); DesktopInfo desktop_info = new DesktopInfo(); desktop_info.desktop_etguid = desktop_etguid; desktop_info.seat_num = desktop_search_filter.seat_num; desktop_info.is_vip = desktop_search_filter.is_vip; desktop_info.desktop_tableid = desktop_search_filter.desktop_tableid; desktop_info.all_player_num = 0; desktop_info.seat_player_num = 0; desktop_info.list_seat_player = new List <DesktopPlayerInfo>(); list_desktop.Add(desktop_info); grain_desktop.s2sSetupDesktop(desktop_info); } } return(list_desktop); }