Example #1
0
        //---------------------------------------------------------------------
        // 请求查询指定桌子
        async Task <DesktopInfo> ICellDesktopService.searchDesktop(string desktop_etguid, DesktopRequestPlayerEnter request_enter)
        {
            Logger.Info("searchDesktop()");

            DesktopInfo desktop_info = null;

            if (string.IsNullOrEmpty(desktop_etguid))
            {
                goto End;
            }

            // 首先查询桌子是否存在
            string key    = "CacheDesktopData_" + desktop_etguid;
            bool   exists = false;

            if (!exists)
            {
                goto End;
            }

            // 进入桌子
            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);
        }
Example #2
0
        //-------------------------------------------------------------------------
        public override void init()
        {
            Init            = false;
            CacheDesktopKey = "CacheDesktopData_" + Entity.Guid;

            DesktopConfigData = new DesktopConfigData();
            DesktopConfigData.desktop_etguid       = Entity.Guid;
            DesktopConfigData.seat_num             = 6;
            DesktopConfigData.is_vip               = false;
            DesktopConfigData.desktop_waitwhile_tm = 60;
            MapAllPlayer1 = new Dictionary <uint, Entity>();
            MapAllPlayer  = new Dictionary <string, Entity>();

            byte index = 0;

            AllSeat = new SeatInfo[DesktopConfigData.seat_num];
            foreach (var i in AllSeat)
            {
                SeatInfo seat_info = new SeatInfo();
                seat_info.index           = index;
                seat_info.et_player_rpcid = 0;
                seat_info.et_playermirror = null;
                AllSeat[index]            = seat_info;
                index++;
            }

            DesktopInfo = new DesktopInfo();
            DesktopInfo.desktop_etguid   = Entity.Guid;
            DesktopInfo.seat_num         = 6;
            DesktopInfo.desktop_tableid  = 1;
            DesktopInfo.is_vip           = false;
            DesktopInfo.list_seat_player = new List <DesktopPlayerInfo>();
            DesktopInfo.all_player_num   = 0;
            DesktopInfo.seat_player_num  = 0;

            QueAoIEvent = new Queue <_tAoIEvent>();
            QuePlayerId = new Queue <byte>();
            MaxPlayerId = 0;
            for (int i = 0; i < 50; i++)
            {
                QuePlayerId.Enqueue(++MaxPlayerId);
            }

            TbDataRoom._eRoomType room_type = TbDataRoom._eRoomType.RT_Tenfold;
            bool           fish_mustdie     = true;
            bool           is_single        = false;
            float          pumping_rate     = 1f;
            string         path_fishlord    = Path.Combine(ServerPath.getPathMediaRoot(), "Fishing\\FishLord\\");
            string         path_route       = Path.Combine(ServerPath.getPathMediaRoot(), "Fishing\\Route\\");
            ILogicListener listener         = new LogicListener(this);

            LogicScene = new CLogicScene();
            LogicScene.create(1, 1.0f, is_single, fish_mustdie, listener, pumping_rate, _getRateList(room_type),
                              CellApp.Instance.jsonCfg.json_packet_list,
                              CellApp.Instance.jsonCfg.route_json_packet_list);
        }
        //---------------------------------------------------------------------
        // 请求根据查询条件查找桌子
        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");
            
            List<DesktopInfo> list_desktop = new List<DesktopInfo>();
            
            // 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;
        }
Example #4
0
        //---------------------------------------------------------------------
        // 请求根据查询条件查找桌子
        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");

            List <DesktopInfo> list_desktop = new List <DesktopInfo>();

            // 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);
        }
