public void End() { foreach (PokerPlayer player in Players.Players.ToList()) { player.CloseGump(typeof(PokerTableGump)); player.SendGump(new PokerTableGump(this, player)); } State = PokerGameState.Inactive; PokerHand.EndTime = DateTime.Now; PokerLogging.EndHand(Dealer.TableName); PokerExport.HandsToExport.Add(PokerHand); foreach (PokerActionObject pokerActionObject in PokerActions) { PokerExport.ActionsToExport.Add(pokerActionObject); } foreach (PokerPlayerObject pokerplayer in PokerPlayers) { PokerExport.PlayersToExport.Add(pokerplayer); } PokerPots.Clear(); if (Timer.Running) { Timer.Stop(); } }
public void SplitPots() { var firstpot = PokerPots.FirstOrDefault(); if (firstpot != null) { var newpot = firstpot; while (newpot != null) { var tempdict = newpot.SplitPot(); if (tempdict == null || tempdict.Count <= 0) { newpot = null; } else { newpot = new PokerPot(tempdict); PokerPots.Add(newpot); } } } }
public void ResetGame() { CloseGumps(); State = PokerGameState.Inactive; RoundActions = new List <PlayerAction>(); CommunityCards.Clear(); //create and shuffle a new deck Deck = new Deck(); PokerPots.Clear(); ActivePlayers.Clear(); foreach (var player in Players.ToArray()) { player.ClearGame(); } ActivePlayers.AddRange(Players.Where(x => x.Currency > 0)); if (GetActiveElliblePlayersCount() > 1) { BeginGame(); } else { StopIntermission(); ActivePlayers.Clear(); } }
public void BeginGame() { StartTime = DateTime.Now; DetermineBlinds(); PokerPots.Add(new PokerPot()); State = PokerGameState.DealHoleCards; }
public void MakeBet(PokerPlayer player, int bet) { player.MakeBet(bet); var pot = PokerPots.FirstOrDefault(); if (pot != null) { pot.AddtoPot(bet, player); } }
public void CreateSidePots() { PokerPot newPot; do { var pot = PokerPots.Last(); newPot = pot.TrySplitPot(); if (newPot != null) { PokerPots.Add(newPot); } }while (newPot != null); }
public void CheckPot(int amount, PokerPlayer player, bool allin = false) { /*if (allin) * { * foreach (PokerPot pokerPot in PokerPots) * { * if (pokerPot.MaxContributionAmountPerPlayer == 0) * { * pokerPot.MaxContributionAmountPerPlayer = amount + player.RoundCurrency; * break; * } * * if (amount + player.RoundCurrency < pokerPot.MaxContributionAmountPerPlayer) * { * Dictionary<PokerPlayer, int> newpot = pokerPot.CheckAllIn(amount + player.RoundCurrency); * * foreach (PokerPlayer p in Players.Players) * { * p.Mobile.SendMessage(61, "POT DIVISION OCCURRED"); * } * * newpot = PokerPots.Aggregate(newpot, (current, pot) => pot.DivisionAdjustment(current)); * * PokerPots.Add(new PokerPot(newpot)); * break; * } * } * } * amount = PokerPots.Aggregate(amount, (current, pokerPot) => pokerPot.CheckContribution(current, player)); * * if (amount > 0) * { * foreach (PokerPlayer p in Players.Players) * { * p.Mobile.SendMessage(61, "SPLIT POT CREATED: " + amount + "GP ADDED TO IT"); * } * * PokerPots.Add(new PokerPot(amount, player)); * }*/ var mainpot = PokerPots.FirstOrDefault(); if (mainpot != null) { mainpot.AddtoPot(amount, player); } }
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(); }