コード例 #1
0
        public override List <IGameMessage> HandleData(GameUserSession session, dataPlayerAddCoins Data)
        {
            List <IGameMessage> msgList = new List <IGameMessage>();
            GameManager         gm      = session.GameManager;

            EGameInfo gi       = gm.GameDataHandle.GetGameInfo();
            var       nextUser = gm.PlayerAddCoins(gi, Data.OpenId, Data.Coins, 0);

            if (nextUser == null)
            {
                gi = gm.GameEndShowCard(gi, true);
            }

            var msg = gm.WaitNextPlayer(gi);

            if (msg != null)
            {
                msgList.Add(msg);
            }
            else
            {
                var passMsg = GameMessageHandle.CreateResultPlayerAddCoinsMsg(gm.RoomCode, Data.OpenId, gi.CurBetUserOpenId, Data.Coins);
                msgList.Add(passMsg);
            }
            return(msgList);
        }
コード例 #2
0
        public override void ExecuteCommand(GameUserSession session, SubRequestInfo requestInfo)
        {
            try
            {
                InitInData(requestInfo.Body, session);

                if (Data != null)
                {
                    session.GameAttr.UserOpenId = this.Data.OpenId;

                    var msgData = HandleData(session, this.Data);
                    if (msgData != null)
                    {
                        GameMessageHandle.Push(msgData, session);
                    }
                }
            }
            catch (Exception ex)
            {
                GameMessageHandle.PushErrorMsg(ex.Message, session);
            }

            if (session.Connected)
            {
                GameMessageHandle.Run(session.GameServer);
            }
        }
コード例 #3
0
        public T InitInData(string Body, GameUserSession session)
        {
            Console.WriteLine($"{this.Name}:{Body}");

            if (string.IsNullOrEmpty(Body))
            {
                GameMessageHandle.PushErrorMsg("没有获取数据", session);
                return(null);
            }

            var preData = JsonConvert.DeserializeObject <T>(Body);

            if (!VerifyBaseData(preData, session))
            {
                return(null);
            }

            if (!VerifyCommandData(preData, session))
            {
                return(null);
            }

            Data = preData;

            return(Data);
        }
コード例 #4
0
 private bool VerifyBaseData(T preData, GameUserSession session)
 {
     if (string.IsNullOrEmpty(preData.OpenId))
     {
         GameMessageHandle.PushErrorMsg("错误,没有获取您的身份,请重新登陆", session);
         return(false);
     }
     return(true);
 }
コード例 #5
0
 public override bool VerifyCommandData(dataPlayerAddCoins InData, GameUserSession session)
 {
     if (InData.Coins <= 0)
     {
         base.GameMessageHandle.PushErrorMsg("筹码不能小于0", session);
         return(false);
     }
     return(true);
 }
コード例 #6
0
ファイル: UserSitUp.cs プロジェクト: flysnoopy1984/IQianBa
        public override List <IGameMessage> HandleData(GameUserSession session, dataUserSitUp Data)
        {
            List <IGameMessage> result      = new List <IGameMessage>();
            GameManager         gameManager = session.GameManager;
            var r = gameManager.UserSitUp();

            result.Add(r);
            return(result);
        }
コード例 #7
0
        public void PushErrorMsg(string msgString, GameUserSession session)
        {
            var msg = new MessageNormalError();

            if (session != null)
            {
                msg.SessionId = session.SessionID;
            }
            msg.ErrorMsg = msgString;
            ErrorQueue.Enqueue(msg);
        }
コード例 #8
0
        public void Push(List <IGameMessage> msgList, GameUserSession session = null)
        {
            foreach (var msg in msgList)
            {
                if (session != null)
                {
                    msg.SessionId = session.SessionID;
                }

                Push(msg);
            }
        }
コード例 #9
0
        public override bool VerifyCommandData(dataPlayerPass InData, GameUserSession session)
        {
            GameManager gm = session.GameManager;
            var         gi = gm.GameDataHandle.GetGameInfo();

            if (gi.CurRequireCoins > 0)
            {
                base.GameMessageHandle.PushErrorMsg($"无法过牌,需要跟注[{gi.CurRequireCoins}]", session);
                return(false);
            }
            return(true);
        }
コード例 #10
0
        public override List <IGameMessage> HandleData(GameUserSession session, dataBackHall Data)
        {
            List <IGameMessage> result = new List <IGameMessage>();
            //GameModel.WebSocketData.SendData.ResultBackHall msg = new GameModel.WebSocketData.SendData.ResultBackHall();
            //base.GameMessageHandle.PushDelayMsg(session,msg,5);

            GameManager gameManager = session.GameManager;
            var         r           = gameManager.UserBackHall();

            result.Add(r);
            return(result);
        }
