Пример #1
0
        private void OnAuthenticateUserCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c = (AuthenticateUserCommand)command;
            var u = DataManager.Persistance.Get(c.Username);

            var ok = false;

            if (u != null)
            {
                client.PlayerName = u.DisplayName;
                if (DataManager.Persistance.Authenticate(c.Username, c.Password) != null)
                {
                    if (!Lobby.IsNameUsed(client.PlayerName))
                    {
                        Lobby.AddName(client.PlayerName);
                        ok = true;
                        client.SendCommand(c.ResponseSuccess());
                    }
                    else
                    {
                        client.SendCommand(c.ResponseFailure(TaluvaMessageId.NameAlreadyUsed, "The name is already used on the server!"));
                    }
                }
                else
                {
                    client.SendCommand(c.ResponseFailure(TaluvaMessageId.InvalidPassword, "Wrong Password!"));
                }
            }
            else
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.UsernameNotFound, "Your username was not in the database!"));
            }
            Logger.LogInformation("> Client authenticate to RegisteredMode Server as : {0}. Success={1}", c.Username, ok);
        }
 private void OnPlayerSitInCommandReceived(AbstractBluffinCommand command, IBluffinClient client, RemotePlayer p)
 {
     UserInfo userInfo = null;
     var c = (PlayerSitInCommand)command;
     if (p.Game.Params.Lobby.OptionType == LobbyTypeEnum.QuickMode)
         p.Player.MoneySafeAmnt = ((LobbyOptionsQuickMode) p.Game.Params.Lobby).StartingAmount;
     else
     {
         int money = c.MoneyAmount;
         userInfo = DataManager.Persistance.Get(p.Client.PlayerName);
         if (userInfo == null || userInfo.TotalMoney < money)
             p.Player.MoneySafeAmnt = -1;
         else
         {
             userInfo.TotalMoney -= money;
             p.Player.MoneySafeAmnt = money;
         }
     }
     var seat = p.Game.GameTable.SitIn(p.Player, c.NoSeat);
     if (seat == null)
     {
         client.SendCommand(c.ResponseFailure(BluffinMessageId.NoMoreSeats, "No seats available"));
         if (userInfo != null)
             userInfo.TotalMoney += p.Player.MoneySafeAmnt; 
     }
     else
     {
         var r = (seat.NoSeat != c.NoSeat) ? c.ResponseSuccess(BluffinMessageId.SeatChanged, "The asked seat wasn't available, the server gave you another one.") : c.ResponseSuccess();
         r.NoSeat = seat.NoSeat;
         client.SendCommand(r);
         p.Game.AfterPlayerSat(p.Player);
     }
 }
Пример #3
0
        private void OnCreateUserCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c  = (CreateUserCommand)command;
            var ok = false;

            if (!DataManager.Persistance.IsUsernameExist(c.Username))
            {
                if (!DataManager.Persistance.IsDisplayNameExist(c.DisplayName))
                {
                    DataManager.Persistance.Register(new UserInfo(c.Username, c.Password, c.Email, c.DisplayName, 7500));
                    ok = true;
                    client.SendCommand(c.ResponseSuccess());
                }
                else
                {
                    client.SendCommand(c.ResponseFailure(TaluvaMessageId.NameAlreadyUsed, "The display name is already used on the server!"));
                }
            }
            else
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.UsernameAlreadyUsed, "The username is already used on the server!"));
            }

            Logger.LogInformation("> Client register to RegisteredMode Server as : {0}. Success={1}", c.Username, ok);
        }
Пример #4
0
 public RemotePlayer(PokerGame game, PlayerInfo player, IBluffinClient client, int tableId)
 {
     Game    = game;
     Player  = player;
     Client  = client;
     TableId = tableId;
 }
Пример #5
0
        private void OnPlayerSitOutCommandReceived(AbstractCommand command, IBluffinClient client, RemotePlayer p)
        {
            var c = (PlayerSitOutCommand)command;

            client.SendCommand(c.ResponseSuccess());
            p.Game.SitOut(p.Player);
        }
 void OnListTableCommandReceived(AbstractCommand command, IBluffinClient client)
 {
     var c = (ListTableCommand)command;
     var r = c.ResponseSuccess();
     r.Tables = Lobby.ListTables(c.LobbyTypes);
     client.SendCommand(r);
 }
