Ejemplo n.º 1
0
        public async Task AddAbilityMod(string ability, int mod, string source, [Remainder] string name = null)
        {
            DnDPlayerCharacter player = await GetPlayerOrCurrent(name);

            if (player != null)
            {
                DnDAbilityScores abilityScore = GetAbility(ability);
                if ((int)abilityScore == -1)
                {
                    await ReplyAsync("Invalid ability score! Valid: STR, DEX, CON, INT, WIS, CHA");

                    return;
                }
                DnDBasicCharacterInfo basicInfo = player.BasicInfo;
                basicInfo.AbilityMods.Add(new DnDAbilityModDescriptor()
                {
                    SourceDescription = source,
                    AbilityMod        = new DnDAbilityModifier()
                    {
                        Ability  = abilityScore,
                        Modifier = mod
                    }
                });
                player.BasicInfo = basicInfo;
                await ReplyAsync("Successfully added ability modifier.");
            }
        }
Ejemplo n.º 2
0
        public async Task GivePlayer(IUser user, [Remainder] string name)
        {
            DnDPlayerCharacter player = CurrentGame.GetPlayer(Games.Storage, name);

            if (player == null)
            {
                await ReplyAsync("No player exists with that name!");
            }
            else if (player.ControlledBy != 0UL && CurrentGame.GameData.DungeonMaster != Context.User.Id && player.ControlledBy != Context.User.Id)
            {
                await ReplyAsync("That player already has a controller!" + (player.ControlledBy == user.Id ? " (It's them.)" : ""));
            }
            else
            {
                DnDPlayerCharacter old     = CurrentGame.GetPlayer(user.Id);
                string             joining = "Joining";
                if (old != null)
                {
                    joining = "Replacing " + old.Name + " in";
                    CurrentGame.RemovePlayer(old);
                }
                player.ControlledBy = user.Id;
                await ReplyAsync(user.Mention + " now controls " + player.Name + ". " + joining + " current campaign " + CurrentGame.Data.Title + ".");

                CurrentGame.AddPlayer(player);
                CurrentGame.Save(Games.Storage);
            }
        }
Ejemplo n.º 3
0
        public async Task DeleteSkillProficiency(string skillName, [Remainder] string name = null)
        {
            DnDPlayerCharacter player = await GetPlayerOrCurrent(name);

            if (player != null)
            {
                DnDCharacterSkills skill = GetSkill(skillName);
                if ((int)skill == -1)
                {
                    await ReplyAsync("Invalid skill! Valid: athl, acro, slei, stea, arca, hist, inve, natu, reli, anim, insi, medi, perc, surv, dece, inti, perf, pers");

                    return;
                }
                DnDBasicCharacterInfo basicInfo = player.BasicInfo;
                if (!basicInfo.SkillProficiencies.Contains(skill))
                {
                    await ReplyAsync(player.Name + " does not have a proficiency in " + skill.ToString().ToLowerInvariant() + "!");

                    return;
                }
                basicInfo.SkillProficiencies.Remove(skill);
                player.BasicInfo = basicInfo;
                await ReplyAsync("Successfully deleted skill proficiency.");
            }
        }
Ejemplo n.º 4
0
        public async Task TakePlayer([Remainder] string name)
        {
            DnDPlayerCharacter player = CurrentGame.GetPlayer(Games.Storage, name);

            if (player == null)
            {
                await ReplyAsync("No player exists with that name!");
            }
            else if (player.ControlledBy != 0UL)
            {
                await ReplyAsync("That player already has a controller!" + (player.ControlledBy == Context.User.Id ? " (It's you.)" : ""));
            }
            else
            {
                DnDPlayerCharacter old     = CurrentGame.GetPlayer(Context.User.Id);
                string             joining = "Joining";
                if (old != null)
                {
                    joining = "Replacing " + old.Name + " in";
                    CurrentGame.RemovePlayer(old);
                }
                player.ControlledBy = Context.User.Id;
                await ReplyAsync("You now control " + player.Name + ". " + joining + " current campaign " + CurrentGame.Data.Title + ".");

                CurrentGame.AddPlayer(player);
                CurrentGame.Save(Games.Storage);
            }
        }
