Ejemplo n.º 1
0
        public PokerPlayer AssignNextTurn()
        {
            PokerPlayer nextTurn = Players.Next();

            if (nextTurn == null)
            {
                return(null);
            }

            if (nextTurn.RequestLeave)
            {
                Players.Push(nextTurn);
                nextTurn.BetStart = DateTime.UtcNow;
                nextTurn.Action   = PlayerAction.Fold;
                return(nextTurn);
            }

            if (nextTurn.IsAllIn)
            {
                Players.Push(nextTurn);
                nextTurn.BetStart = DateTime.UtcNow;
                nextTurn.Action   = PlayerAction.AllIn;
                return(nextTurn);
            }

            if (nextTurn.LonePlayer)
            {
                Players.Push(nextTurn);
                nextTurn.BetStart = DateTime.UtcNow;
                nextTurn.Action   = PlayerAction.Check;
                return(nextTurn);
            }

            bool canCall = false;

            PokerPlayer currentTurn = Players.Peek();

            if (currentTurn != null && currentTurn.Action != PlayerAction.Check &&
                currentTurn.Action != PlayerAction.Fold)
            {
                canCall = true;
            }
            if (currentTurn == null && State == PokerGameState.PreFlop)
            {
                canCall = true;
            }

            Players.Push(nextTurn);
            nextTurn.BetStart = DateTime.UtcNow;

            var         entry = new ResultEntry(nextTurn);
            List <Card> bestCards;

            entry.Rank      = nextTurn.GetBestHand(CommunityCards, out bestCards);
            entry.BestCards = bestCards;

            nextTurn.SendMessage(0x22, String.Format("You have {0}.", HandRanker.RankString(entry)));
            nextTurn.CloseGump(typeof(PokerBetGump));
            nextTurn.SendGump(new PokerBetGump(this, nextTurn, canCall));

            NeedsGumpUpdate = true;

            return(nextTurn);
        }
Ejemplo n.º 2
0
        public void AddPlayer(PokerPlayer player)
        {
            Mobile from = player.Mobile;

            if (from == null)
            {
                return;
            }

            if (from is PlayerMobile)
            {
                var playermob = from as PlayerMobile;
                if (playermob.PokerJoinTimer > DateTime.UtcNow)
                {
                    TimeSpan nextuse = playermob.PokerJoinTimer - DateTime.UtcNow;
                    from.SendMessage("You cannot join another poker game for " + nextuse.Seconds + " seconds.");
                    return;
                }

                if (playermob.Aggressed.Any(info => (DateTime.UtcNow - info.LastCombatTime) < TimeSpan.FromSeconds(60)))
                {
                    playermob.SendMessage("You cannot join poker while you are in combat!");
                    return;
                }

                if (playermob.Aggressors.Any(info => (DateTime.UtcNow - info.LastCombatTime) < TimeSpan.FromSeconds(60)))
                {
                    playermob.SendMessage("You cannot join poker while you are in combat!");
                    return;
                }

                if (playermob.Party != null)
                {
                    playermob.SendMessage("You cannot join a poker game while in a party.");
                    return;
                }
            }


            if (!Dealer.InRange(from.Location, 8))
            {
                from.PrivateOverheadMessage(MessageType.Regular, 0x22, true, "I am too far away to do that",
                                            from.NetState);
            }
            else if (GetIndexFor(from) != -1)
            {
                from.SendMessage(0x22, "You are already seated at this table");
            }
            else if (Players.Count >= Dealer.MaxPlayers)
            {
                from.SendMessage(0x22, "Sorry, that table is full");
            }
            else if (Banker.Withdraw(from, TypeOfCurrency, player.Currency))
            {
                Point3D seat = Point3D.Zero;

                foreach (Point3D seats in Dealer.Seats.Where(seats => !Dealer.SeatTaken(seats)))
                {
                    seat = seats;
                    break;
                }

                if (seat == Point3D.Zero)
                {
                    from.SendMessage(0x22, "Sorry, that table is full");
                    return;
                }

                player.Game = this;
                player.Seat = seat;
                player.TeleportToSeat();
                Players.Players.Add(player);

                ((PlayerMobile)from).PokerGame = this;
                from.SendMessage(0x22, "You have been seated at the table");

                if (Players.Count == 1 && !GameBackup.PokerGames.Contains(this))
                {
                    GameBackup.PokerGames.Add(this);
                }
                else if (State == PokerGameState.Inactive && Players.Count > 1 && !Dealer.TournamentMode)
                {
                    Begin();
                }
                else if (State == PokerGameState.Inactive && Players.Count >= Dealer.MaxPlayers && Dealer.TournamentMode)
                {
                    Dealer.TournamentMode = false;
                    Begin();
                }

                player.CloseGump(typeof(PokerTableGump));
                player.SendGump(new PokerTableGump(this, player));
                NeedsGumpUpdate = true;
                player.Chat     = true;

                player.Mobile.Blessed = true;
            }
            else
            {
                from.SendMessage(0x22, "Your bank box lacks the funds to join this poker table");
            }
        }