Пример #7
0
        void OnDisconnectCommandReceived(AbstractCommand command, IBluffinClient client, RemotePlayer p)
        {
            if (p.Game.Table.Params.Lobby.OptionType == LobbyTypeEnum.RegisteredMode)
            {
                DataManager.Persistance.Get(p.Client.PlayerName).TotalMoney += p.Player.MoneySafeAmnt;
            }

            client.RemovePlayer(p);
            if (p.Player.State == PlayerStateEnum.Joined || !p.Game.IsPlaying)
            {
                var t = p.Game.Table;
                Logger.LogInformation("> Client '{0}' left table: {2}:{1}", p.Player.Name, t.Params.TableName, p.TableId);

                p.Game.LeaveGame(p.Player);
            }
            else
            {
                var blindNeeded = p.Game.Table.Bank.DebtAmount(p.Player);

                if (!p.Game.Table.Zombies.Contains(p.Player))
                {
                    p.Game.Table.Zombies.Add(p.Player);
                }
                if (p.Game.State == GameStateEnum.Playing && p.Game.Table.Seats.CurrentPlayer() == p.Player)
                {
                    p.Game.PlayMoney(p.Player, -1);
                }
                else if (blindNeeded > 0)
                {
                    p.Game.PlayMoney(p.Player, blindNeeded);
                }
            }
        }
Пример #8
0
        private void OnCheckUserExistCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c = (CheckUserExistCommand)command;
            var r = c.ResponseSuccess();

            r.Exist = DataManager.Persistance.IsUsernameExist(c.Username);
            client.SendCommand(r);
        }
Пример #9
0
        private void OnCheckDisplayExistCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c = (CheckDisplayExistCommand)command;
            var r = c.ResponseSuccess();

            r.Exist = Lobby.IsNameUsed(c.DisplayName) || DataManager.Persistance.IsDisplayNameExist(c.DisplayName);
            client.SendCommand(r);
        }
Пример #10
0
        void OnListTableCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c = (ListTableCommand)command;
            var r = c.ResponseSuccess();

            r.Tables = Lobby.ListTables(c.LobbyTypes);
            client.SendCommand(r);
        }
Пример #11
0
 public RemotePlayer(PokerGame game, PlayerInfo player, IBluffinClient client, IBluffinServer server, int tableId)
 {
     Game = game;
     Player = player;
     Client = client;
     TableId = tableId;
     Server = server;
 }
Пример #12
0
        private void OnCreateTableCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c   = (CreateTableCommand)command;
            var res = Lobby.CreateTable(c);
            var r   = c.ResponseSuccess();

            Logger.LogInformation("> Client '{0}' {3}: {2}:{1}", client.PlayerName, c.Params.TableName, res, c.Params.Lobby.OptionType);
            r.IdTable = res;
            client.SendCommand(r);
        }
Пример #13
0
        private void OnLeaveTableCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c    = (LeaveTableCommand)command;
            var game = (PokerGame)Lobby.GetGame(c.TableId);
            var p    = game.Table.Seats.Players().SingleOrDefault(x => x.Name == client.PlayerName);

            if (p != null)
            {
                game.LeaveGame(p);
            }
            Server.GameCommands.Add(new GameCommandEntry {
                Client = client, Command = new DisconnectCommand(), Player = ((RemoteTcpClient)client).GamePlayers[c.TableId]
            });
        }
        void OnDisconnectCommandReceived(AbstractBluffinCommand command, IBluffinClient client, RemotePlayer p)
        {
            if (p.Game.Params.Lobby.OptionType == LobbyTypeEnum.RegisteredMode)
                DataManager.Persistance.Get(p.Client.PlayerName).TotalMoney += p.Player.MoneySafeAmnt;

            client.RemovePlayer(p);

            p.Player.State = PlayerStateEnum.Zombie;

            var t = p.Game.Table;
            LogManager.Log(LogLevel.Message, "BluffinGameWorker.OnDisconnectCommandReceived", "> Client '{0}' left table: {2}:{1}", p.Player.Name, t.Params.TableName, p.TableId);

            p.Game.LeaveGame(p.Player);
            
        }
 void OnIdentifyCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
 {
     var c = (IdentifyCommand)command;
     client.PlayerName = c.Name;
     var ok = !Lobby.IsNameUsed(c.Name) && !DataManager.Persistance.IsDisplayNameExist(c.Name);
     LogManager.Log(LogLevel.Message, "BluffinLobbyWorker.OnIdentifyCommandReceived", "> Client indentifying QuickMode server as : {0}. Success={1}", c.Name, ok);
     if (ok)
     {
         client.SendCommand(c.ResponseSuccess());
         Lobby.AddName(c.Name);
     }
     else
     {
         client.SendCommand(c.ResponseFailure(BluffinMessageId.NameAlreadyUsed,"The name is already used on the server!"));
     }
 }
