Ejemplo n.º 1
0
 public void BroadcastSeatInfo(CGamePlayer player)
 {
     if (tableR.ContainsKey(player))
     {
         BroadcastSeatInfo(tableR[player]);
     }
 }
Ejemplo n.º 2
0
 protected void SendAllSeatInfo(CGamePlayer receiver)
 {
     for (int i = 0; i < this.MaxSeatNum; i++)
     {
         SendSeatInfo(receiver, i);
     }
 }
Ejemplo n.º 3
0
 protected virtual void SendSeatInfo(CGamePlayer receiver, int seatnum)
 {
     if (table.ContainsKey(seatnum))
     {
         CGamePlayer player = table[seatnum];
         receiver.Tunnel.SendMessage(String.Format("seatinfo:{0:0},{1},{2:0},{3}", seatnum, player.Name, player.Wallet, Enum.GetName(typeof(PlayerStatus), player.Status)));
     }
     else
     {
         receiver.Tunnel.SendMessage(String.Format("seatinfo:{0:0},{1},{2:0},{3}", seatnum, "", 0, "Empty"));
     }
 }
Ejemplo n.º 4
0
        public bool SitOut(CGamePlayer player)
        {
            if (tableR.ContainsKey(player))
            {
                player.Status = PlayerStatus.SittingOut;

                BroadcastSeatInfo(tableR[player]);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        public bool JoinGame(LobbyPlayer lobbyPlayer, NetTunnel tunnel)
        {
            string pname = lobbyPlayer.Name;

            if (spectators.ContainsKey(pname))
            {
                // should trigger unexpected disconnect and remove itself from list if disconnected
                if (spectators[pname].Tunnel.Ping())
                {
                    Logger.Log(LogType.Error, pname + " is already a spectator when he suppied the correct ticket to join " + name);

                    tunnel.SendMessage("fail");
                    return(false);
                }
            }

            CGamePlayer newPlayer = null;

            if (GAME_TYPE == typeof(TexasHoldem))
            {
                newPlayer = new THPlayer(lobbyPlayer, tunnel, this);
            }
            else
            {
                Logger.Log(LogType.Error, "unknown game type");
                tunnel.SendMessage("fail");
                return(false);
            }

            spectators.Add(pname, newPlayer);

            Logger.Log(LogType.Debug, pname + " joined game " + name);

            newPlayer.Tunnel.SendMessage(newPlayer.Name);
            newPlayer.Tunnel.SendMessage(this.name);
            newPlayer.Tunnel.SendMessage(BUY_IN.ToString("0"));
            newPlayer.Tunnel.SendMessage(MAX_BUY_IN.ToString("0"));

            newPlayer.Status = PlayerStatus.Standing;

            SendAllSeatInfo(newPlayer);

            return(true);
        }
Ejemplo n.º 6
0
        public void StandUp(CGamePlayer player)
        {
            if (tableR.ContainsKey(player))
            {
                Logger.Log(LogType.Debug, player.Name + " stood up in " + name);

                int seat = tableR[player];
                table.Remove(seat);
                tableR.Remove(player);

                player.DepositWallet();

                BroadcastSeatInfo(seat);
            }
            else
            {
                Logger.Log(LogType.Error, player.Name + " tried to stand without sitting in " + name);
            }
        }
Ejemplo n.º 7
0
        public void LeaveGame(CGamePlayer player)
        {
            Logger.Log(LogType.Debug, player.Name + " is leaving game " + name);

            string pname = player.Name;

            if (spectators.ContainsKey(pname))
            {
                spectators.Remove(pname);
            }
            if (tableR.ContainsKey(player))
            {
                int seat = tableR[player];
                tableR.Remove(player);
                if (table.ContainsKey(seat))
                {
                    table.Remove(seat);
                }

                BroadcastSeatInfo(seat);
            }
        }
Ejemplo n.º 8
0
        public bool SitDown(CGamePlayer player, int seatnum)
        {
            if (seatnum >= MAX_SEAT_NUM)
            {
                Logger.Log(LogType.Error, player.Name + " tried to sit in an invalid seat in " + name);
                return(false);
            }

            if (table.ContainsKey(seatnum))
            {
                Logger.Log(LogType.Error, player.Name + " tried to sit in occupied seat in " + name);
                return(false);
            }

            if (player.Bank < BUY_IN)
            {
                Logger.Log(LogType.Error, player.Name + " tried to sit with a low bank amount in " + name);
                return(false);
            }

            // note that the player's OnMsgRx event sends the "fail" if returned false
            // but this SitDown method sends the "ok"

            table.Add(seatnum, player);
            tableR.Add(player, seatnum);

            player.Status = PlayerStatus.SittingOut;

            Logger.Log(LogType.Debug, player.Name + " is now sitting in " + seatnum.ToString("0") + " in " + name);

            player.Tunnel.SendMessage("sit:ok");

            BroadcastSeatInfo(seatnum);

            return(true);
        }
Ejemplo n.º 9
0
 protected void SendAllSeatInfo(CGamePlayer receiver)
 {
     for (int i = 0; i < this.MaxSeatNum; i++)
         SendSeatInfo(receiver, i);
 }
Ejemplo n.º 10
0
 protected virtual void SendSeatInfo(CGamePlayer receiver, int seatnum)
 {
     if (table.ContainsKey(seatnum))
     {
         CGamePlayer player = table[seatnum];
         receiver.Tunnel.SendMessage(String.Format("seatinfo:{0:0},{1},{2:0},{3}", seatnum, player.Name, player.Wallet, Enum.GetName(typeof(PlayerStatus), player.Status)));
     }
     else
     {
         receiver.Tunnel.SendMessage(String.Format("seatinfo:{0:0},{1},{2:0},{3}", seatnum, "", 0, "Empty"));
     }
 }
Ejemplo n.º 11
0
        public void StandUp(CGamePlayer player)
        {
            if (tableR.ContainsKey(player))
            {
                Logger.Log(LogType.Debug, player.Name + " stood up in " + name);

                int seat = tableR[player];
                table.Remove(seat);
                tableR.Remove(player);

                player.DepositWallet();

                BroadcastSeatInfo(seat);
            }
            else
            {
                Logger.Log(LogType.Error, player.Name + " tried to stand without sitting in " + name);
            }
        }
Ejemplo n.º 12
0
        public bool SitOut(CGamePlayer player)
        {
            if (tableR.ContainsKey(player))
            {
                player.Status = PlayerStatus.SittingOut;

                BroadcastSeatInfo(tableR[player]);

                return true;
            }

            return false;
        }
Ejemplo n.º 13
0
        public bool SitDown(CGamePlayer player, int seatnum)
        {
            if (seatnum >= MAX_SEAT_NUM)
            {
                Logger.Log(LogType.Error, player.Name + " tried to sit in an invalid seat in " + name);
                return false;
            }

            if (table.ContainsKey(seatnum))
            {
                Logger.Log(LogType.Error, player.Name + " tried to sit in occupied seat in " + name);
                return false;
            }

            if (player.Bank < BUY_IN)
            {
                Logger.Log(LogType.Error, player.Name + " tried to sit with a low bank amount in " + name);
                return false;
            }

            // note that the player's OnMsgRx event sends the "fail" if returned false
            // but this SitDown method sends the "ok"

            table.Add(seatnum, player);
            tableR.Add(player, seatnum);

            player.Status = PlayerStatus.SittingOut;

            Logger.Log(LogType.Debug, player.Name + " is now sitting in " + seatnum.ToString("0") + " in " + name);

            player.Tunnel.SendMessage("sit:ok");

            BroadcastSeatInfo(seatnum);

            return true;
        }
Ejemplo n.º 14
0
        public void LeaveGame(CGamePlayer player)
        {
            Logger.Log(LogType.Debug, player.Name + " is leaving game " + name);

            string pname = player.Name;
            if (spectators.ContainsKey(pname))
                spectators.Remove(pname);
            if (tableR.ContainsKey(player))
            {
                int seat = tableR[player];
                tableR.Remove(player);
                if (table.ContainsKey(seat))
                    table.Remove(seat);

                BroadcastSeatInfo(seat);
            }
        }
Ejemplo n.º 15
0
 public void BroadcastSeatInfo(CGamePlayer player)
 {
     if (tableR.ContainsKey(player))
         BroadcastSeatInfo(tableR[player]);
 }