コード例 #11
0
ファイル: GameManager.cs プロジェクト: flysnoopy1984/IQianBa
        public void StartNewGame(GameUserSession session, string RoomCode)
        {
            PrePareNewGameInfo(RoomCode);

            var game = GameDataHandle.GetGameData();

            game.GameCoins = new EGameCoins(RoomCode);



            GameTaskManager.SyncTask_ShuffleEnd(session);
        }
コード例 #12
0
        public override List <IGameMessage> HandleData(GameUserSession session, dataTestStartGame Data)
        {
            List <IGameMessage> result      = new List <IGameMessage>();
            GameManager         gameManager = session.GameManager;

            ResultGameShuffleStart shuffleStartMsg = new ResultGameShuffleStart(Data.RoomCode);

            result.Add(shuffleStartMsg);

            gameManager.StartNewGame(session, Data.RoomCode);

            return(result);
        }
コード例 #13
0
ファイル: UserSitDown.cs プロジェクト: flysnoopy1984/IQianBa
 public override bool VerifyCommandData(dataUserSitDown InData, GameUserSession session)
 {
     if (InData.SeatNo != -1 && InData.SeatNo <= 0)
     {
         base.GameMessageHandle.PushErrorMsg("没有获取座位号!", session);
         return(false);
     }
     if (InData.Coins <= 0)
     {
         base.GameMessageHandle.PushErrorMsg("没有资金不能继续!", session);
         return(false);
     }
     return(true);
 }
コード例 #14
0
        public override List <IGameMessage> HandleData(GameUserSession session, dataDealCardDone Data)
        {
            List <IGameMessage> result = new List <IGameMessage>();

            //GameManager gm = session.GameManager;

            //var gi = gm.PreNextStep(true);
            //var msg = gm.WaitNextPlayer(gi);
            //if (msg != null)
            //    result.Add(msg);


            return(result);
        }
コード例 #15
0
        public override List <IGameMessage> HandleData(GameUserSession session, dataNewConnect data)
        {
            session.GameAttr.UserName = data.UserName;
            session.GameAttr.Weight   = data.Weight;

            session.KeepOneSession(data.OpenId);

            List <IGameMessage> msgList = new List <IGameMessage>();
            var GameManager             = session.GameManager;
            var r = GameManager.FindAvailableRoom(data.Weight);

            if (r.IsSuccess)
            {
                //表明是新房间,则初始化新游戏的数据
                if (r.IntMsg == 0)
                {
                    GameDataHandle.GenerateEmptyGame(session.GameServer, r.SuccessMsg);
                }
                else
                {
                    GameDataHandle.ReCoverData(session.GameServer, r.SuccessMsg);
                }

                session.GameAttr.RoomCode = r.SuccessMsg;
                //用户进入房间
                r = GameManager.UserEntryRoom(r.SuccessMsg);
            }
            if (r.IsSuccess)
            {
                /*【注】如果服务器宕机,GameDataHandle将空*/
                var DataHandle = GameManager.GameDataHandle;
                var oneGame    = DataHandle.GetGameData(true);
                msgList.Add(oneGame);
            }
            else
            {
                msgList.Add(new MessageNormalError(r.ErrorMsg));
            }



            return(msgList);
        }
コード例 #16
0
        public override List <IGameMessage> HandleData(GameUserSession session, dataPlayerFollow Data)
        {
            List <IGameMessage> msgList = new List <IGameMessage>();
            GameManager         gm      = session.GameManager;
            var gi = gm.GameDataHandle.GetGameInfo();

            gm.PlayerFollow(gi, Data.OpenId, Data.FollowCoins);

            gi = gm.PreNextStep(true);

            var dealCards = gm.DealCard(gi);

            if (dealCards != null)
            {
                var followMsg = GameMessageHandle.CreateResultPlayerFollowMsg(gm.RoomCode, Data.OpenId, "", Data.FollowCoins);
                msgList.Add(followMsg);

                gi = gm.PreNextStep(true);
                var cardsMsg = GameMessageHandle.CreateDealCardMsg(gm.RoomCode, dealCards, gi);
                msgList.Add(cardsMsg);

                GameTaskManager.SyncTask_DealCardDone(session, gi);
            }
            else
            {
                var msg = gm.WaitNextPlayer(gi);
                if (msg != null)
                {
                    msgList.Add(msg);
                }
                else
                {
                    var followMsg = GameMessageHandle.CreateResultPlayerFollowMsg(gm.RoomCode, Data.OpenId, gi.CurBetUserOpenId, Data.FollowCoins);
                    msgList.Add(followMsg);
                }
            }

            return(msgList);
        }
