Add pick db interaction
This commit is contained in:
parent
09e5b671c8
commit
57058060c2
@ -154,27 +154,8 @@ namespace ChaosBot.Discord.Modules
|
||||
|
||||
private void PickRaffle(StringBuilder sb)
|
||||
{
|
||||
int totalRaffle = _currentPot.Values.Sum();
|
||||
|
||||
if (totalRaffle == 0)
|
||||
{
|
||||
sb.Append("No one has any rafflepoints.");
|
||||
return;
|
||||
}
|
||||
|
||||
int winner = new Random().Next(totalRaffle);
|
||||
foreach (ulong userId in _currentPot.Keys)
|
||||
{
|
||||
int userValue = _currentPot.GetValueOrDefault(userId);
|
||||
if (winner <= userValue)
|
||||
{
|
||||
sb.Append($"<@{userId}> has won the raffle!");
|
||||
ClearRaffle(sb, true);
|
||||
return;
|
||||
}
|
||||
|
||||
winner -= userValue;
|
||||
}
|
||||
Raffle winner = RaffleRepository.PickRandom();
|
||||
sb.Append($"<@{winner.userId}> has won the raffle!");
|
||||
}
|
||||
|
||||
private void ClearRaffle(StringBuilder sb, bool noOutput = false)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user