예제 #1
0
        /// <summary>
        /// Определяет размер выигрыша человека
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        private int getWinningAmount(Player player)
        {
            int bank = this.bets.Sum(bet => bet.Value);
            if (bank == 0)
            {
                return 0;
            }
            IEnumerable<Bug> raceWinners = this.bugs.Where(bug => bug.distance >= this.trackLength);
            int playerWinningContribution = (from bet in this.bets
                                        where raceWinners.Contains(bet.Key.Value) && player == bet.Key.Key
                                        select bet.Value).Sum();

            return (int)(playerWinningContribution * this.payout);
        }
예제 #2
0
 /// <summary>
 /// Осуществление ставки на участника.
 /// </summary>
 /// <param name="player">Игрок, осуществляющйи ставку</param>
 /// <param name="bug">Участник забега, на победу которого осуществляется ставка</param>
 /// <param name="amount">Сумма ставки</param>
 private void addBet(Player player, Bug bug, int amount)
 {
     this.bets[new KeyValuePair<Player, Bug>(player, bug)] = amount;
     this.updateBetsInfoboard();
 }
예제 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="balance">@see Player.balance</param>
        /// <param name="name">@see Player.name</param>
        public static Player CreateNewPlayer(string name, int balance)
        {
            Player p = new Player();

            p.balance = balance;
            p.name = name;

            return p;
        }