Ejemplo n.º 5
0
        public async Task AddSkillMod(string skillName, int mod, string source, [Remainder] string name = null)
        {
            DnDPlayerCharacter player = await GetPlayerOrCurrent(name);

            if (player != null)
            {
                DnDCharacterSkills skill = GetSkill(skillName);
                if ((int)skill == -1)
                {
                    await ReplyAsync("Invalid skill! Valid: athl, acro, slei, stea, arca, hist, inve, natu, reli, anim, insi, medi, perc, surv, dece, inti, perf, pers");

                    return;
                }
                DnDBasicCharacterInfo basicInfo = player.BasicInfo;
                basicInfo.SkillMods.Add(new DnDSkillModDescriptor()
                {
                    SourceDescription = source,
                    SkillMod          = new DnDSkillModifier()
                    {
                        Skill    = skill,
                        Modifier = mod
                    }
                });
                player.BasicInfo = basicInfo;
                await ReplyAsync("Successfully added skill modifier.");
            }
        }
Ejemplo n.º 6
0
        public async Task DeleteSkillMod(string skillName, int num, [Remainder] string name = null)
        {
            DnDPlayerCharacter player = await GetPlayerOrCurrent(name);

            if (player != null)
            {
                DnDCharacterSkills skill = GetSkill(skillName);
                if ((int)skill == -1)
                {
                    await ReplyAsync("Invalid skill! Valid: athl, acro, slei, stea, arca, hist, inve, natu, reli, anim, insi, medi, perc, surv, dece, inti, perf, pers");

                    return;
                }
                DnDBasicCharacterInfo basicInfo = player.BasicInfo;
                DnDSkillModDescriptor match     = basicInfo.SkillMods.Where((smd) => smd.SkillMod.Skill == skill).ElementAtOrDefault(num - 1);
                if (match.Equals(default(DnDSkillModDescriptor)))
                {
                    await ReplyAsync("No valid modifier found. Must be a number from .listsmods " + skillName);

                    return;
                }
                basicInfo.SkillMods.Remove(match);
                player.BasicInfo = basicInfo;
                await ReplyAsync("Successfully deleted skill modifier.");
            }
        }
Ejemplo n.º 7
0
        public async Task DeleteAbilityMod(string ability, int num, [Remainder] string name = null)
        {
            DnDPlayerCharacter player = await GetPlayerOrCurrent(name);

            if (player != null)
            {
                DnDAbilityScores abilityScore = GetAbility(ability);
                if ((int)abilityScore == -1)
                {
                    await ReplyAsync("Invalid ability score! Valid: STR, DEX, CON, INT, WIS, CHA");

                    return;
                }
                DnDBasicCharacterInfo   basicInfo = player.BasicInfo;
                DnDAbilityModDescriptor match     = basicInfo.AbilityMods.Where((amd) => amd.AbilityMod.Ability == abilityScore).ElementAtOrDefault(num - 1);
                if (match.Equals(default(DnDAbilityModDescriptor)))
                {
                    await ReplyAsync("No valid modifier found. Must be a number from .listamods " + ability);

                    return;
                }
                basicInfo.AbilityMods.Remove(match);
                player.BasicInfo = basicInfo;
                await ReplyAsync("Successfully deleted ability modifier.");
            }
        }
