예제 #1
0
        public async Task RemoveMoney(SocketUser mentionedUser, int amount)
        {
            List <string> roles = new List <string>();

            roles.Add(Setup.ApeChieftainRole);

            if (await Tools.RolesCheck(Context, roles, true, roles[0]))
            {
                //Create player folder if it doesn't exist
                Directory.CreateDirectory(Setup.PlayerSavesPath + "/" + mentionedUser.Id);
                //Loaded data
                BinaryMoneyNormal entry = new BinaryMoneyNormal(0, 0, Context.Message.Timestamp.Ticks, Context.Message.Timestamp.Offset.Ticks);
                //Load
                MoneyNormal.Load(Setup.PlayerSavesPath + "/" + mentionedUser.Id + "/" + "Money", ref entry);
                //Modify
                entry.Money -= amount;
                //Save
                MoneyNormal.Save(Setup.PlayerSavesPath + "/" + mentionedUser.Id + "/" + "Money", entry);

                EmbedBuilder eb   = new EmbedBuilder();
                string       text = mentionedUser.Mention + " you have loss **$" + amount + "** credits!";
                eb.WithDescription(text);
                eb.WithColor(Color.Orange);

                await Context.Channel.SendMessageAsync("", false, eb.Build());
            }
            await Context.Message.DeleteAsync();
        }
예제 #2
0
        public async Task Daily()
        {
            EmbedBuilder eb = new EmbedBuilder();

            //Create player folder if it doesn't exist
            Directory.CreateDirectory(Setup.PlayerSavesPath + "/" + Context.User.Id);
            //Loaded data
            BinaryMoneyNormal entry = new BinaryMoneyNormal(0, 0, Context.Message.Timestamp.Ticks, Context.Message.Timestamp.Offset.Ticks);
            //Load
            bool fileExists = MoneyNormal.Load(Setup.PlayerSavesPath + "/" + Context.User.Id + "/" + "Money", ref entry);

            DateTimeOffset lastLoadedTimestamp = new DateTimeOffset(entry.DateTimeTicks, new TimeSpan(entry.DateTimeOffsetTicks));
            DateTimeOffset nextUpdateTimestamp = lastLoadedTimestamp.AddHours(Setup.HoursTillReset);
            TimeSpan       nextUpdateTime      = nextUpdateTimestamp.Subtract(Context.Message.Timestamp);

            //Check if time threshold has passed to execute again
            if (nextUpdateTime.TotalHours <= 0 || !fileExists)
            {
                //Modify
                entry.CurrentBonusDay += 1;
                if (entry.CurrentBonusDay > 5)
                {
                    entry.CurrentBonusDay = 1;
                }
                entry.Money              += Setup.DailyBaseWorth * entry.CurrentBonusDay;
                entry.DateTimeTicks       = Context.Message.Timestamp.Ticks;
                entry.DateTimeOffsetTicks = Context.Message.Timestamp.Offset.Ticks;
                //Save
                MoneyNormal.Save(Setup.PlayerSavesPath + "/" + Context.User.Id + "/" + "Money", entry);

                string[] streakSymbols = new string[5];
                streakSymbols[0] = "🇨 ";
                streakSymbols[1] = "🇭 ";
                streakSymbols[2] = "🇮 ";
                streakSymbols[3] = "🇲 ";
                streakSymbols[4] = "🇵 ";
                string streak = "";
                for (int i = 0; i < entry.CurrentBonusDay; i++)
                {
                    streak += streakSymbols[i];
                }

                eb.Title = "**💰 Daily! " + Tools.GetNickname(Context, Context.User.Id) + "**";
                string text =
                    "You got **$" + Setup.DailyBaseWorth * entry.CurrentBonusDay + "** daily credits!" + "\n" +
                    "**Streak: " + streak + "**";
                eb.WithDescription(text);
                eb.WithColor(Color.Gold);
            }
            else
            {
                eb.Title = "**🚫 " + Tools.GetNickname(Context, Context.User.Id) + " please wait " + (nextUpdateTime.Hours) + " hours, " + (nextUpdateTime.Minutes) + " minutes, and " + (nextUpdateTime.Seconds) + " seconds for daily! 💰**";
                eb.WithColor(Color.Red);
            }
            await Context.Channel.SendMessageAsync("", false, eb.Build());

            await Context.Message.DeleteAsync();
        }
