public static IEnumerable <PriorityBonusDto> GetListBonuses(PriorityScope scope, int attendances, RaidMemberStatus status, long donatedCopper)
        {
            yield return(GetAttendanceBonus(scope, attendances));

            yield return(GetStatusBonus(scope, status));

            yield return(GetDonationBonus(scope, donatedCopper));
 static PriorityBonusDto GetAttendanceBonus(PriorityScope scope, int attendances)
 {
     return(new AttendancePriorityBonusDto
     {
         Type = PriorityBonusTypes.Attendance,
         Value = (int)Math.Floor((double)Math.Min(attendances, scope.ObservedAttendances) / scope.AttendancesPerPoint),
         AttendancePerPoint = scope.AttendancesPerPoint,
         Attended = attendances,
         ObservedAttendances = scope.ObservedAttendances
     });
 }
 static PriorityBonusDto GetStatusBonus(PriorityScope scope, RaidMemberStatus status)
 {
     return(new MembershipPriorityBonusDto
     {
         Type = PriorityBonusTypes.Trial,
         Value = status switch
         {
             RaidMemberStatus.HalfTrial => scope.HalfTrialPenalty,
             RaidMemberStatus.FullTrial => scope.FullTrialPenalty,
             RaidMemberStatus.Member => 0,
             _ => throw new ArgumentOutOfRangeException(nameof(status))
         },
 public static int CalculateAttendanceBonus(int attendances, PriorityScope scope)
 {
     return((int)Math.Floor((double)Math.Min(attendances, scope.ObservedAttendances) / scope.AttendancesPerPoint));
 }
示例#5
0
        public async Task <DonationMatrix> GetDonationMatrixAsync(Expression <Func <Donation, bool> > predicate, PriorityScope scope, CancellationToken cancellationToken = default)
        {
            var results = await Donations
                          .AsNoTracking()
                          .Where(d => d.RemovalId == null)
                          .Where(predicate)
                          .Select(d => new { d.DonatedAt.Year, d.DonatedAt.Month, d.CharacterId, d.CopperAmount })
                          .GroupBy(d => new { d.Year, d.Month, d.CharacterId })
                          .Select(g => new MonthDonations
            {
                CharacterId = g.Key.CharacterId,
                Donated     = g.Sum(d => d.CopperAmount),
                Month       = g.Key.Month,
                Year        = g.Key.Year,
            })
                          .OrderBy(md => md.CharacterId)
                          .ThenBy(md => md.Year)
                          .ThenBy(md => md.Month)
                          .ToListAsync(cancellationToken);

            return(new(results, scope));
        }