Beispiel #1
0
        public async Task cc(CommandContext cmct, string name, string clas, int pow, int dex, int body, int wisdom, int intel, int charisma, int dice, int def, params string[] skills)
        {
            string    skillCC = String.Join(" ", skills);
            Character temp    = new Character()
            {
                ShortName = name, pow = pow, dex = dex, bod = body, wis = wisdom, Int = intel, cha = charisma,
                skills    = skillCC, level = 1, ini = 0, clas = clas, max_HP = dice + (body - 10) / 2, dice = dice, HP = dice + (body - 10) / 2,
                def       = def, history = "no.", name = name, spellPoints = "-"
            };

            using (CharacterContext cc = new CharacterContext())
            {
                try
                {
                    cc.Characters.Add(temp);
                    cc.SaveChanges();
                }
                catch (Exception ex)
                {
                    await cmct.RespondAsync("ERROR!" + ex.Message);

                    Console.WriteLine(ex.Message);
                }
            }
            await cmct.RespondAsync("Character " + name + " was created");

            await cmct.Message.DeleteAsync();
        }
Beispiel #2
0
        public async Task mp(CommandContext cmct, string personName, string statName, bool add = false, params string[] param)
        {
            using (CharacterContext cc = new CharacterContext()) {
                Character    chara = null;
                PropertyInfo temp  = null;
                try
                {
                    chara = cc.Characters.Where(c => c.ShortName == personName).FirstOrDefault();
                    temp  = chara.GetType().GetProperty(statName);
                }
                catch (NullReferenceException ex)
                {
                    var embed = new DiscordEmbedBuilder
                    {
                        Color       = DiscordColor.Black,
                        Title       = "Error!",
                        Description = "Character with name " + personName + " does not exist in database."
                    };
                    await cmct.RespondAsync(embed : embed).ConfigureAwait(false);
                }
                try {
                    int a = Int32.Parse(param[0]);
                    temp.SetValue(chara, a);
                }
                catch
                {
                    string x = string.Join(" ", param);
                    temp.SetValue(chara, x);
                }
                await cmct.RespondAsync("saved.");

                cc.SaveChanges();
            }
        }
Beispiel #3
0
 public async Task us(CommandContext cmct, string Name, int pointLevel, int pointCount = 1)
 {
     using (CharacterContext cc = new CharacterContext())
     {
         try
         {
             pointLevel = pointLevel - 1;
             var      chara    = cc.Characters.Where(c => c.ShortName == Name).FirstOrDefault();
             string[] splitted = chara.spellPoints.Split();
             int      temp     = int.Parse(splitted[pointLevel]);
             if (temp - pointCount >= 0)
             {
                 temp -= pointCount;
                 splitted[pointLevel] = temp.ToString();
                 chara.spellPoints    = string.Join(" ", splitted);
                 cc.SaveChanges();
                 await cmct.RespondAsync("ok.");
             }
             else
             {
                 await cmct.RespondAsync("Not enough spell points.");
             }
         }
         catch (NullReferenceException ex)
         {
             var embed = new DiscordEmbedBuilder
             {
                 Color       = DiscordColor.Black,
                 Title       = "Error!",
                 Description = "Character with name " + Name + " does not exist in database."
             };
             await cmct.RespondAsync(embed : embed).ConfigureAwait(false);
         }
     }
 }
Beispiel #4
0
 public async Task ss(CommandContext cmct, string Name, params string[] points)
 {
     using (CharacterContext cc = new CharacterContext()) {
         try {
             var    chara   = cc.Characters.Where(c => c.ShortName == Name).FirstOrDefault();
             string toInput = "";
             for (int i = 0; i < points.Length; i++)
             {
                 int j = i + 1;
                 toInput += points[i] + " ";
             }
             chara.spellPoints = toInput;
             cc.SaveChanges();
             await cmct.RespondAsync(toInput);
         }
         catch (NullReferenceException ex)
         {
             var embed = new DiscordEmbedBuilder
             {
                 Color       = DiscordColor.Black,
                 Title       = "Error!",
                 Description = "Character with name " + Name + " does not exist in database."
             };
             await cmct.RespondAsync(embed : embed).ConfigureAwait(false);
         }
     }
 }
Beispiel #5
0
 public async Task lu(CommandContext cmct, string Name, int up = 1)
 {
     using (CharacterContext cc = new CharacterContext()) {
         try
         {
             var chara = cc.Characters.Where(c => c.ShortName == Name).FirstOrDefault();
             chara.level = chara.level + up;
             for (int i = 0; i < up; i++)
             {
                 chara.max_HP = chara.max_HP + r.Next(1, chara.dice) + (chara.bod - 10) / 2;
             }
             chara.HP = chara.max_HP;
             cc.SaveChanges();
         }
         catch (NullReferenceException ex)
         {
             var embed = new DiscordEmbedBuilder
             {
                 Color       = DiscordColor.Black,
                 Title       = "Error!",
                 Description = "Character with name " + Name + " does not exist in database."
             };
             await cmct.RespondAsync(embed : embed).ConfigureAwait(false);
         }
     }
     await cmct.RespondAsync("Level up " + Name + ".");
 }
Beispiel #6
0
 public async Task hr(CommandContext cmct, string Name)
 {
     using (CharacterContext cc = new CharacterContext()) {
         try {
             var person = cc.Characters.Where(c => c.ShortName == Name).FirstOrDefault();
             person.HP = person.max_HP;
             cc.SaveChanges();
             await cmct.RespondAsync("reseted HP for " + Name);
         }
         catch (NullReferenceException ex)
         {
             var embed = new DiscordEmbedBuilder
             {
                 Color       = DiscordColor.Black,
                 Title       = "Error!",
                 Description = "Character with name " + Name + " does not exist in database."
             };
             await cmct.RespondAsync(embed : embed).ConfigureAwait(false);
         }
     }
 }