예제 #1
0
        public void Close(ChallengeScoreboard scoreboard)
        {
            var payouts = new ChallengeParticipantPayouts(scoreboard);

            foreach (var bucket in scoreboard.PayoutBuckets)
            {
                for (var index = 0; index < bucket.Size; index++)
                {
                    if (!scoreboard.Winners.Any())
                    {
                        break;
                    }

                    var userId = scoreboard.Winners.Dequeue();

                    this.AddDomainEvent(new ChallengeParticipantPayoutDomainEvent(userId, bucket.Prize));

                    payouts[userId] = new ChallengePayoutBucketPrize(bucket.Prize);
                }
            }

            foreach (var userId in scoreboard.Losers)
            {
                this.AddDomainEvent(new ChallengeParticipantPayoutDomainEvent(userId, ChallengePayoutBucketPrize.Consolation));

                payouts[userId] = ChallengePayoutBucketPrize.Consolation;
            }

            this.AddDomainEvent(new ChallengeClosedDomainEvent(Id, payouts));
        }
예제 #2
0
 public ChallengePayoutBucket(ChallengePayoutBucketPrize prize, ChallengePayoutBucketSize size)
 {
     Size  = size;
     Prize = prize;
 }