Exemple #1
0
 private static void GivePrizeWinner(UserAccount account, Prize prize)
 {
     account.Cash += prize.Cash;
     account.NumberOfKeys--;
     account.NumberOfCases--;
     account.CasesProfit += (uint)prize.Cash;
     account.OpenedCases++;
     account.lastCaseOpen = DateTime.Now;
     UserAccounts.SaveAccounts();
 }
Exemple #2
0
        public async Task OpenCase()
        {
            var account = UserAccounts.GetAccount(Context.User);

            if (!CanOpen(account))
            {
                return;
            }

            Prize prize = Prize.GetRandomPrize(prizes, scale);

            await Context.Channel.SendMessageAsync($"{Context.User.Mention} wygrales **{prize.Name}**");

            GivePrizeWinner(account, prize);
        }
Exemple #3
0
        static public async Task Do(SocketGuild guild, SocketTextChannel channel)
        {
            if (!IsAtLeastTwoUsersOnline(guild))
            {
                return;
            }

            SocketGuildUser user    = GetRandomUser(guild);
            var             account = UserAccounts.GetAccount(user);
            Prize           prize   = Prize.GetRandomPrize(prizes, scale);

            await channel.SendMessageAsync($"Gratuluje {user.Mention}." + $" Wygrales **{prize.Name}**");

            GivePrize(account, prize);
            lastWinner = user;
        }
Exemple #4
0
        public async Task PlayRoulette(int placedCash)
        {
            var account = UserAccounts.GetAccount(Context.User);

            TimeSpan requiredTime = new TimeSpan(0, 0, Config.Bot.timeRoulette);

            if (!Misceleanous.WasRequiredTimeElapsed(account.lastRoulette, requiredTime))
            {
                TimeSpan waitingTime = account.lastRoulette + requiredTime - DateTime.Now;
                await Context.Channel.SendMessageAsync($"Kolejna gra dostepna za " +
                                                       $"`{waitingTime.Minutes}m:{waitingTime.Seconds}s`.");

                return;
            }

            if (placedCash > account.Cash)
            {
                await Context.Channel.SendMessageAsync($"Kanciarza chcesz kantowac?");

                return;
            }

            if (placedCash < 20)
            {
                await Context.Channel.SendMessageAsync($"Minimalna kwota zakladu to 20 dudow.");

                return;
            }

            double chance = CountChance(account.Cash, placedCash);
            Prize  prize  = DoDraw(placedCash, chance);

            if (prize.Cash > 0)
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention} **WYGRALES!** Miales na to szanse **{(int)chance}%** i zarobiles **{prize.Cash}** dudow. Dodatkowo dostajesz {prize.XP} punktow statusu spolecznego.");
            }
            else
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention} **PRZEGRALES.** Szansa na wygrana wynosila **{(int)chance}%** i straciles **{prize.Cash}** dudow. Udalo ci sie za to dostac **{prize.XP}** punktow statusu spolecznego.");
            }

            GivePrize(account, prize);
        }