Beispiel #1
0
        public async Task AwardExperienceAsync(SocketMessage messageParam)
        {
            // Don't process the message if it was a system message, or if it was a DM
            var message = messageParam as SocketUserMessage;

            if (message == null)
            {
                return;
            }

            // Don't process the message if it was supposed to be a command
            int argPos = 0;

            if (message.HasCharPrefix(cmd_prefix, ref argPos))
            {
                return;
            }

            var user = message.Author;

            if (user.IsBot)
            {
                return;
            }
            var channel = message.Channel as SocketGuildChannel;

            if (channel == null)
            {
                return;
            }

            var context = new SocketCommandContext(_client, message);

            if (CharacterUtilityService.CharacterExists(user))
            {
                byte level = ExperienceService.GetCharacterLevel(user);

                // passing the 5 minute check
                if (ratelimit.BastardizedCheckPermissionsAsync(context, _services) && level < 50)
                {
                    ExperienceService.AwardExp(user);
                }

                byte newLevel = ExperienceService.GetCharacterLevel(user);
                if (newLevel > level)
                {
                    await context.Channel.SendMessageAsync(user.Mention + " is now level " + newLevel + "!");

                    await ExperienceService.CharacterLevelUp(user);
                }
            }
            else
            {
                return;
            }
        }
Beispiel #2
0
 public static byte GetCharacterLevel(SocketUser user)
 {
     if (CharacterUtilityService.CharacterExists(user)) // fancy way
     {
         return(GetCharacterLevel(CharacterLoadService.LoadCharacter(user)));
     }
     else
     {
         return(0);
     }
 }
Beispiel #3
0
        public static string AddPerk(SocketUser user, string perkToAdd)
        {
            var character = CharacterLoadService.LoadCharacter(user);
            int oldCount  = character.CharPerks.Count;

            if (character == null)
            {
                return("Couldn't find character!");
            }
            if (character.RemainingPerkPoints <= 0)
            {
                return("You don't have any skill points!");
            }

            foreach (var perk in CharacterUtilityService.GetAllPerks())
            {
                if (perk.Name.ToLower().Equals(perkToAdd.ToLower())) // parameter case insensitivity
                {
                    if (character.CharPerks.Contains(perk))          // add another rank to perk instead of adding it to list
                    {
                        var charPerk = character.CharPerks.Find(x => x.Name.Equals(perk.Name));
                        if (charPerk.CurrentPerkRanks < perk.PerkRanks)
                        {
                            charPerk.CurrentPerkRanks++;
                            CharacterUtilityService.OverwriteCharacter(character);
                            return("Added a rank to the given perk!");
                        }
                        else
                        {
                            return("You already have that stat at its max rank!");
                        }
                    }
                    else
                    {
                        // TODO: actually check Skill and S.P.E.C.I.A.L. requirements
                        if (character.CharSpecial.IsGreaterThanOrEqualTo(perk.SpecialRequirement) &&
                            character.CharSkills.IsGreaterThanOrEqualTo(perk.SkillRequirement))
                        {
                            character.CharPerks.Add(perk);
                            CharacterUtilityService.OverwriteCharacter(character);
                            return("Added perk!");
                        }
                    }
                }
            }
            if (oldCount == character.CharPerks.Count) // make sure we added a perk
            {
                return("Failed to add the given perk.  (Check spelling!)");
            }
            else
            {
                return("idk wtf happened bro tell someone how you got here");
            }
        }
Beispiel #4
0
 public static int GetCharacterExpPoints(SocketUser user)
 {
     if (CharacterUtilityService.CharacterExists(user))
     {
         return(GetCharacterExpPoints(CharacterLoadService.LoadCharacter(user)));
     }
     else
     {
         return(-1);
     }
 }
Beispiel #5
0
        public static async Task CharacterLevelUp(SocketUser user)
        {
            var dmChannel = await user.GetOrCreateDMChannelAsync();

            var character = CharacterLoadService.LoadCharacter(user);

            AddSkillPoints(character); // that doesn't seem right...I should probably move that to Character

            var cPre = CommandHandlerService.cmd_prefix;

            await dmChannel.SendMessageAsync("You're now level " + GetCharacterLevel(character) + ", and have " + character.RemainingSkillPoints + " skill points remaining to add. " +
                                             "You have " + character.RemainingPerkPoints + " remaining perk points.  " +
                                             "Use " + cPre + "addskill to add skill points, and " + cPre + "addperk to add perks.  Use " + cPre + "viewskills to look at skill names.");

            await Task.Delay(1000);

            CharacterUtilityService.OverwriteCharacter(character);
        }
