Exemplo n.º 1
0
        private async Task DoTransferIfFullfillConditions(UserAccount sender, UserAccount recipient, int amount)
        {
            TimeSpan requiredTime = new TimeSpan(Config.Bot.timeTransfer);

            if (!Misceleanous.WasRequiredTimeElapsed(sender.lastTransfer, requiredTime))
            {
                TimeSpan waitingTime = sender.lastTransfer + requiredTime - DateTime.Now;
                await Context.Channel.SendMessageAsync($"Kolejny przelew dostepny za " +
                                                       $"`{waitingTime.Minutes}m:{waitingTime.Seconds}s`.");

                return;
            }

            if (sender.Cash < amount)
            {
                await Context.Channel.SendMessageAsync($"Tfu, biedaku robaku. Nie masz tyle hajsu.");

                return;
            }

            if (amount < Config.Bot.minimalTransfer)
            {
                await Context.Channel.SendMessageAsync($"Minimalna kwota przelewu to **{Config.Bot.minimalTransfer}** dudow.");

                return;
            }

            await DoTransfer(sender, recipient, amount);
        }
Exemplo n.º 2
0
        private async Task UpdateWearOf(SocketGuildUser user)
        {
            var  account       = UserAccounts.GetAccount(user);
            var  color         = account.Equipment.Find(x => x.ID == account.ActuallyColor);
            bool needToAddRole = true;

            foreach (var e in account.Equipment)
            {
                if (Miscelenaous.IsUserRankOwner(user, e.Name))
                {
                    if (e.ID == AvalibleColors[account.ActuallyColor].ID)
                    {
                        needToAddRole = false;
                        continue;
                    }

                    var roleToDelete = user.Guild.Roles.FirstOrDefault(r => r.Name == e.Name);
                    await user.RemoveRoleAsync(roleToDelete);
                }
            }

            if (needToAddRole)
            {
                var role = user.Guild.Roles.FirstOrDefault(r => r.Name == AvalibleColors[account.ActuallyColor].Name);
                await user.AddRoleAsync(role);
            }

            UserAccounts.SaveAccounts();
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        private bool CanOpen(UserAccount account)
        {
            TimeSpan requiredTime = new TimeSpan(0, 0, Config.Bot.timeCase);

            if (!Misceleanous.WasRequiredTimeElapsed(account.lastCaseOpen, requiredTime))
            {
                TimeSpan waitingTime = account.lastCaseOpen + requiredTime - DateTime.Now;
                Context.Channel.SendMessageAsync($"Kolejna skrzynke otworzysz za `{waitingTime.Seconds}s`.");
                return(false);
            }

            if (account.NumberOfCases == 0 || account.NumberOfKeys == 0)
            {
                Context.Channel.SendMessageAsync("Nie posiadasz skrzynki lub klucza");
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        public async Task Give10Cash()
        {
            var account = UserAccounts.GetAccount(Context.User);

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

            if (Misceleanous.WasRequiredTimeElapsed(account.last10Use, requiredTime))
            {
                account.Cash += 10;
                await Context.Channel.SendMessageAsync($"**10** dudow dla ksieciunia!");

                account.last10Use = DateTime.Now;
                UserAccounts.SaveAccounts();
            }
            else
            {
                TimeSpan waitingTime = account.last10Use + requiredTime - DateTime.Now;
                await Context.Channel.SendMessageAsync($"Ejze, Menelaosie. Poczekaj ze " +
                                                       $"`{waitingTime.Minutes}m:{waitingTime.Seconds}s` na kolejny datek!");
            }
        }
Exemplo n.º 6
0
        public async Task Give500Cash()
        {
            var      account      = UserAccounts.GetAccount(Context.User);
            TimeSpan requiredTime = new TimeSpan(0, 0, Config.Bot.time500);

            if (Misceleanous.WasRequiredTimeElapsed(account.last500Use, requiredTime))
            {
                account.Cash += 500;
                await Context.Channel.SendMessageAsync($"Gratuluje dziecka! Dostales **500** dudow.");

                account.last500Use = DateTime.Now;
                UserAccounts.SaveAccounts();
            }
            else
            {
                TimeSpan waitingTime = account.last500Use + requiredTime - DateTime.Now;
                await Context.Channel.SendMessageAsync($"Hola hola, musisz poczekac jeszcze " +
                                                       $"`{waitingTime.Hours}h:{waitingTime.Minutes}m` " +
                                                       $"zanim bedziesz mogl pobrac kolejne swiadczenie!.");
            }
        }