示例#1
0
        public static async Task GainExperience(SocketCommandContext context)
        {
            //Create player folder if it doesn't exist
            Directory.CreateDirectory(Setup.PlayerSavesPath + "/" + context.User.Id);
            //Loaded data
            BinaryLevelNormal entry = new BinaryLevelNormal(0, 0, 0);

            //Load
            LevelNormal.Load(Setup.PlayerSavesPath + "/" + context.User.Id + "/" + "Level", ref entry);
            //Modify
            entry.CurrentExp += Setup.ExperienceGainPerMessage;
            entry.TotalExp   += Setup.ExperienceGainPerMessage;
            long nextLevelExp = Tools.GetExpForLevel(entry.CurrentLevel, Setup.ExperienceGrowthModifier);

            if (entry.CurrentExp >= nextLevelExp)
            {
                entry.CurrentExp    = entry.CurrentExp - nextLevelExp;
                entry.CurrentLevel += 1;

                EmbedBuilder eb = new EmbedBuilder();
                eb.Title = "🆙 Level up!";
                string text = context.User.Mention + " has leveled up to **level " + entry.CurrentLevel + "**!";
                eb.WithDescription(text);
                eb.WithColor(255, 255, 255);
                await context.Channel.SendMessageAsync("", false, eb.Build());
            }
            //Save
            LevelNormal.Save(Setup.PlayerSavesPath + "/" + context.User.Id + "/" + "Level", entry);
        }
示例#2
0
        public async Task DisplayProfile(ulong userID)
        {
            //Create player folder if it doesn't exist
            Directory.CreateDirectory(Setup.PlayerSavesPath + "/" + userID);
            //Loaded data
            BinaryLevelNormal levelEntry = new BinaryLevelNormal(0, 0, 0);
            BinaryMoneyNormal moneyEntry = new BinaryMoneyNormal(0, 0, Context.Message.Timestamp.Ticks, Context.Message.Timestamp.Offset.Ticks);
            int repEntry = 0;
            BinaryMarriageNormal marriageEntry = new BinaryMarriageNormal(0, Context.Message.Timestamp.Ticks, Context.Message.Timestamp.Offset.Ticks);

            //Load
            LevelNormal.Load(Setup.PlayerSavesPath + "/" + userID + "/" + "Level", ref levelEntry);
            MoneyNormal.Load(Setup.PlayerSavesPath + "/" + userID + "/" + "Money", ref moneyEntry);
            IntNormal.Load(Setup.PlayerSavesPath + "/" + userID + "/" + "Reputation", ref repEntry);
            MarriageNormal.Load(Setup.PlayerSavesPath + "/" + userID + "/" + "Spouse", ref marriageEntry);

            EmbedBuilder eb = new EmbedBuilder();

            eb.Title = Tools.GetNickname(Context, userID) + "'s Profile";
            eb.WithThumbnailUrl(Context.User.GetAvatarUrl());
            eb.WithColor(194, 14, 213);

            string creditsTitle = "Status";
            string creditsText  =
                "💰Credits: $" + moneyEntry.Money + "\n" +
                "✨Reputation: " + repEntry + "\n";

            eb.AddField(Tools.CreateEmbedField(creditsTitle, creditsText, true));

            string levelFieldTitle = "Level";
            string levelFieldText  =
                "🆙Level: " + levelEntry.CurrentLevel + " (" + levelEntry.CurrentExp + "/" + Tools.GetExpForLevel(levelEntry.CurrentLevel, Setup.ExperienceGrowthModifier) + ")" + "\n" +
                "🛡️Total exp: " + levelEntry.TotalExp;

            eb.AddField(Tools.CreateEmbedField(levelFieldTitle, levelFieldText, true));

            string marriageTitle = "Married to";
            string marriageText  = "None";

            if (marriageEntry.SpouseID != 0)
            {
                string dateOfMarriage = new DateTimeOffset(marriageEntry.DateTimeTicks, new TimeSpan(marriageEntry.DateTimeOffsetTicks)).Date.ToShortDateString();
                marriageText = "💕" + Tools.GetMention(Context, marriageEntry.SpouseID) + " (" + dateOfMarriage + ")";
            }
            eb.AddField(Tools.CreateEmbedField(marriageTitle, marriageText, false));

            await Context.Channel.SendMessageAsync("", false, eb.Build());
        }