private async Task ManagePoints(IEnumerable <string> winners, BlackjackGame game) { // Add points to winners if (winners.Count() == 1) { await _usersPointsRepository.AddBalanceToUserAccount(winners.First(), game.MoneyToWin); } else { var splittedAmount = Math.Floor(game.MoneyToWin / winners.Count()); foreach (var winner in winners) { await _usersPointsRepository.AddBalanceToUserAccount(winner, (float)splittedAmount); } } // Remove points from loosers var losers = game.Members.Where(x => !winners.ToList().Contains(x.UserId)) .Select(x => x.UserId); foreach (var loser in losers) { await _usersPointsRepository.SubtractBalanceFromUserAccount(loser, game.BetAmount); } }
private async Task ManagePoints(bool attackerWon) { var oppenentId = _command.Arguments[0].Substring(3, _command.Arguments[0].Length - 4); if (attackerWon) { attackerBalance += gameBounty; defenderBalance -= gameBounty; await _userPointsRepository.AddBalanceToUserAccount(_command.Author.Id, gameBounty); await _userPointsRepository.SubtractBalanceFromUserAccount(oppenentId, gameBounty); } else { attackerBalance -= gameBounty; defenderBalance += gameBounty; await _userPointsRepository.AddBalanceToUserAccount(oppenentId, gameBounty); await _userPointsRepository.SubtractBalanceFromUserAccount(_command.Author.Id, gameBounty); } }