Пример #16
0
        private void OnGetUserCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c = (GetUserCommand)command;
            var u = DataManager.Persistance.Get(client.PlayerName);

            if (u == null)
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.UsernameNotFound, "Your username was not in the database. That's weird !"));
            }
            else
            {
                var r = c.ResponseSuccess();
                r.Email       = u.Email;
                r.DisplayName = u.DisplayName;
                r.Money       = u.TotalMoney;
                client.SendCommand(r);
            }
        }
Пример #17
0
        void OnIdentifyCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c  = (IdentifyCommand)command;
            var ok = !Lobby.IsNameUsed(c.Name) && !DataManager.Persistance.IsDisplayNameExist(c.Name);

            Logger.LogInformation("> Client indentifying QuickMode server as : {0}. Success={1}", c.Name, ok);
            if (ok)
            {
                client.PlayerName = c.Name;
                Logger.LogClientIdentified(client);
                client.SendCommand(c.ResponseSuccess());
                Lobby.AddName(c.Name);
            }
            else
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.NameAlreadyUsed, "The name is already used on the server!"));
            }
        }
Пример #18
0
        private void OnCheckCompatibilityCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            const string MINIMUM_CLIENT_VERSION = "0.0.3.0";

            Assembly        assembly = typeof(AbstractCommand).Assembly;
            FileVersionInfo fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);

            var     c = (CheckCompatibilityCommand)command;
            Version vClient;
            bool    ok = Version.TryParse(c.ImplementedProtocolVersion, out vClient);

            if (ok)
            {
                client.SupportedProtocol = vClient;
            }
            client.ClientIdentification = c.ClientIdentification;
            Logger.LogClientAdditionalInfo(client);
            if (!ok || vClient < new Version(MINIMUM_CLIENT_VERSION))
            {
                var r = c.ResponseFailure(TaluvaMessageId.NotSupported, "The client must implement at least protocol version " + MINIMUM_CLIENT_VERSION);
                r.ImplementedProtocolVersion = fvi.FileVersion;
                r.ServerIdentification       = Server.Identification;
                client.SendCommand(r);
            }
            else
            {
                var r = c.ResponseSuccess();
                r.ImplementedProtocolVersion = fvi.FileVersion;
                r.ServerIdentification       = Server.Identification;
                r.SupportedLobbyTypes        = new[] { LobbyTypeEnum.QuickMode, LobbyTypeEnum.RegisteredMode };
                r.AvailableGames             = new[]
                {
                    new GameInfo
                    {
                        AvailableVariants = RuleFactory.Variants.Values.Where(x => x.GameType == GameTypeEnum.Standard).Select(x => x.Variant).ToArray(),
                        GameType          = GameTypeEnum.Standard,
                        MaxPlayers        = 4,
                        MinPlayers        = 2
                    },
                };
                client.SendCommand(r);
            }
        }
Пример #19
0
        private void OnPlayerSitInCommandReceived(AbstractCommand command, IBluffinClient client, RemotePlayer p)
        {
            UserInfo userInfo = null;
            var      c        = (PlayerSitInCommand)command;

            if (p.Game.Table.Params.Lobby.OptionType == LobbyTypeEnum.QuickMode)
            {
                p.Player.MoneySafeAmnt = 1500;//((LobbyOptionsQuickMode)p.Game.Table.Params.Lobby).StartingAmount;
            }
            else
            {
                int money = c.MoneyAmount;
                userInfo = DataManager.Persistance.Get(p.Client.PlayerName);
                if (userInfo == null || userInfo.TotalMoney < money)
                {
                    p.Player.MoneySafeAmnt = -1;
                }
                else
                {
                    userInfo.TotalMoney   -= money;
                    p.Player.MoneySafeAmnt = money;
                }
            }
            var seat = p.Game.Table.SitIn(p.Player, c.NoSeat);

            if (seat == null)
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.NoMoreSeats, "No seats available"));
                if (userInfo != null)
                {
                    userInfo.TotalMoney += p.Player.MoneySafeAmnt;
                }
            }
            else
            {
                var r = seat.NoSeat != c.NoSeat ? c.ResponseSuccess(TaluvaMessageId.SeatChanged, "The asked seat wasn't available, the server gave you another one.") : c.ResponseSuccess();
                r.NoSeat = seat.NoSeat;
                client.SendCommand(r);
                p.Game.AfterPlayerSat(p.Player);
            }
        }