Example #5
0
        //-------------------------------------------------------------------------
        // 请求创建私人牌桌
        Task <DesktopInfo> ICellDesktopService.createPrivateDesktop(PrivateDesktopCreateInfo desktop_createinfo)
        {
            Logger.Info("createPrivateDesktop()");

            var    grain_desktop  = GrainFactory.GetGrain <ICellDesktop>(Guid.NewGuid());
            string desktop_etguid = grain_desktop.GetPrimaryKey().ToString();

            DesktopInfo desktop_info = new DesktopInfo();

            desktop_info.desktop_etguid   = desktop_etguid;
            desktop_info.seat_num         = desktop_createinfo.seat_num;
            desktop_info.is_vip           = desktop_createinfo.is_vip;
            desktop_info.desktop_tableid  = desktop_createinfo.desktop_tableid;
            desktop_info.all_player_num   = 0;
            desktop_info.seat_player_num  = 0;
            desktop_info.list_seat_player = new List <DesktopPlayerInfo>();

            grain_desktop.s2sSetupDesktop(desktop_info);

            return(Task.FromResult(desktop_info));
        }
Example #6
0
        //---------------------------------------------------------------------
        // 初始化桌子信息
        public Task s2sSetupDesktop(DesktopInfo desktop_info)
        {
            var tb_desktop = EbDataMgr.Instance.getData <TbDataDesktopInfo>(DesktopInfo.desktop_tableid);

            if (tb_desktop == null)
            {
                EbLog.Error("CellDesktop.s2sSetupDesktop() Error DesktopTableId=" + DesktopInfo.desktop_tableid);
                return(TaskDone.Done);
            }

            Init = true;
            DesktopInfo.seat_num        = desktop_info.seat_num;
            DesktopInfo.desktop_tableid = desktop_info.desktop_tableid;
            DesktopInfo.is_vip          = desktop_info.is_vip;
            DesktopInfo.all_player_num  = desktop_info.all_player_num;
            DesktopInfo.seat_player_num = desktop_info.seat_player_num;
            DesktopInfo.list_seat_player.Clear();

            DesktopConfigData.is_vip = DesktopInfo.is_vip;

            byte index = 0;

            AllSeat = new SeatInfo[DesktopConfigData.seat_num];
            foreach (var i in AllSeat)
            {
                SeatInfo seat_info = new SeatInfo();
                seat_info.index           = index;
                seat_info.et_playermirror = null;
                AllSeat[index]            = seat_info;
                index++;
            }

            string data = EbTool.jsonSerialize(DesktopInfo);

            //DbClientCouchbase.Instance.asyncSave(CacheDesktopKey, data, TimeSpan.FromSeconds(15.0));

            return(TaskDone.Done);
        }
Example #7
0
        //---------------------------------------------------------------------
        // 请求查询可以立即玩的桌子
        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);
        }
        //---------------------------------------------------------------------
        // 请求查询指定桌子
        async Task<DesktopInfo> ICellDesktopService.searchDesktop(string desktop_etguid, DesktopRequestPlayerEnter request_enter)
        {
            Logger.Info("searchDesktop()");

            DesktopInfo desktop_info = null;

            if (string.IsNullOrEmpty(desktop_etguid))
            {
                goto End;
            }

            // 首先查询桌子是否存在
            string key = "CacheDesktopData_" + desktop_etguid;
            bool exists = false;
            if (!exists)
            {
                goto End;
            }

            // 进入桌子
            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;
        }
        //-------------------------------------------------------------------------
        // 请求创建私人牌桌
        Task<DesktopInfo> ICellDesktopService.createPrivateDesktop(PrivateDesktopCreateInfo desktop_createinfo)
        {
            Logger.Info("createPrivateDesktop()");

            var grain_desktop = GrainFactory.GetGrain<ICellDesktop>(Guid.NewGuid());
            string desktop_etguid = grain_desktop.GetPrimaryKey().ToString();

            DesktopInfo desktop_info = new DesktopInfo();
            desktop_info.desktop_etguid = desktop_etguid;
            desktop_info.seat_num = desktop_createinfo.seat_num;
            desktop_info.is_vip = desktop_createinfo.is_vip;
            desktop_info.desktop_tableid = desktop_createinfo.desktop_tableid;
            desktop_info.all_player_num = 0;
            desktop_info.seat_player_num = 0;
            desktop_info.list_seat_player = new List<DesktopPlayerInfo>();

            grain_desktop.s2sSetupDesktop(desktop_info);

            return Task.FromResult(desktop_info);
        }
