Exemple #1
0
        public async Task AddXpAsync(int amount, DSharpPlus.CommandsNext.CommandContext c = null)
        {
            bool hasLeveled = false;

            XpCurrent += amount;

            if (XpCurrent >= XpNext)
            {
                hasLeveled = true;

                while (XpCurrent >= XpNext)
                {
                    XpCurrent = XpCurrent - XpNext;
                    Level++;
                    XpNext = Rpg.GetNextXp(Level);

                    SkillPoints     += Realm.GetSetting <int>("skill_points_per_levelup");
                    AttributePoints += Realm.GetSetting <int>("attribute_points_per_levelup");
                }
            }

            if (hasLeveled == false || c == null)
            {
                return;
            }

            HpMax     = Rpg.GetBaseHpForLevel(Level);
            HpCurrent = HpMax;

            var g = await Bot.RpgBot.Client.GetGuildAsync(GuildId);

            var m = await g.GetMemberAsync(ulong.Parse(Id));

            await c.Channel.SendMessageAsync($"{m.Mention} is now level {Level}!");
        }
Exemple #2
0
        public Enemy(EncounterTemplate tmp, int playerLevel)
        {
            Name = tmp.TemplateName;

            if (tmp.AdjustToPlayerLevel)
            {
                Level = Rng.Instance.Next(0, 100) > 50
                                        ? playerLevel + Rng.Instance.Next(tmp.LevelRangeMin, tmp.LevelRangeMax)
                                        : playerLevel - Rng.Instance.Next(tmp.LevelRangeMin, tmp.LevelRangeMax);
            }
            else
            {
                Level = Rng.Instance.Next(tmp.LevelRangeMin, tmp.LevelRangeMax);
            }

            if (Level < 1)
            {
                Level = 1;
            }

            if (tmp.AutoHp)
            {
                HpMax = Rng.Instance.Next(0, 100) > 50
                                        ? Rpg.GetBaseHpForLevel(Level) + Rng.Instance.Next(0, tmp.HpVariance)
                                        : Rpg.GetBaseHpForLevel(Level) - Rng.Instance.Next(0, tmp.HpVariance);
            }
            else
            {
                HpMax = Rng.Instance.Next(0, 100) > 50
                                        ? tmp.BaseHp + Rng.Instance.Next(0, tmp.HpVariance)
                                        : tmp.BaseHp - Rng.Instance.Next(0, tmp.HpVariance);
            }

            Attributes = tmp.Attributes ?? new AttributeBlock(1);
            Equipment  = tmp.Equipment ?? new EquipSet();

            HpCurrent = HpMax;

            TemplateId = tmp.Id;
        }