Ejemplo n.º 8
0
        public override string SpecialRoll(ulong userId, string input)
        {
            input = Regex.Replace(input, "adv" + IgnoreMath, "2d20d1");
            input = Regex.Replace(input, "dis" + IgnoreMath, "2d20k1");
            DnDPlayerCharacter player = GetPlayer(userId);

            if (player != null)
            {
                foreach (DnDAbilityScores ability in Utilities.GetEnumValues <DnDAbilityScores>())
                {
                    // first 3 letters... str, dex, con, int, wis, cha
                    string name = ability.ToString().Substring(0, 3).ToLowerInvariant() + IgnoreMath;
                    // only an ability score -> roll d20 + mod
                    input = Regex.Replace(input, "^" + name + "$", "1d20" + GetModString(player, ability));
                    // somewhere in a string -> assume it can be replaced with the mod
                    input = Regex.Replace(input, name, "(" + player.BasicInfo.GetAbilityMod(ability) + ")");
                }
                foreach (DnDCharacterSkills skill in Utilities.GetEnumValues <DnDCharacterSkills>())
                {
                    // first 4 letters... athl, acro, slei, stea, arca, hist, inve, natu, reli, anim, insi, medi, perc, surv, dece, inti, perf, pers
                    string name = skill.ToString().Substring(0, 4).ToLowerInvariant() + IgnoreMath;
                    // only a skill -> roll d20 + mod
                    input = Regex.Replace(input, "^" + name + "$", "1d20" + GetModString(player, skill));
                    // somewhere in a string -> assume it can be replaced with the mod
                    input = Regex.Replace(input, name, "(" + player.GetSkillMod(skill) + ")");
                }
            }
            return(input);
        }
Ejemplo n.º 9
0
        public async Task PlayerInfo([Remainder] string name = null)
        {
            DnDPlayerCharacter player = await GetPlayerOrCurrent(name, false);

            if (player != null)
            {
                await ReplyAsync(embed : player.CreateInfoEmbed());
            }
        }
Ejemplo n.º 10
0
        public async Task ListSkillProficiencies([Remainder] string name = null)
        {
            DnDPlayerCharacter player = await GetPlayerOrCurrent(name, false);

            if (player != null)
            {
                string skills = Utilities.Join(player.BasicInfo.SkillProficiencies.Select((skill) => skill.ToString().ToLowerInvariant()).ToArray(), ", ");
                if (string.IsNullOrEmpty(skills))
                {
                    skills = "None";
                }
                await ReplyAsync(player.Name + " is proficient in the following skills: " + skills);
            }
        }
Ejemplo n.º 11
0
        public async Task SetStats(int strength, int dexterity, int constitution, int intelligence, int wisdom, int charisma, [Remainder] string name = null)
        {
            DnDPlayerCharacter player = await GetPlayerOrCurrent(name);

            if (player != null)
            {
                DnDBasicCharacterInfo basicInfo = player.BasicInfo;
                basicInfo.Strength     = strength;
                basicInfo.Dexterity    = dexterity;
                basicInfo.Constitution = constitution;
                basicInfo.Intelligence = intelligence;
                basicInfo.Wisdom       = wisdom;
                basicInfo.Charisma     = charisma;
                player.BasicInfo       = basicInfo;
                await ReplyAsync("Successfully modified stats.");
            }
        }
