Ejemplo n.º 1
0
        public string Winner(string winner)
        {
            GameOpen = false;
            var winners = ActiveBets.Where(b => b.Tribute.Equals(winner, StringComparison.InvariantCultureIgnoreCase))
                          .Select(b => _channel.Server.GetUser(b.UserId));

            if (winners.Count() > 0)
            {
                var payout   = ActiveBets.Sum(b => b.BettedAmount) / winners.Count();
                var rounding = ActiveBets.Sum(b => b.BettedAmount) % winners.Count();

                foreach (var user in winners)
                {
                    _bank.Accounts.SingleOrDefault(u => u.UserId == user.Id).Bucks += payout;
                }
                _bank.WriteBank();

                if (winners.Count() == 1)
                {
                    return($"{winners.Single().Name} has won the whole pot of {symbol}{payout}.");
                }
                else
                {
                    return($"{String.Join(", ", winners.Select(u => u.Name))} have won {symbol}{payout} each. {symbol}{rounding} has been lost due to rounding.");
                }
            }
            else
            {
                return($"No bets were made on the winner of this game.");
            }
        }
Ejemplo n.º 2
0
 public void ClosingGame()
 {
     _countDown = new Timer(async cb =>
     {
         CloseOff();
         await _channel.SendMessage($"Bets are closed. {ActiveBets.Count} bets are in. The pot is {symbol}{ActiveBets.Sum(b => b.BettedAmount)}.");
     },
                            null,
                            TimeSpan.FromSeconds((GType == GameType.SaltyBet ? 30 : 45)),
                            Timeout.InfiniteTimeSpan);
 }