Exemple #1
0
        /// <summary>
        /// If successful, takes money from player SafeMoneyAmount to BetMoneyAmount. It will also repay debts if any.
        /// </summary>
        /// <param name="p">Player</param>
        /// <param name="amount">Amount of money collecting</param>
        /// <returns></returns>
        public bool CollectMoneyFromPlayer(PlayerInfo p, int amount)
        {
            bool hadEnoughMoney = p.TryBet(amount);

            if (hadEnoughMoney)
            {
                MoneyAmount += amount;
                RepayDebt(p, amount);
                if (!PlayersWithMoneyAmountInPlay.Contains(p))
                {
                    PlayersWithMoneyAmountInPlay.Add(p);
                }
            }

            return(hadEnoughMoney);
        }
Exemple #2
0
        /// <summary>
        /// Takes all the money in front of every player and deposit it into money pots.
        /// </summary>
        public void DepositMoneyInPlay()
        {
            var allInPlayers = PlayersWithMoneyAmountInPlay.Where(p => p.State == PlayerStateEnum.AllIn).ToArray();

            if (allInPlayers.Any())
            {
                int given = 0;
                foreach (var cap in allInPlayers.Select(p => p.MoneyBetAmnt).OrderBy(a => a))
                {
                    PlayersWithMoneyAmountInPlay.ForEach(p => Pots.Peek().Contribute(p, cap - given));
                    given += cap - given;
                    Pots.Push(new MoneyPot());
                }
            }
            PlayersWithMoneyAmountInPlay.ForEach(p => Pots.Peek().Contribute(p, p.MoneyBetAmnt));
            PlayersWithMoneyAmountInPlay.Clear();
        }