Пример #20
0
        private void OnJoinTableCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c    = (JoinTableCommand)command;
            var game = (PokerGame)Lobby.GetGame(c.TableId);

            if (game == null || !game.IsRunning)
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.WrongTableState, "You can't join a game that isn't running !"));
                return;
            }
            var table = game.Table;

            if (table.Seats.Players().ContainsPlayerNamed(client.PlayerName))
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.NameAlreadyUsed, "Someone with your name is already in this game !"));
                return;
            }
            var rp = new RemotePlayer(game, new PlayerInfo(client.PlayerName, 0), client, c.TableId);

            if (!rp.JoinGame())
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.SpecificServerMessage, "Unknown failure"));
                return;
            }

            client.AddPlayer(rp);

            Logger.LogInformation("> Client '{0}' joined {2}:{1}", client.PlayerName, table.Params.TableName, c.TableId, rp.Player.NoSeat);


            var r = c.ResponseSuccess();

            r.GameHasStarted = rp.Game.IsPlaying;
            //r.BoardCards = rp.Game.Table.Cards.Select(x => x.ToString()).ToArray();
            r.Seats  = rp.AllSeats().ToList();
            r.Params = rp.Game.Table.Params;
            //r.TotalPotAmount = rp.Game.Table.Bank.MoneyAmount;
            //r.PotsAmount = rp.Game.Table.Bank.PotAmountsPadded(rp.Game.Table.Params.MaxPlayers).ToList();

            client.SendCommand(r);
        }
 void OnDisconnectCommandReceived(AbstractCommand command, IBluffinClient client)
 {
     Logger.LogInformation("> Client disconnected: {0}", client.PlayerName);
     Lobby.RemoveName(client.PlayerName);
 }
Пример #22
0
        private void OnPlayerPlayMoneyCommandReceived(AbstractCommand command, IBluffinClient client, RemotePlayer p)
        {
            var c = (PlayerPlayMoneyCommand)command;

            p.Game.PlayMoney(p.Player, c.AmountPlayed);
        }
Пример #23
0
 public LogCommandEventArg(AbstractCommand command, string commandData, IBluffinClient client)
 {
     Command     = command;
     CommandData = commandData;
     Client      = client;
 }
 private void OnCommandReceived(AbstractBluffinCommand command, IBluffinClient client, RemotePlayer p)
 {
     LogManager.Log(LogLevel.MessageVeryLow, "BluffinGameWorker.OnCommandReceived", "GameWorker RECV from {0} [{1}]", client.PlayerName, command.Encode());
     LogManager.Log(LogLevel.MessageVeryLow, "BluffinGameWorker.OnCommandReceived", "-------------------------------------------");
 }
 private void OnPlayerSitOutCommandReceived(AbstractBluffinCommand command, IBluffinClient client, RemotePlayer p)
 {
     var c = (PlayerSitOutCommand)command;
     client.SendCommand(c.ResponseSuccess());
     p.Game.SitOut(p.Player);
 }
Пример #26
0
 void OnDisconnectCommandReceived(AbstractCommand command, IBluffinClient client)
 {
     Logger.LogInformation("> Client disconnected: {0}", client.PlayerName);
     Lobby.RemoveName(client.PlayerName);
 }