Beispiel #6
0
        public static void AwardExp(SocketUser user)
        {
            var character    = CharacterLoadService.LoadCharacter(user);
            int expOnMessage = int.Parse(Program._config["exp_on_message"]);

            int actualExp = (int)Math.Round(expOnMessage * (character.CharSpecial.Intelligence / 10.0 + 1));

            if (character != null)
            {
                character.ExpPoints += actualExp;
            }
            else
            {
                return;
            }

            CharacterUtilityService.OverwriteCharacter(character);
        }
Beispiel #7
0
        public string GetRollResult(Character.SpecialEnum rollSpecial, SocketUser user)
        {
            Random rand = new Random();
            //var skills = CharacterUtilityService.GetCharacterSkills(user);
            var charSpecial = CharacterUtilityService.GetCharacterSpecial(user);
            var charTraits  = CharacterUtilityService.GetCharacterTraits(user);
            //if (charSpecial == null) return null;

            // RNG influenced by character luck except when its 5
            int rngResult     = (int)Math.Round((rand.Next(1, 11) * (charSpecial.Luck / 10.0 - .5 + 1.0))),
                specialAmount = (byte)typeof(CharacterStats.SPECIAL).GetProperty(rollSpecial.ToString()).GetValue(charSpecial);

            int difference = specialAmount - rngResult;
            // compares your roll with your skills, and how much better you did than the bare minimum
            double successPercent = (double)difference / specialAmount;

            successPercent = Math.Round(successPercent, 2) * 100;
            // says much you failed in percent (sometimes gets to 300% and higher o.o )
            double failurePercent = (double)rngResult / specialAmount;

            failurePercent = Math.Round(failurePercent, 2) * 100;

            StringBuilder result = new StringBuilder();

            if (rngResult <= specialAmount)
            {
                if (successPercent >= 90)
                {
                    // criticaler success (holy shit)
                    result.Append("**CRITICAL " + rollSpecial.ToString().ToUpper() + " SUCCESS!!!**");
                }
                else if (successPercent >= 80)
                {
                    // critical success
                    result.Append("**CRITICAL " + rollSpecial.ToString().ToUpper() + " SUCCESS!**");
                }
                else if (successPercent >= 60)
                {
                    // purty good (great) success
                    result.Append("__GREAT " + rollSpecial.ToString().ToUpper() + " SUCCESS__");
                }
                else if (successPercent >= 40)
                {
                    // good success
                    result.Append("*Very good " + rollSpecial.ToString() + " success*");
                }
                else if (successPercent >= 25)
                {
                    // decent
                    result.Append("*Good " + rollSpecial.ToString() + " success*");
                }
                else if (successPercent >= 10)
                {
                    // decent
                    result.Append("*Above average " + rollSpecial.ToString() + " success*");
                }
                else
                {
                    // close call!
                    result.Append("__***CLOSE CALL! " + rollSpecial.ToString() + " success***__");
                }
                result.Append(" for " + user.Username + ": did **" + successPercent + "%** better than needed!");
            }
            else
            {
                if (failurePercent >= 90)
                {
                    // criticaler failure (holy shit
                    result.Append("**CRITICAL " + rollSpecial.ToString().ToUpper() + " FAILURE!!!**");
                }
                else if (failurePercent >= 80)
                {
                    // critical failure
                    result.Append("**CRITICAL " + rollSpecial.ToString().ToUpper() + " FAILURE!**");
                }
                else if (failurePercent >= 60)
                {
                    // purty good (great) failure
                    result.Append("__GREAT " + rollSpecial.ToString().ToUpper() + " FAILURE__");
                }
                else if (failurePercent >= 40)
                {
                    // good failure
                    result.Append("*Very good " + rollSpecial.ToString() + " failure*");
                }
                else if (failurePercent >= 25)
                {
                    // decent
                    result.Append("*Good " + rollSpecial.ToString() + " failure*");
                }
                else if (failurePercent >= 10)
                {
                    // decent
                    result.Append("*Above average " + rollSpecial.ToString() + " failure*");
                }
                else
                {
                    // close call!
                    result.Append("__***Heartbreaking " + rollSpecial.ToString() + " failure***__");
                }
                result.Append(" for " + user.Username + ": did **" + failurePercent + "%** worse than needed!");
                if (rollSpecial.Equals(Character.SpecialEnum.Agility) && charTraits.Contains(new CharacterStats.Trait.SmallFrame()))
                {
                    result.Append("\nCharacter has a **Small Frame!**");
                }
            }

            return(result.ToString());
        }