コード例 #17
0
ファイル: UserSitUp.cs プロジェクト: flysnoopy1984/IQianBa
 public override bool VerifyCommandData(dataUserSitUp InData, GameUserSession session)
 {
     return(true);
 }
コード例 #18
0
ファイル: UserSitDown.cs プロジェクト: flysnoopy1984/IQianBa
        public override List <IGameMessage> HandleData(GameUserSession session, dataUserSitDown Data)
        {
            List <IGameMessage> result = new List <IGameMessage>();

            //检测用户状态
            GameManager gameManager = session.GameManager;

            //if (!gameManager.CanSitDown())
            //{
            //    result.Add(new MessageNormalError("当前不能入座!请等待"));
            //    return result;
            //}
            //用户坐下
            lock (_lockSitDown)
            {
                var r = gameManager.UserSitDown(Data.SeatNo, Data.Coins);
                if (r.IsSuccess)
                {
                    ResultUserSitDown msg = new ResultUserSitDown(gameManager.RoomCode);
                    msg.RemainCoins = Data.Coins;
                    msg.RoomCode    = r.SuccessMsg;
                    msg.SeatNo      = r.IntMsg;
                    result.Add(msg);
                }
                else
                {
                    result.Add(new MessageNormalError(r.ErrorMsg));
                    return(result);
                }
                //游戏下一阶段
                var gameInfo = gameManager.GetGameBasic();
                var gs       = gameInfo.GameStatus;
                if (gs == GameStatus.NoGame ||
                    gs == GameStatus.WaitPlayer ||
                    gs == GameStatus.Shuffling)
                {
                    var nextGs = gameManager.GetNextGameStatus(gameInfo, true);

                    if (nextGs == GameStatus.WaitPlayer)
                    {
                        result.Add(new ResultGameWait(gameInfo.RoomCode));
                    }
                    if (nextGs == GameStatus.StartShuffle)
                    {
                        //通知前端洗牌
                        ResultGameShuffleStart shuffleStartMsg = new ResultGameShuffleStart(gameInfo.RoomCode);
                        result.Add(shuffleStartMsg);


                        //   gameManager.PrePareNewGameInfo(gameInfo);

                        //洗牌异步指令,洗牌结束需要通知前端,开始游戏
                        GameTaskManager.SyncTask_ShuffleEnd(session);
                    }
                    //else if (nextGs == GameStatus.Shuffling)
                    //{
                    //    ResultGameShuffling shuffleMsg = gameManager.WhileShuffling();
                    //    result.Add(shuffleMsg);
                    //}
                }
            }

            return(result);
        }
コード例 #19
0
 public abstract bool VerifyCommandData(T InData, GameUserSession session);
コード例 #20
0
 public override bool VerifyCommandData(dataTestStartGame InData, GameUserSession session)
 {
     return(true);
 }
コード例 #21
0
 public abstract List <IGameMessage> HandleData(GameUserSession session, T Data);
コード例 #22
0
 public override bool VerifyCommandData(dataNewConnect InData, GameUserSession session)
 {
     return(true);
 }
コード例 #23
0
        public static void SyncTask_DealCardDone(GameUserSession session, EGameInfo gi)
        {
            DealCardDoneTask syncTask = new DealCardDoneTask();

            syncTask.Run(GameConfig.Send_OneCard_Sec, session.GameServer, gi);
        }
コード例 #24
0
        public static void SyncTask_ShuffleEnd(GameUserSession session)
        {
            ShuffleEndTask syncTask = new ShuffleEndTask(session.GameManager);

            syncTask.Run(GameConfig.Game_Shuffle_Sec, session.GameServer, session.GameAttr.Weight);
        }
コード例 #25
0
 public override bool VerifyCommandData(dataDealCardDone InData, GameUserSession session)
 {
     return(true);
 }
コード例 #26
0
ファイル: GameManager.cs プロジェクト: flysnoopy1984/IQianBa
 public GameManager(string userOpenId, GameUserSession session)
 {
     // _RoomCode = RoomCode;
     _UserOpenId = userOpenId;
     _Session    = session;
 }