Пример #27
0
 public static void LogClientIdentified(IBluffinClient client)
 {
     ClientIdentified(new StackFrame(1), new LogClientEventArg(client));
 }
        private void OnJoinTableCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c = (JoinTableCommand)command;
            var game = (PokerGame)Lobby.GetGame(c.TableId);
            var table = game.Table;
            if (!game.IsRunning)
            {
                client.SendCommand(c.ResponseFailure(BluffinMessageId.WrongTableState, "You can't join a game that isn't running !"));
                return;
            }
            if (table.ContainsPlayer(client.PlayerName))
            {
                client.SendCommand(c.ResponseFailure(BluffinMessageId.NameAlreadyUsed, "Someone with your name is already in this game !"));
                return;
            }
            var rp = new RemotePlayer(game, new PlayerInfo(client.PlayerName, 0), client, Server, c.TableId);
            if (!rp.JoinGame())
            {
                client.SendCommand(c.ResponseFailure(BluffinMessageId.SpecificServerMessage, "Unknown failure"));
                return;
            }

            client.AddPlayer(rp);

            Logger.LogInformation("> Client '{0}' joined {2}:{1}", client.PlayerName, table.Params.TableName, c.TableId, rp.Player.NoSeat);


            var r = c.ResponseSuccess();

            r.GameHasStarted = rp.Game.IsPlaying;
            r.BoardCards = rp.Game.Table.Cards.Select(x => x.ToString()).ToArray();
            r.Seats = rp.AllSeats().ToList();
            r.Params = rp.Game.Table.Params;
            r.TotalPotAmount = rp.Game.Table.TotalPotAmnt;
            r.PotsAmount = rp.Game.Table.PotAmountsPadded.ToList();

            client.SendCommand(r);
        }
Пример #29
0
 public LogClientEventArg(IBluffinClient client)
 {
     Client = client;
 }
 void OnDisconnectCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
 {
     LogManager.Log(LogLevel.Message, "BluffinLobbyWorker.OnDisconnectCommandReceived", "> Client disconnected: {0}", client.PlayerName);
     Lobby.RemoveName(client.PlayerName);
 }
 private void OnCheckUserExistCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
 {
     var c = (CheckUserExistCommand)command;
     var r = c.ResponseSuccess();
     r.Exist = DataManager.Persistance.IsUsernameExist(c.Username);
     client.SendCommand(r);
 }
 private void OnLeaveTableCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
 {
     var c = (LeaveTableCommand)command;
     var game = Lobby.GetGame(c.TableId);
     game.LeaveGame(game.GameTable.Players.Single(x => x.Name == client.PlayerName));
 }
        private void OnJoinTableCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
        {
            var c = (JoinTableCommand)command;
            var game = Lobby.GetGame(c.TableId);
            var table = game.GameTable;
            if (!game.IsRunning)
            {
                client.SendCommand(c.ResponseFailure(BluffinMessageId.WrongTableState, "You can't join a game that isn't running !"));
                return;
            }
            if (table.ContainsPlayer(client.PlayerName))
            {
                client.SendCommand(c.ResponseFailure(BluffinMessageId.NameAlreadyUsed, "Someone with your name is already in this game !"));
                return;
            }
            var rp = new RemotePlayer(game, new PlayerInfo(client.PlayerName, 0), client, c.TableId);
            if (!rp.JoinGame())
            {
                client.SendCommand(c.ResponseFailure(BluffinMessageId.SpecificServerMessage, "Unknown failure"));
                return;
            }

            client.AddPlayer(rp);

            LogManager.Log(LogLevel.Message, "BluffinLobbyWorker.OnJoinTableCommandReceived", "> Client '{0}' joined {2}:{1}", client.PlayerName, table.Params.TableName, c.TableId, rp.Player.NoSeat);
            client.SendCommand(c.ResponseSuccess());

            rp.SendTableInfo();
        }
 private void OnCreateTableCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
 {
     var c = (CreateTableCommand)command;
     var res = Lobby.CreateTable(c);
     var r = c.ResponseSuccess();
     LogManager.Log(LogLevel.Message, "BluffinLobbyWorker.OnCreateTableCommandReceived_{3}", "> Client '{0}' {3}: {2}:{1}", client.PlayerName, c.Params.TableName, res, c.Params.Lobby.OptionType);
     r.IdTable = res;
     client.SendCommand(r);
 }
Пример #35
0
 public LogClientCreationEventArg(TcpClient endpoint, IBluffinClient client) : base(client)
 {
     Endpoint = endpoint;
 }
        private void OnCreateUserCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
        {
            var c = (CreateUserCommand)command;
            var ok = false;
            if (!DataManager.Persistance.IsUsernameExist(c.Username))
            {
                if (!DataManager.Persistance.IsDisplayNameExist(c.DisplayName))
                {
                    DataManager.Persistance.Register(new UserInfo(c.Username, c.Password, c.Email, c.DisplayName, 7500));
                    ok = true;
                    client.SendCommand(c.ResponseSuccess());
                }
                else
                    client.SendCommand(c.ResponseFailure(BluffinMessageId.NameAlreadyUsed, "The display name is already used on the server!"));
            }
            else
                client.SendCommand(c.ResponseFailure(BluffinMessageId.UsernameAlreadyUsed, "The username is already used on the server!"));

            LogManager.Log(LogLevel.Message, "BluffinLobbyWorker.OnCreateUserCommandReceived", "> Client register to RegisteredMode Server as : {0}. Success={1}", c.Username, ok);
        }