Ejemplo n.º 3
0
		public void AddPlayer( PokerPlayer player )
		{
			Mobile from = player.Mobile;

			if ( from == null )
				return;

			if ( !m_Dealer.InRange( from.Location, 8 ) )
				from.PrivateOverheadMessage( Server.Network.MessageType.Regular, 0x22, true, "I am too far away to do that", from.NetState );
			else if ( GetIndexFor( from ) != -1 )
				from.SendMessage( 0x22, "You are already seated at this table" );
			else if ( m_Players.Count >= m_Dealer.MaxPlayers )
				from.SendMessage( 0x22, "Sorry, that table is full" );
			/*else if ( TournamentSystem.TournamentCore.SignedUpTeam( from ) != null || TournamentSystem.TournamentCore.FindTeam( from ) != null )
				from.SendMessage( 0x22, "You may not join a poker game while signed up for a tournament." );*/
			else if ( Banker.Withdraw( from, player.Gold ) )
			{
				Point3D seat = Point3D.Zero;

				foreach ( Point3D seats in m_Dealer.Seats )
					if ( !m_Dealer.SeatTaken( seats ) )
					{
						seat = seats;
						break;
					}

				if ( seat == Point3D.Zero )
				{
					from.SendMessage( 0x22, "Sorry, that table is full" );
					return;
				}

				player.Game = this;
				player.Seat = seat;
				player.TeleportToSeat();
				m_Players.Players.Add( player );

				( (PlayerMobile)from ).PokerGame = this;
				from.SendMessage( 0x22, "You have been seated at the table" );

				if ( m_Players.Count == 1 && !GameBackup.PokerGames.Contains( this ) )
					GameBackup.PokerGames.Add( this );
				else if ( m_State == PokerGameState.Inactive && m_Players.Count > 1 && !m_Dealer.TournamentMode )
					Begin();
				else if ( m_State == PokerGameState.Inactive && m_Players.Count >= m_Dealer.MaxPlayers && m_Dealer.TournamentMode )
				{
					m_Dealer.TournamentMode = false;
					Begin();
				}

				player.CloseGump( typeof( PokerTableGump ) );
				player.SendGump( new PokerTableGump( this, player ) );
				m_NeedsGumpUpdate = true;
			}
			else
				from.SendMessage( 0x22, "Your bank box lacks the funds to join this poker table" );
		}
Ejemplo n.º 4
0
        public void AddPlayer(PokerPlayer player)
        {
            Mobile from = player.Mobile;

            if (from == null)
            {
                return;
            }

            if (from is PlayerMobile)
            {
                var playermob = from as PlayerMobile;
                if (playermob.PokerJoinTimer > DateTime.UtcNow)
                {
                    TimeSpan nextuse = playermob.PokerJoinTimer - DateTime.UtcNow;
                    from.SendMessage("You cannot join another poker game for " + nextuse.Seconds + " seconds.");
                    return;
                }

                if (playermob.Aggressed.Any(info => (DateTime.UtcNow - info.LastCombatTime) < TimeSpan.FromSeconds(60)))
                {
                    playermob.SendMessage("You cannot join poker while you are in combat!");
                    return;
                }

                if (playermob.Aggressors.Any(info => (DateTime.UtcNow - info.LastCombatTime) < TimeSpan.FromSeconds(60)))
                {
                    playermob.SendMessage("You cannot join poker while you are in combat!");
                    return;
                }

                if (playermob.Party != null)
                {
                    playermob.SendMessage("You cannot join a poker game while in a party.");
                    return;
                }
            }


            if (!Dealer.InRange(from.Location, 8))
            {
                from.PrivateOverheadMessage(MessageType.Regular, 0x22, true, "I am too far away to do that",
                    from.NetState);
            }
            else if (GetIndexFor(from) != -1)
            {
                from.SendMessage(0x22, "You are already seated at this table");
            }
            else if (Players.Count >= Dealer.MaxPlayers)
            {
                from.SendMessage(0x22, "Sorry, that table is full");
            }
            else if (Banker.Withdraw(from, TypeOfCurrency, player.Currency))
            {
                Point3D seat = Point3D.Zero;

                foreach (Point3D seats in Dealer.Seats.Where(seats => !Dealer.SeatTaken(seats)))
                {
                    seat = seats;
                    break;
                }

                if (seat == Point3D.Zero)
                {
                    from.SendMessage(0x22, "Sorry, that table is full");
                    return;
                }

                player.Game = this;
                player.Seat = seat;
                player.TeleportToSeat();
                Players.Players.Add(player);

                ((PlayerMobile) from).PokerGame = this;
                from.SendMessage(0x22, "You have been seated at the table");

                if (Players.Count == 1 && !GameBackup.PokerGames.Contains(this))
                {
                    GameBackup.PokerGames.Add(this);
                }
                else if (State == PokerGameState.Inactive && Players.Count > 1 && !Dealer.TournamentMode)
                {
                    Begin();
                }
                else if (State == PokerGameState.Inactive && Players.Count >= Dealer.MaxPlayers && Dealer.TournamentMode)
                {
                    Dealer.TournamentMode = false;
                    Begin();
                }

                player.CloseGump(typeof(PokerTableGump));
                player.SendGump(new PokerTableGump(this, player));
                NeedsGumpUpdate = true;
                player.Chat = true;

                player.Mobile.Blessed = true;
            }
            else
            {
                from.SendMessage(0x22, "Your bank box lacks the funds to join this poker table");
            }
        }