Beispiel #8
0
        public string GetRollResult(Character.SkillEnum skill, SocketUser user)
        {
            Random rand    = new Random();
            var    skills  = CharacterUtilityService.GetCharacterSkills(user);
            var    special = CharacterUtilityService.GetCharacterSpecial(user);

            if (skills == null)
            {
                return(null);
            }

            // RNG influenced by character luck except when its 5
            int rngResult   = (int)Math.Round((rand.Next(1, 101) * (special.Luck / 10.0 - .5 + 1.0))),
                skillAmount = skills.skillDict[skill.ToString()];

            // compares your roll with your skills, and how much better you did than the bare minimum
            double successPercent = (double)(skillAmount - rngResult) / skillAmount;

            successPercent = Math.Round(successPercent, 2) * 100;
            // says much you failed in percent (sometimes gets to 300% and higher o-o )
            double failurePercent = (double)rngResult / skillAmount - 1;

            failurePercent = Math.Round(failurePercent, 2) * 100;

            StringBuilder result = new StringBuilder();

            if (rngResult <= skillAmount)
            {
                if (successPercent >= 90)
                {
                    // criticaler success (holy shit)
                    result.Append("**CRITICAL " + skill.ToString().ToUpper() + " SUCCESS!!!**");
                }
                else if (successPercent >= 80)
                {
                    // critical success
                    result.Append("**CRITICAL " + skill.ToString().ToUpper() + " SUCCESS!**");
                }
                else if (successPercent >= 60)
                {
                    // purty good (great) success
                    result.Append("__GREAT " + skill.ToString().ToUpper() + " SUCCESS__");
                }
                else if (successPercent >= 40)
                {
                    // good success
                    result.Append("*Very good " + skill.ToString() + " success*");
                }
                else if (successPercent >= 25)
                {
                    // decent
                    result.Append("*Good " + skill.ToString() + " success*");
                }
                else if (successPercent >= 10)
                {
                    // decent
                    result.Append("*Above average " + skill.ToString() + " success*");
                }
                else
                {
                    // close call!
                    result.Append("__***CLOSE CALL! " + skill.ToString() + " success***__");
                }
                result.Append(" for " + user.Username + ": did **" + successPercent + "%** better than needed!");
            }
            else
            {
                if (failurePercent >= 90)
                {
                    // criticaler failure (holy shit
                    result.Append("**CRITICAL " + skill.ToString().ToUpper() + " FAILURE!!!**");
                }
                else if (failurePercent >= 80)
                {
                    // critical failure
                    result.Append("**CRITICAL " + skill.ToString().ToUpper() + " FAILURE!**");
                }
                else if (failurePercent >= 60)
                {
                    // purty good (great) failure
                    result.Append("__TERRIBLE " + skill.ToString().ToUpper() + " FAILURE__");
                }
                else if (failurePercent >= 40)
                {
                    // good failure
                    result.Append("*Pretty bad " + skill.ToString() + " failure*");
                }
                else if (failurePercent >= 25)
                {
                    // decent
                    result.Append("*Bad " + skill.ToString() + " failure*");
                }
                else if (failurePercent >= 10)
                {
                    // decent
                    result.Append("*Above average " + skill.ToString() + " failure*");
                }
                else
                {
                    // close call!
                    result.Append("__***Heartbreaking " + skill.ToString() + " failure***__");
                }
                result.Append(" for " + user.Username + ": did **" + failurePercent + "%** worse than needed!");
            }

            return(result.ToString());
        }