Пример #37
0
 public static void LogClientCreated(TcpClient endpoint, IBluffinClient client)
 {
     ClientCreated(new StackFrame(1), new LogClientCreationEventArg(endpoint, client));
 }
        private void OnAuthenticateUserCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
        {
            var c = (AuthenticateUserCommand)command;
            var u = DataManager.Persistance.Get(c.Username);

            var ok = false;
            if (u != null)
            {
                client.PlayerName = u.DisplayName;
                if (DataManager.Persistance.Authenticate(c.Username, c.Password) != null)
                {
                    if (!Lobby.IsNameUsed(client.PlayerName))
                    {
                        Lobby.AddName(client.PlayerName);
                        ok = true;
                        client.SendCommand(c.ResponseSuccess());
                    }
                    else
                        client.SendCommand(c.ResponseFailure(BluffinMessageId.NameAlreadyUsed, "The name is already used on the server!"));
                }
                else
                    client.SendCommand(c.ResponseFailure(BluffinMessageId.InvalidPassword, "Wrong Password!"));
            }
            else
                client.SendCommand(c.ResponseFailure(BluffinMessageId.UsernameNotFound, "Your username was not in the database!"));
            LogManager.Log(LogLevel.Message, "BluffinLobbyWorker.OnAuthenticateUserCommandReceived", "> Client authenticate to RegisteredMode Server as : {0}. Success={1}", c.Username, ok);
        }
Пример #39
0
 public static void LogCommandReceived(AbstractCommand cmd, IBluffinClient cli, string commandData)
 {
     CommandReceived(new StackFrame(1), new LogCommandEventArg(cmd, commandData, cli));
     VerboseInformationLogged(new StackFrame(1), new EventArgs <string>($"Server RECV from {cli.PlayerName} [{commandData}]"));
     VerboseInformationLogged(new StackFrame(1), new EventArgs <string>("-------------------------------------------"));
 }
 private void OnGetUserCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
 {
     var c = (GetUserCommand)command;
     var u = DataManager.Persistance.Get(client.PlayerName);
     if(u == null)
         client.SendCommand(c.ResponseFailure(BluffinMessageId.UsernameNotFound, "Your username was not in the database. That's weird !"));
     else
     {
         var r = c.ResponseSuccess();
         r.Email = u.Email;
         r.DisplayName = u.DisplayName;
         r.Money = u.TotalMoney;
         client.SendCommand(r);
     }
 }
 private void OnPlayerPlayMoneyCommandReceived(AbstractBluffinCommand command, IBluffinClient client, RemotePlayer p)
 {
     var c = (PlayerPlayMoneyCommand)command;
     p.Game.PlayMoney(p.Player, c.Played);
 }
 public LogClientEventArg(IBluffinClient client)
 {
     Client = client;
 }
Пример #43
0
 public static void LogClientAdditionalInfo(IBluffinClient client)
 {
     ClientAdditionalInfo(new StackFrame(1), new LogClientEventArg(client));
 }