예제 #3
0
        public async Task Flip(int amount)
        {
            EmbedBuilder eb = new EmbedBuilder();

            //Create player folder if it doesn't exist
            Directory.CreateDirectory(Setup.PlayerSavesPath + "/" + Context.User.Id);
            //Loaded data
            BinaryMoneyNormal entry = new BinaryMoneyNormal(0, 0, Context.Message.Timestamp.Ticks, Context.Message.Timestamp.Offset.Ticks);

            //Load
            MoneyNormal.Load(Setup.PlayerSavesPath + "/" + Context.User.Id + "/" + "Money", ref entry);

            int chance = Setup.Rand.Next(0, 2);

            //Check if theres enough money
            if (entry.Money >= amount)
            {
                //Win
                if (chance == 0)
                {
                    //Modify
                    entry.Money += amount;
                    eb.Title     = "**💸 Flip!**";
                    string text = Context.User.Mention + " you won the flip! You have earned **$" + amount + "** credits!";
                    eb.WithDescription(text);
                    eb.WithColor(Color.Green);
                }
                //Lose
                else
                {
                    entry.Money -= amount;
                    eb.Title     = "**💸 Flip!**";
                    string text = Context.User.Mention + " you lose the flip! You have lossed **$" + amount + "** credits!";
                    eb.WithDescription(text);
                    eb.WithColor(Color.Orange);
                }
                //Save
                MoneyNormal.Save(Setup.PlayerSavesPath + "/" + Context.User.Id + "/" + "Money", entry);
            }
            else
            {
                eb.Title = "**🚫 " + Tools.GetNickname(Context, Context.User.Id) + " you don't have enough credits to flip that amount!**";
                eb.WithColor(Color.Red);
            }
            await Context.Channel.SendMessageAsync("", false, eb.Build());

            await Context.Message.DeleteAsync();
        }
예제 #4
0
        public async Task BuyRing()
        {
            EmbedBuilder eb = new EmbedBuilder();

            //Create player folder if it doesn't exist
            Directory.CreateDirectory(Setup.PlayerSavesPath + "/" + Context.User.Id);
            Directory.CreateDirectory(Setup.PlayerSavesPath + "/" + Context.User.Id + "/Inventory");

            if (!Empty.Load(Setup.PlayerSavesPath + "/" + Context.User.Id + "/Inventory/WeddingRing"))
            {
                //Loaded data
                BinaryMoneyNormal moneyEntry = new BinaryMoneyNormal(0, 0, Context.Message.Timestamp.Ticks, Context.Message.Timestamp.Offset.Ticks);
                //Load
                MoneyNormal.Load(Setup.PlayerSavesPath + "/" + Context.User.Id + "/" + "Money", ref moneyEntry);

                if (moneyEntry.Money >= Setup.MarriagePrice)
                {
                    //Modify
                    moneyEntry.Money -= Setup.MarriagePrice;
                    //Save
                    MoneyNormal.Save(Setup.PlayerSavesPath + "/" + Context.User.Id + "/" + "Money", moneyEntry);
                    Empty.Save(Setup.PlayerSavesPath + "/" + Context.User.Id + "/Inventory/WeddingRing");

                    eb.Title = "**🛍️ wedding ring bought!**";
                    string text =
                        Context.User.Mention + " you have bought a __**wedding ring**__  for **$" + Setup.MarriagePrice + "** credits!" + "\n" +
                        "You are now eligible to marry someone!";
                    eb.WithDescription(text);
                    eb.WithColor(Color.Blue);
                }
                else
                {
                    eb.Title = "**🚫 " + Tools.GetNickname(Context, Context.User.Id) + " you don't have enough credits to buy wedding ring! Cost: $" + Setup.MarriagePrice + " credits**";
                    eb.WithColor(Color.Red);
                }
            }
            else
            {
                eb.Title = "**🚫 " + Tools.GetNickname(Context, Context.User.Id) + " you already own a wedding ring!**";
                eb.WithColor(Color.Red);
            }
            await Context.Channel.SendMessageAsync("", false, eb.Build());

            await Context.Message.DeleteAsync();
        }