Ejemplo n.º 12
0
        public async Task ListAbilityMod(string ability = null, [Remainder] string name = null)
        {
            DnDPlayerCharacter player = await GetPlayerOrCurrent(name, false);

            if (player != null)
            {
                EmbedBuilder     builder      = new EmbedBuilder();
                DnDAbilityScores abilityScore = GetAbility(ability);
                if ((int)abilityScore == -1)
                {
                    builder.WithTitle("List of all active ability modifiers");
                    int i = 0;
                    DnDAbilityScores lastAbility = DnDAbilityScores.Strength;
                    foreach (DnDAbilityModDescriptor descriptor in player.BasicInfo.AbilityMods.OrderBy((amd) => amd.AbilityMod.Ability))
                    {
                        if (descriptor.AbilityMod.Ability != lastAbility)
                        {
                            i           = 0;
                            lastAbility = descriptor.AbilityMod.Ability;
                        }
                        builder.Description += lastAbility.ToString().ToUpper().Substring(0, 3) + " " + (i + 1) + ": "
                                               + descriptor.SourceDescription + " (" + descriptor.AbilityMod.Modifier.ShowSign() + ")\n";
                        i++;
                    }
                }
                else
                {
                    builder.WithTitle("List of active " + abilityScore.ToString().ToLowerInvariant() + " modifiers");
                    int i = 0;
                    foreach (DnDAbilityModDescriptor descriptor in player.BasicInfo.AbilityMods.Where((amd) => amd.AbilityMod.Ability == abilityScore))
                    {
                        builder.Description += (i + 1) + ": " + descriptor.SourceDescription + " (" + descriptor.AbilityMod.Modifier.ShowSign() + ")\n";
                        i++;
                    }
                }
                if (string.IsNullOrEmpty(builder.Description))
                {
                    builder.Description = "None";
                }
                await ReplyAsync(embed : builder.Build());
            }
        }
Ejemplo n.º 13
0
        public async Task ListSkillMod(string skillName = null, [Remainder] string name = null)
        {
            DnDPlayerCharacter player = await GetPlayerOrCurrent(name, false);

            if (player != null)
            {
                EmbedBuilder       builder = new EmbedBuilder();
                DnDCharacterSkills skill   = GetSkill(skillName);
                if ((int)skill == -1)
                {
                    builder.WithTitle("List of all active skill modifiers");
                    int i = 0;
                    DnDCharacterSkills lastSkill = DnDCharacterSkills.Athletics;
                    foreach (DnDSkillModDescriptor descriptor in player.BasicInfo.SkillMods.OrderBy((smd) => smd.SkillMod.Skill))
                    {
                        if (descriptor.SkillMod.Skill != lastSkill)
                        {
                            i         = 0;
                            lastSkill = descriptor.SkillMod.Skill;
                        }
                        builder.Description += lastSkill.ToString().ToUpper().Substring(0, 4) + " " + (i + 1) + ": "
                                               + descriptor.SourceDescription + " (" + descriptor.SkillMod.Modifier.ShowSign() + ")\n";
                        i++;
                    }
                }
                else
                {
                    builder.WithTitle("List of active " + skill.ToString().ToLowerInvariant() + " modifiers");
                    int i = 0;
                    foreach (DnDSkillModDescriptor descriptor in player.BasicInfo.SkillMods.Where((smd) => smd.SkillMod.Skill == skill))
                    {
                        builder.Description += (i + 1) + ": " + descriptor.SourceDescription + " (" + descriptor.SkillMod.Modifier.ShowSign() + ")\n";
                        i++;
                    }
                }
                if (string.IsNullOrEmpty(builder.Description))
                {
                    builder.Description = "None";
                }
                await ReplyAsync(embed : builder.Build());
            }
        }
Ejemplo n.º 14
0
        public static DnDPlayerCharacter Migrate(DnDPlayerCharacter player)
        {
            if (player == null || player.Migrated)
            {
                return(player);
            }
            DnDBasicCharacterInfo basicInfo = player.BasicInfo;

            if (basicInfo.AbilityMods == null)
            {
                basicInfo.AbilityMods = new List <DnDAbilityModDescriptor>();
            }
            if (basicInfo.SkillMods == null)
            {
                basicInfo.SkillMods = new List <DnDSkillModDescriptor>();
            }
            player.BasicInfo = basicInfo;
            player.Migrated  = true;
            return(player);
        }