Пример #44
0
 public static void LogClientIdentified(IBluffinClient client)
 {
     ClientIdentified(new StackFrame(1), new LogClientEventArg(client));
 }
        private void OnCheckCompatibilityCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            const string minimumClientVersion = "3.0";
            const string currentServerVersion = "3.0.0";

            var c = (CheckCompatibilityCommand)command;
            Version vClient; 
            bool ok = Version.TryParse(c.ImplementedProtocolVersion,out vClient);
            if (!ok || vClient < new Version(minimumClientVersion))
            {
                var r = c.ResponseFailure(BluffinMessageId.NotSupported, "The client must implement at least protocol version " + minimumClientVersion);
                r.ImplementedProtocolVersion = currentServerVersion;
                client.SendCommand(r);
            }
            else
            {
                var r = c.ResponseSuccess();
                r.ImplementedProtocolVersion = currentServerVersion;
                r.SupportedLobbyTypes = new[] {LobbyTypeEnum.QuickMode, LobbyTypeEnum.RegisteredMode};
                r.AvailableGames = new[]
                {
                    new GameInfo
                    {
                        AvailableBlinds = new [] {BlindTypeEnum.Blinds},
                        AvailableLimits = new []{LimitTypeEnum.NoLimit},
                        AvailableVariants = RuleFactory.Variants.Values.Where(x => x.GameType == GameTypeEnum.CommunityCardsPoker).Select(x => x.Variant).ToArray(),
                        GameType = GameTypeEnum.CommunityCardsPoker,
                        MaxPlayers = 10,
                        MinPlayers = 2
                    },
                    new GameInfo
                    {
                        AvailableBlinds = new [] {BlindTypeEnum.Antes},
                        AvailableLimits = new []{LimitTypeEnum.NoLimit},
                        AvailableVariants = RuleFactory.Variants.Values.Where(x => x.GameType == GameTypeEnum.StudPoker).Select(x => x.Variant).ToArray(),
                        GameType = GameTypeEnum.StudPoker,
                        MaxPlayers = 10,
                        MinPlayers = 2
                    },
                    new GameInfo
                    {
                        AvailableBlinds = new [] {BlindTypeEnum.Antes},
                        AvailableLimits = new []{LimitTypeEnum.NoLimit},
                        AvailableVariants = RuleFactory.Variants.Values.Where(x => x.GameType == GameTypeEnum.DrawPoker).Select(x => x.Variant).ToArray(),
                        GameType = GameTypeEnum.DrawPoker,
                        MaxPlayers = 10,
                        MinPlayers = 2
                    }
                };
                client.SendCommand(r);
            }
        }
Пример #46
0
 public static void LogClientCreated(TcpClient endpoint, IBluffinClient client)
 {
     ClientCreated(new StackFrame(1), new LogClientCreationEventArg(endpoint, client));
 }
Пример #47
0
        private void OnPlayerDiscardActionCommandReceived(AbstractCommand command, IBluffinClient client, RemotePlayer p)
        {
            var c = (PlayerDiscardActionCommand)command;

            p.Game.Discard(p.Player, c.CardsDiscarded);
        }
Пример #48
0
 public static void LogCommandReceived(AbstractCommand cmd, IBluffinClient cli, string commandData)
 {
     CommandReceived(new StackFrame(1), new LogCommandEventArg(cmd, commandData, cli ));
     VerboseInformationLogged(new StackFrame(1), new StringEventArgs($"Server RECV from {cli.PlayerName} [{commandData}]"));
     VerboseInformationLogged(new StackFrame(1), new StringEventArgs("-------------------------------------------"));
 }
 private void OnCheckCompatibilityCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
 {
     var c = (CheckCompatibilityCommand)command;
     Version vClient; 
     bool ok = Version.TryParse(c.ImplementedProtocolVersion,out vClient);
     if (!ok || vClient < new Version("1.0"))
     {
         var r = c.ResponseFailure(BluffinMessageId.NotSupported, "The client version must be at least 1.0");
         r.ImplementedProtocolVersion = "1.0";
         client.SendCommand(r);
     }
     else
     {
         var r = c.ResponseSuccess();
         r.ImplementedProtocolVersion = "1.0";
         r.SupportedLobbyTypes = new[] {LobbyTypeEnum.QuickMode, LobbyTypeEnum.RegisteredMode};
         r.Rules = RuleFactory.SupportedRules;
         client.SendCommand(r);
     }
 }
 private void OnCheckDisplayExistCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
 {
     var c = (CheckDisplayExistCommand)command;
     var r = c.ResponseSuccess();
     r.Exist = Lobby.IsNameUsed(c.DisplayName) || DataManager.Persistance.IsDisplayNameExist(c.DisplayName);
     client.SendCommand(r);
 }
 public LogClientCreationEventArg(TcpClient endpoint, IBluffinClient client) : base(client)
 {
     Endpoint = endpoint;
 }
 private void OnCreateTableCommandReceived(AbstractCommand command, IBluffinClient client)
 {
     var c = (CreateTableCommand)command;
     var res = Lobby.CreateTable(c);
     var r = c.ResponseSuccess();
     Logger.LogInformation("> Client '{0}' {3}: {2}:{1}", client.PlayerName, c.Params.TableName, res, c.Params.Lobby.OptionType);
     r.IdTable = res;
     client.SendCommand(r);
 }