Ejemplo n.º 5
0
        public void AddPlayer(PokerPlayer player)
        {
            Mobile from = player.Mobile;

            if (from == null)
            {
                return;
            }

            if (!m_Dealer.InRange(from.Location, 8))
            {
                from.PrivateOverheadMessage(Server.Network.MessageType.Regular, 0x22, true, "I am too far away to do that", from.NetState);
            }
            else if (GetIndexFor(from) != -1)
            {
                from.SendMessage(0x22, "You are already seated at this table");
            }
            else if (m_Players.Count >= m_Dealer.MaxPlayers)
            {
                from.SendMessage(0x22, "Sorry, that table is full");
            }

            /*else if ( TournamentSystem.TournamentCore.SignedUpTeam( from ) != null || TournamentSystem.TournamentCore.FindTeam( from ) != null )
             *      from.SendMessage( 0x22, "You may not join a poker game while signed up for a tournament." );*/
            else if (Banker.Withdraw(from, player.Gold))
            {
                Point3D seat = Point3D.Zero;

                foreach (Point3D seats in m_Dealer.Seats)
                {
                    if (!m_Dealer.SeatTaken(seats))
                    {
                        seat = seats;
                        break;
                    }
                }

                if (seat == Point3D.Zero)
                {
                    from.SendMessage(0x22, "Sorry, that table is full");
                    return;
                }

                player.Game = this;
                player.Seat = seat;
                player.TeleportToSeat();
                m_Players.Players.Add(player);

                ((PlayerMobile)from).PokerGame = this;
                from.SendMessage(0x22, "You have been seated at the table");

                if (m_Players.Count == 1 && !GameBackup.PokerGames.Contains(this))
                {
                    GameBackup.PokerGames.Add(this);
                }
                else if (m_State == PokerGameState.Inactive && m_Players.Count > 1 && !m_Dealer.TournamentMode)
                {
                    Begin();
                }
                else if (m_State == PokerGameState.Inactive && m_Players.Count >= m_Dealer.MaxPlayers && m_Dealer.TournamentMode)
                {
                    m_Dealer.TournamentMode = false;
                    Begin();
                }

                player.Mobile.CloseGump <PokerTableGump>();
                player.SendGump(new PokerTableGump(this, player));
                m_NeedsGumpUpdate = true;
            }
            else
            {
                from.SendMessage(0x22, "Your bank box lacks the funds to join this poker table");
            }
        }
Ejemplo n.º 6
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;
            int    buyInAmount;

            if (info.ButtonID != 1)
            {
                return;
            }

            PokerPlayer pokerplayer = m_Game.GetPlayer(from);

            if (pokerplayer != null)
            {
                int balance = Banker.GetBalance(from, m_Game.TypeOfCurrency);

                int currency = pokerplayer.Currency;

                if (balance + currency < m_Game.Dealer.MinBuyIn)
                {
                    from.SendMessage(
                        0x22,
                        "You do not have enough {0} to buy back in to the game. Minimum buy-in: {1:#,0}",
                        (m_Game.Dealer.IsDonation ? "donation coins" : "gold"),
                        m_Game.Dealer.MinBuyIn);

                    return;
                }


                var t = info.GetTextEntry(3);

                if (!Int32.TryParse(t.Text, out buyInAmount))
                {
                    from.SendMessage(0x22, "Use numbers without commas to input your buy-in amount (ie 25000)");
                    return;
                }

                if (buyInAmount > balance)
                {
                    from.SendMessage(
                        0x22,
                        "You do not have enough {0} to cover the specified buy-in amount.",
                        (m_Game.Dealer.IsDonation ? "donation coins" : "gold"));

                    return;
                }

                if (buyInAmount + currency < m_Game.Dealer.MinBuyIn)
                {
                    from.SendMessage(
                        0x22,
                        "You must at least specify an amount that equals the minimum buy-in. Minimum buy-in: {0:#,0}",
                        m_Game.Dealer.MinBuyIn);

                    return;
                }

                if (buyInAmount + currency > m_Game.Dealer.MaxBuyIn)
                {
                    from.SendMessage(
                        0x22,
                        "The specified buy-in amount + your current chips would put you over the max allowable buy-in.  Maximum buy-in: {0:#,0}",
                        m_Game.Dealer.MaxBuyIn);

                    return;
                }

                pokerplayer.PendingCredit = buyInAmount;
                pokerplayer.CloseGump(typeof(PokerTableGump));
                pokerplayer.SendGump(new PokerTableGump(m_Game, pokerplayer));
            }
        }