Ejemplo n.º 15
0
        public async Task NewPlayer(string race, [Remainder] string name)
        {
            if (CurrentGame.GetPlayer(Games.Storage, name) != null)
            {
                await ReplyAsync("A player already exists with that name!");

                return;
            }
            DnDPlayerCharacter currentPC = CurrentGame.GetPlayer(Context.User.Id);
            DnDPlayerCharacter newPC     = CurrentGame.CreatePlayer(race, name);

            if (currentPC == null)
            {
                newPC.ControlledBy = Context.User.Id;
                await ReplyAsync("Player created and is now controlled by you, as you have no active character. Joining current campaign " + CurrentGame.Data.Title + ".");

                CurrentGame.AddPlayer(newPC);
                CurrentGame.Save(Games.Storage);
            }
            else if (!currentPC.Alive)
            {
                currentPC.ControlledBy = 0UL;
                newPC.ControlledBy     = Context.User.Id;
                await ReplyAsync("Player created and is now controlled by you, as your old one is dead. Nice going! Replacing " + currentPC.Name + " in current campaign " + CurrentGame.Data.Title + ".");

                CurrentGame.RemovePlayer(currentPC);
                CurrentGame.AddPlayer(newPC);
                CurrentGame.Save(Games.Storage);
            }
            else
            {
                CurrentGame.AddPlayer(newPC);
                CurrentGame.Save(Games.Storage);
                CurrentGame.RemovePlayer(newPC);
                await ReplyAsync("Player created. It has no active controller because you have an active character. To take control, use /takepc " + name + "\n"
                                 + "You can also use /takepc " + name.ToLowerInvariant().StripNonAlphaNumeric());
            }
        }
Ejemplo n.º 16
0
        public async Task ImportPlayer([Remainder] string url)
        {
            Match match = Regex.Match(url, @".*myth-weavers.com/sheet.html#id=(\d+)");

            if (!match.Success)
            {
                await ReplyAsync("Provided URL is not a MythWeavers sheet.");

                return;
            }
            DnDMythWeavers mw;
            WebRequest     wr = WebRequest.Create("https://www.myth-weavers.com/api/v1/sheets/sheets/" + match.Groups[1].Value);

            using (WebResponse response = wr.GetResponse())
                using (Stream stream = response.GetResponseStream())
                {
                    mw = Games.Storage.Load <DnDMythWeavers>(stream);
                }
            if (mw.Error || mw.Sheetdata.Private == 1)
            {
                await ReplyAsync("Error retrieving data. Is the sheet private?");

                return;
            }
            string name         = mw.Sheetdata.Data.Name;
            string internalName = name.ToLowerInvariant().StripNonAlphaNumeric();

            Games.Storage.Write("data/mythweavers/" + internalName, mw);
            DnDPlayerCharacter newPC = DnDConvert.ConvertPlayer(mw.Sheetdata.Data);

            CurrentGame.AddPlayer(newPC);
            CurrentGame.Save(Games.Storage);
            CurrentGame.RemovePlayer(newPC);
            CurrentGame.Save(Games.Storage);
            await ReplyAsync("Player imported. It has no active controller because it might contain flaws and should be manually edited before taking control. " +
                             "To take control, use /takepc " + name + "\nYou can also use /takepc " + name.ToLowerInvariant().StripNonAlphaNumeric());
        }
Ejemplo n.º 17
0
        private static string GetModString(DnDPlayerCharacter player, DnDCharacterSkills skill)
        {
            int mod = player.GetSkillMod(skill);

            return((mod < 0 ? " - " : " + ") + Math.Abs(mod));
        }
Ejemplo n.º 18
0
 public void RemovePlayer(DnDPlayerCharacter character)
 {
     character.ControlledBy      = 0UL;
     character.LastKnownCampaign = null;
     GameData.Players.Remove(character);
 }
Ejemplo n.º 19
0
        private static string GetModString(DnDPlayerCharacter player, DnDAbilityScores ability)
        {
            int mod = player.BasicInfo.GetAbilityMod(ability);

            return((mod < 0 ? " - " : " + ") + Math.Abs(mod));
        }
Ejemplo n.º 20
0
 public void AddPlayer(DnDPlayerCharacter character)
 {
     GameData.Players.Add(character);
     character.LastKnownCampaign = InternalTitle;
 }