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); }
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); } }
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); }
private bool VerifyBaseData(T preData, GameUserSession session) { if (string.IsNullOrEmpty(preData.OpenId)) { GameMessageHandle.PushErrorMsg("错误,没有获取您的身份,请重新登陆", session); return(false); } return(true); }
public override bool VerifyCommandData(dataPlayerAddCoins InData, GameUserSession session) { if (InData.Coins <= 0) { base.GameMessageHandle.PushErrorMsg("筹码不能小于0", session); return(false); } return(true); }
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); }
public void PushErrorMsg(string msgString, GameUserSession session) { var msg = new MessageNormalError(); if (session != null) { msg.SessionId = session.SessionID; } msg.ErrorMsg = msgString; ErrorQueue.Enqueue(msg); }
public void Push(List <IGameMessage> msgList, GameUserSession session = null) { foreach (var msg in msgList) { if (session != null) { msg.SessionId = session.SessionID; } Push(msg); } }
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); }
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); }
public void StartNewGame(GameUserSession session, string RoomCode) { PrePareNewGameInfo(RoomCode); var game = GameDataHandle.GetGameData(); game.GameCoins = new EGameCoins(RoomCode); GameTaskManager.SyncTask_ShuffleEnd(session); }
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); }
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); }
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); }
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); }
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); }
public override bool VerifyCommandData(dataUserSitUp InData, GameUserSession session) { return(true); }
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); }
public abstract bool VerifyCommandData(T InData, GameUserSession session);
public override bool VerifyCommandData(dataTestStartGame InData, GameUserSession session) { return(true); }
public abstract List <IGameMessage> HandleData(GameUserSession session, T Data);
public override bool VerifyCommandData(dataNewConnect InData, GameUserSession session) { return(true); }
public static void SyncTask_DealCardDone(GameUserSession session, EGameInfo gi) { DealCardDoneTask syncTask = new DealCardDoneTask(); syncTask.Run(GameConfig.Send_OneCard_Sec, session.GameServer, gi); }
public static void SyncTask_ShuffleEnd(GameUserSession session) { ShuffleEndTask syncTask = new ShuffleEndTask(session.GameManager); syncTask.Run(GameConfig.Game_Shuffle_Sec, session.GameServer, session.GameAttr.Weight); }
public override bool VerifyCommandData(dataDealCardDone InData, GameUserSession session) { return(true); }
public GameManager(string userOpenId, GameUserSession session) { // _RoomCode = RoomCode; _UserOpenId = userOpenId; _Session = session; }