Example #10
0
        //---------------------------------------------------------------------
        // 请求查询可以立即玩的桌子
        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;
        }
Example #11
0
        //---------------------------------------------------------------------
        // 立即玩
        public async Task enterDesktopPlayNow()
        {
            if (IsEntering)
            {
                EbLog.Note("CellPlayerDesktop.enterDesktopPlayNow() 错误:正在进入中");
                return;
            }
            IsEntering = true;

            if (!string.IsNullOrEmpty(DesktopEtGuid))
            {
                await leaveDesktop();
            }

            DesktopRequestPlayerEnter request_enter;

            request_enter.desktop_etguid = "";
            request_enter.seat_index     = 255;
            request_enter.player_clip    = 0;
            request_enter.player_gold    = CoActor.Def.PropGold.get();
            request_enter.is_vip         = CoActor.Def.mPropIsVIP.get();

            var         grain = Entity.getUserData <GrainCellPlayer>();
            var         grain_desktopservice = grain.GF.GetGrain <ICellDesktopService>(0);
            DesktopInfo desktop_info         = await grain_desktopservice.searchDesktopAuto(request_enter);

            if (string.IsNullOrEmpty(desktop_info.desktop_etguid))
            {
                EbLog.Note("CellPlayerDesktop.enterDesktopPlayNow() 获取桌子信息出错");
            }
            else
            {
                EbLog.Note("CellPlayerDesktop.enterDesktopPlayNow() 获取桌子信息成功");
            }

            // Step1:监听桌子广播
            await _createDesktopStreamConsumer(desktop_info.desktop_etguid);

            // 自动下注
            int bet_chip  = 2000;
            int left_chip = CoActor.Def.PropGold.get();

            if (left_chip < bet_chip)
            {
                bet_chip = left_chip;
            }
            left_chip -= bet_chip;
            CoPlayer.CoActor.Def.PropGold.set(left_chip);

            // Step2:进入桌子并获取桌子初始化信息
            var         grain_desktop = grain.GF.GetGrain <ICellDesktop>(new Guid(desktop_info.desktop_etguid));
            DesktopData desktop_data  = await grain_desktop.s2sPlayerEnter(request_enter, CoPlayer.exportEtPlayerMirror());

            IsEntering    = false;
            DesktopEtGuid = desktop_data.desktop_cfg_data.desktop_etguid;

            DesktopNotify desktop_notify;

            desktop_notify.id   = DesktopNotifyId.DesktopInit;
            desktop_notify.data = EbTool.protobufSerialize <DesktopData>(desktop_data);

            MethodData notify_data = new MethodData();

            notify_data.method_id = MethodType.s2cPlayerDesktopNotify;
            notify_data.param1    = EbTool.protobufSerialize <DesktopNotify>(desktop_notify);
            var grain_player = grain.GF.GetGrain <ICellPlayer>(new Guid(Entity.Guid));

            grain_player.s2sNotify(notify_data);
        }
Example #12
0
 //---------------------------------------------------------------------
 // 初始化桌子信息
 Task ICellDesktopGroup.s2sSetupDesktop(DesktopInfo desktop_info)
 {
     return(TaskDone.Done);
 }
Example #13
0
        //---------------------------------------------------------------------
        // 初始化桌子信息
        Task ICellDesktop.s2sSetupDesktop(DesktopInfo desktop_info)
        {
            var co_desktop = EtDesktop.getComponent <CellDesktop <DefDesktop> >();

            return(co_desktop.s2sSetupDesktop(desktop_info));
        }