public PokerGame(PokerDealer dealer) { Dealer = dealer; NeedsGumpUpdate = false; CommunityCards = new List <Card>(); State = PokerGameState.Inactive; Deck = new Deck(); Timer = new PokerGameTimer(this); Players = new PlayerStructure(this); }
public PokerGame( PokerDealer dealer ) { m_Dealer = dealer; m_NeedsGumpUpdate = false; m_CommunityCards = new List<Card>(); m_State = PokerGameState.Inactive; m_Deck = new Deck(); m_Timer = new PokerGameTimer( this ); m_Players = new PlayerStructure( this ); }
public void Begin() { Players.Clear(); CurrentBet = 0; NextRaise = 0; Steps = 0; PokerLogging.createPokerLog(Dealer.TableName); foreach (PokerPlayer player in Players.Players) { if (player.PendingCredit > 0) { int balance = Banker.GetBalance(player.Mobile, TypeOfCurrency); if ((player.PendingCredit + player.Currency) > Dealer.MinBuyIn && (player.PendingCredit + player.Currency) < Dealer.MaxBuyIn && balance >= player.PendingCredit) { player.Currency += player.PendingCredit; Banker.Withdraw(player.Mobile, TypeOfCurrency, player.PendingCredit); player.Mobile.SendMessage(61, "You have withdrawn " + player.PendingCredit + "."); player.PendingCredit = 0; } else if ((player.PendingCredit + player.Currency) > Dealer.MaxBuyIn && balance >= player.PendingCredit) { int diff = Dealer.MaxBuyIn - player.Currency; if (diff > 0) { player.Currency += diff; Banker.Withdraw(player.Mobile, TypeOfCurrency, diff); player.Mobile.SendMessage(61, "You have withdrawn " + diff + "gp."); player.PendingCredit = 0; } else { player.Mobile.SendMessage(61, "You cannot withdraw any further currency as you are at or above the max buy-in."); player.PendingCredit = 0; } } else if ((player.PendingCredit + player.Currency) < Dealer.MinBuyIn) { player.Mobile.SendMessage(61, "Your current rebuy-in amount does not meet the minimum buy-in for this hand."); player.PendingCredit = 0; } } } List <PokerPlayer> dispose = Players.Players.Where(player => player.RequestLeave || !player.IsOnline() || player.Currency <= 0) .ToList(); foreach (PokerPlayer player in dispose.Where(player => Players.Contains(player))) { RemovePlayer(player); } foreach (PokerPlayer player in Players.Players) { player.ClearGame(); player.Game = this; if (player.Currency >= Dealer.BigBlind && player.IsOnline()) { Players.Round.Add(player); } } if (DealerButton == null) //First round / more player { if (Players.Round.Count == 2) //Only use dealer button and small blind { DealerButton = Players.Round[0]; SmallBlind = Players.Round[1]; BigBlind = null; } else if (Players.Round.Count > 2) { DealerButton = Players.Round[0]; SmallBlind = Players.Round[1]; BigBlind = Players.Round[2]; } else { return; } } else { if (Players.Round.Count == 2) //Only use dealer button and small blind { if (DealerButton == Players.Round[0]) { DealerButton = Players.Round[1]; SmallBlind = Players.Round[0]; } else { DealerButton = Players.Round[0]; SmallBlind = Players.Round[1]; } BigBlind = null; } else if (Players.Round.Count > 2) { int index = Players.Round.IndexOf(DealerButton); if (index == -1) //Old dealer button was lost :( { DealerButton = null; Begin(); //Start over return; } if (index == Players.Round.Count - 1) { DealerButton = Players.Round[0]; SmallBlind = Players.Round[1]; BigBlind = Players.Round[2]; } else if (index == Players.Round.Count - 2) { DealerButton = Players.Round[Players.Round.Count - 1]; SmallBlind = Players.Round[0]; BigBlind = Players.Round[1]; } else if (index == Players.Round.Count - 3) { DealerButton = Players.Round[Players.Round.Count - 2]; SmallBlind = Players.Round[Players.Round.Count - 1]; BigBlind = Players.Round[0]; } else { DealerButton = Players.Round[index + 1]; SmallBlind = Players.Round[index + 2]; BigBlind = Players.Round[index + 3]; } } else { return; } } PokerHand = new PokerHandObject(); PokerHand.Community = new List <Card>(); PokerHand.StartTime = DateTime.Now; PokerHand.PokerGameId = new PokerHandSerial(); PokerActions = new List <PokerActionObject>(); PokerPlayers = new List <PokerPlayerObject>(); CommunityCards.Clear(); Deck = new Deck(); State = PokerGameState.DealHoleCards; PokerLogging.StartNewHand(Dealer.TableName); PokerHand.InitialPlayers = Players.Players.Count; foreach (PokerPlayer player in Players.Players) { var playerobject = new PokerPlayerObject(); playerobject.PokerPlayerId = new PokerPlayerSerial(); playerobject.Serial = player.Mobile.Serial; playerobject.charname = player.Mobile.RawName; playerobject.HoleCards = new List <Card>(); playerobject.PokerGameId = PokerHand.PokerGameId; playerobject.Bankroll = player.Currency; PokerPlayers.Add(playerobject); } if (BigBlind != null) { BigBlind.Currency -= Dealer.BigBlind; CommunityCurrency += Dealer.BigBlind; BigBlind.RoundCurrency = Dealer.BigBlind; BigBlind.RoundBet = Dealer.BigBlind; BigBlind.Bet = Dealer.BigBlind; } else { DealerButton.Currency -= Dealer.BigBlind; CommunityCurrency += Dealer.BigBlind; DealerButton.RoundCurrency = Dealer.BigBlind; DealerButton.RoundBet = Dealer.BigBlind; DealerButton.Bet = Dealer.BigBlind; } SmallBlind.Currency -= Dealer.SmallBlind; CommunityCurrency += Dealer.SmallBlind; SmallBlind.RoundCurrency = Dealer.SmallBlind; SmallBlind.RoundBet = Dealer.SmallBlind; SmallBlind.Bet = Dealer.SmallBlind; NextRaise = Dealer.BigBlind; if (PokerPots == null) { PokerPots = new List <PokerPot>(); } var pokerpotobj = new PokerPot(); if (BigBlind != null) { pokerpotobj.AddtoPot(BigBlind.Bet, BigBlind); pokerpotobj.AddtoPot(SmallBlind.Bet, SmallBlind); } else { pokerpotobj.AddtoPot(SmallBlind.Bet, SmallBlind); } PokerPots.Add(pokerpotobj); if (BigBlind != null) { //m_Players.Push( m_BigBlind ); BigBlind.SetBBAction(); CurrentBet = Dealer.BigBlind; } else { //m_Players.Push( m_SmallBlind ); SmallBlind.SetBBAction(); CurrentBet = Dealer.BigBlind; } if (Players.Next() == null) { return; } NeedsGumpUpdate = true; Timer = new PokerGameTimer(this); Timer.Start(); }
public void Begin() { m_Players.Clear(); m_CurrentBet = 0; List<PokerPlayer> dispose = new List<PokerPlayer>(); foreach ( PokerPlayer player in m_Players.Players ) if ( player.RequestLeave || !player.IsOnline() ) dispose.Add( player ); foreach ( PokerPlayer player in dispose ) if ( m_Players.Contains( player ) ) RemovePlayer( player ); foreach ( PokerPlayer player in m_Players.Players ) { player.ClearGame(); player.Game = this; if ( player.Gold >= m_Dealer.BigBlind && player.IsOnline() ) m_Players.Round.Add( player ); } if ( m_DealerButton == null || m_SmallBlind == null ) //First round / more player { if ( m_Players.Round.Count == 2 ) //Only use small blind and big blind { m_DealerButton = null; m_SmallBlind = m_Players.Round[0]; m_BigBlind = m_Players.Round[1]; } else if ( m_Players.Round.Count > 2 ) { m_DealerButton = m_Players.Round[0]; m_SmallBlind = m_Players.Round[1]; m_BigBlind = m_Players.Round[2]; } else return; } else { if ( m_Players.Round.Count == 2 ) //Only use small blind and big blind { if ( m_BigBlind == m_Players.Round[1] ) { m_SmallBlind = m_Players.Round[1]; m_BigBlind = m_Players.Round[0]; } else { m_SmallBlind = m_Players.Round[0]; m_BigBlind = m_Players.Round[1]; } m_DealerButton = null; } else if ( m_Players.Round.Count > 2 ) { int index = m_Players.Round.IndexOf( m_DealerButton ); if ( index == -1 ) //Old dealer button was lost :( { m_DealerButton = null; Begin(); //Start over return; } if ( index == m_Players.Round.Count - 1 ) { m_DealerButton = m_Players.Round[0]; m_SmallBlind = m_Players.Round[1]; m_BigBlind = m_Players.Round[2]; } else if ( index == m_Players.Round.Count - 2 ) { m_DealerButton = m_Players.Round[m_Players.Round.Count - 1]; m_SmallBlind = m_Players.Round[0]; m_BigBlind = m_Players.Round[1]; } else if ( index == m_Players.Round.Count - 3 ) { m_DealerButton = m_Players.Round[m_Players.Round.Count - 2]; m_SmallBlind = m_Players.Round[m_Players.Round.Count - 1]; m_BigBlind = m_Players.Round[0]; } else { m_DealerButton = m_Players.Round[index + 1]; m_SmallBlind = m_Players.Round[index + 2]; m_BigBlind = m_Players.Round[index + 3]; } } else return; } m_CommunityCards.Clear(); m_Deck = new Deck(); m_State = PokerGameState.DealHoleCards; if ( m_BigBlind != null ) { m_BigBlind.Gold -= m_Dealer.BigBlind; m_CommunityGold += m_Dealer.BigBlind; m_BigBlind.RoundGold = m_Dealer.BigBlind; m_BigBlind.RoundBet = m_Dealer.BigBlind; m_BigBlind.Bet = m_Dealer.BigBlind; } m_SmallBlind.Gold -= m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind; m_CommunityGold += m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind; m_SmallBlind.RoundGold = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind; m_SmallBlind.RoundBet = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind; m_SmallBlind.Bet = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind; if ( m_BigBlind != null ) { //m_Players.Push( m_BigBlind ); m_BigBlind.SetBBAction(); m_CurrentBet = m_Dealer.BigBlind; } else { //m_Players.Push( m_SmallBlind ); m_SmallBlind.SetBBAction(); m_CurrentBet = m_Dealer.BigBlind; } if ( m_Players.Next() == null ) return; m_NeedsGumpUpdate = true; m_Timer = new PokerGameTimer( this ); m_Timer.Start(); }
public void Begin() { Players.Clear(); CurrentBet = 0; NextRaise = 0; Steps = 0; PokerLogging.createPokerLog(Dealer.TableName); foreach (PokerPlayer player in Players.Players) { if (player.PendingCredit > 0) { int balance = Banker.GetBalance(player.Mobile, TypeOfCurrency); if ((player.PendingCredit + player.Currency) > Dealer.MinBuyIn && (player.PendingCredit + player.Currency) < Dealer.MaxBuyIn && balance >= player.PendingCredit) { player.Currency += player.PendingCredit; Banker.Withdraw(player.Mobile, TypeOfCurrency, player.PendingCredit); player.Mobile.SendMessage(61, "You have withdrawn " + player.PendingCredit + "."); player.PendingCredit = 0; } else if ((player.PendingCredit + player.Currency) > Dealer.MaxBuyIn && balance >= player.PendingCredit) { int diff = Dealer.MaxBuyIn - player.Currency; if (diff > 0) { player.Currency += diff; Banker.Withdraw(player.Mobile, TypeOfCurrency, diff); player.Mobile.SendMessage(61, "You have withdrawn " + diff + "gp."); player.PendingCredit = 0; } else { player.Mobile.SendMessage(61, "You cannot withdraw any further currency as you are at or above the max buy-in."); player.PendingCredit = 0; } } else if ((player.PendingCredit + player.Currency) < Dealer.MinBuyIn) { player.Mobile.SendMessage(61, "Your current rebuy-in amount does not meet the minimum buy-in for this hand."); player.PendingCredit = 0; } } } List<PokerPlayer> dispose = Players.Players.Where(player => player.RequestLeave || !player.IsOnline() || player.Currency <= 0) .ToList(); foreach (PokerPlayer player in dispose.Where(player => Players.Contains(player))) { RemovePlayer(player); } foreach (PokerPlayer player in Players.Players) { player.ClearGame(); player.Game = this; if (player.Currency >= Dealer.BigBlind && player.IsOnline()) { Players.Round.Add(player); } } if (DealerButton == null) //First round / more player { if (Players.Round.Count == 2) //Only use dealer button and small blind { DealerButton = Players.Round[0]; SmallBlind = Players.Round[1]; BigBlind = null; } else if (Players.Round.Count > 2) { DealerButton = Players.Round[0]; SmallBlind = Players.Round[1]; BigBlind = Players.Round[2]; } else { return; } } else { if (Players.Round.Count == 2) //Only use dealer button and small blind { if (DealerButton == Players.Round[0]) { DealerButton = Players.Round[1]; SmallBlind = Players.Round[0]; } else { DealerButton = Players.Round[0]; SmallBlind = Players.Round[1]; } BigBlind = null; } else if (Players.Round.Count > 2) { int index = Players.Round.IndexOf(DealerButton); if (index == -1) //Old dealer button was lost :( { DealerButton = null; Begin(); //Start over return; } if (index == Players.Round.Count - 1) { DealerButton = Players.Round[0]; SmallBlind = Players.Round[1]; BigBlind = Players.Round[2]; } else if (index == Players.Round.Count - 2) { DealerButton = Players.Round[Players.Round.Count - 1]; SmallBlind = Players.Round[0]; BigBlind = Players.Round[1]; } else if (index == Players.Round.Count - 3) { DealerButton = Players.Round[Players.Round.Count - 2]; SmallBlind = Players.Round[Players.Round.Count - 1]; BigBlind = Players.Round[0]; } else { DealerButton = Players.Round[index + 1]; SmallBlind = Players.Round[index + 2]; BigBlind = Players.Round[index + 3]; } } else { return; } } PokerHand = new PokerHandObject(); PokerHand.Community = new List<Card>(); PokerHand.StartTime = DateTime.Now; PokerHand.PokerGameId = new PokerHandSerial(); PokerActions = new List<PokerActionObject>(); PokerPlayers = new List<PokerPlayerObject>(); CommunityCards.Clear(); Deck = new Deck(); State = PokerGameState.DealHoleCards; PokerLogging.StartNewHand(Dealer.TableName); PokerHand.InitialPlayers = Players.Players.Count; foreach (PokerPlayer player in Players.Players) { var playerobject = new PokerPlayerObject(); playerobject.PokerPlayerId = new PokerPlayerSerial(); playerobject.Serial = player.Mobile.Serial; playerobject.charname = player.Mobile.RawName; playerobject.HoleCards = new List<Card>(); playerobject.PokerGameId = PokerHand.PokerGameId; playerobject.Bankroll = player.Currency; PokerPlayers.Add(playerobject); } if (BigBlind != null) { BigBlind.Currency -= Dealer.BigBlind; CommunityCurrency += Dealer.BigBlind; BigBlind.RoundCurrency = Dealer.BigBlind; BigBlind.RoundBet = Dealer.BigBlind; BigBlind.Bet = Dealer.BigBlind; } else { DealerButton.Currency -= Dealer.BigBlind; CommunityCurrency += Dealer.BigBlind; DealerButton.RoundCurrency = Dealer.BigBlind; DealerButton.RoundBet = Dealer.BigBlind; DealerButton.Bet = Dealer.BigBlind; } SmallBlind.Currency -= Dealer.SmallBlind; CommunityCurrency += Dealer.SmallBlind; SmallBlind.RoundCurrency = Dealer.SmallBlind; SmallBlind.RoundBet = Dealer.SmallBlind; SmallBlind.Bet = Dealer.SmallBlind; NextRaise = Dealer.BigBlind; if (PokerPots == null) { PokerPots = new List<PokerPot>(); } var pokerpotobj = new PokerPot(); if (BigBlind != null) { pokerpotobj.AddtoPot(BigBlind.Bet, BigBlind); pokerpotobj.AddtoPot(SmallBlind.Bet, SmallBlind); } else { pokerpotobj.AddtoPot(SmallBlind.Bet, SmallBlind); } PokerPots.Add(pokerpotobj); if (BigBlind != null) { //m_Players.Push( m_BigBlind ); BigBlind.SetBBAction(); CurrentBet = Dealer.BigBlind; } else { //m_Players.Push( m_SmallBlind ); SmallBlind.SetBBAction(); CurrentBet = Dealer.BigBlind; } if (Players.Next() == null) { return; } NeedsGumpUpdate = true; Timer = new PokerGameTimer(this); Timer.Start(); }
public void Begin() { m_Players.Clear(); m_CurrentBet = 0; List <PokerPlayer> dispose = new List <PokerPlayer>(); foreach (PokerPlayer player in m_Players.Players) { if (player.RequestLeave || !player.IsOnline()) { dispose.Add(player); } } foreach (PokerPlayer player in dispose) { if (m_Players.Contains(player)) { RemovePlayer(player); } } foreach (PokerPlayer player in m_Players.Players) { player.ClearGame(); player.Game = this; if (player.Gold >= m_Dealer.BigBlind && player.IsOnline()) { m_Players.Round.Add(player); } } if (m_DealerButton == null) //First round / more player { if (m_Players.Round.Count == 2) //Only use dealer button and small blind { m_DealerButton = m_Players.Round[0]; m_SmallBlind = m_Players.Round[1]; m_BigBlind = null; } else if (m_Players.Round.Count > 2) { m_DealerButton = m_Players.Round[0]; m_SmallBlind = m_Players.Round[1]; m_BigBlind = m_Players.Round[2]; } else { return; } } else { if (m_Players.Round.Count == 2) //Only use dealer button and small blind { if (m_DealerButton == m_Players.Round[0]) { m_DealerButton = m_Players.Round[1]; m_SmallBlind = m_Players.Round[0]; } else { m_DealerButton = m_Players.Round[0]; m_SmallBlind = m_Players.Round[1]; } m_BigBlind = null; } else if (m_Players.Round.Count > 2) { int index = m_Players.Round.IndexOf(m_DealerButton); if (index == -1) //Old dealer button was lost :( { m_DealerButton = null; Begin(); //Start over return; } if (index == m_Players.Round.Count - 1) { m_DealerButton = m_Players.Round[0]; m_SmallBlind = m_Players.Round[1]; m_BigBlind = m_Players.Round[2]; } else if (index == m_Players.Round.Count - 2) { m_DealerButton = m_Players.Round[m_Players.Round.Count - 1]; m_SmallBlind = m_Players.Round[0]; m_BigBlind = m_Players.Round[1]; } else if (index == m_Players.Round.Count - 3) { m_DealerButton = m_Players.Round[m_Players.Round.Count - 2]; m_SmallBlind = m_Players.Round[m_Players.Round.Count - 1]; m_BigBlind = m_Players.Round[0]; } else { m_DealerButton = m_Players.Round[index + 1]; m_SmallBlind = m_Players.Round[index + 2]; m_BigBlind = m_Players.Round[index + 3]; } } else { return; } } m_CommunityCards.Clear(); m_Deck = new Deck(); m_State = PokerGameState.DealHoleCards; if (m_BigBlind != null) { m_BigBlind.Gold -= m_Dealer.BigBlind; m_CommunityGold += m_Dealer.BigBlind; m_BigBlind.RoundGold = m_Dealer.BigBlind; m_BigBlind.RoundBet = m_Dealer.BigBlind; m_BigBlind.Bet = m_Dealer.BigBlind; } m_SmallBlind.Gold -= m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind; m_CommunityGold += m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind; m_SmallBlind.RoundGold = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind; m_SmallBlind.RoundBet = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind; m_SmallBlind.Bet = m_BigBlind == null ? m_Dealer.BigBlind : m_Dealer.SmallBlind; if (m_BigBlind != null) { //m_Players.Push( m_BigBlind ); m_BigBlind.SetBBAction(); m_CurrentBet = m_Dealer.BigBlind; } else { //m_Players.Push( m_SmallBlind ); m_SmallBlind.SetBBAction(); m_CurrentBet = m_Dealer.BigBlind; } if (m_Players.Next() == null) { return; } m_NeedsGumpUpdate = true; m_Timer = new PokerGameTimer(this); m_Timer.Start(); }