Пример #1
0
        public Hero(int id, bool custom = false)
        {
            this.id  = id;
            level    = 1;
            exp_need = 100;
            gold     = Utils.Random(30, 60);
            if (!custom)
            {
                name = NameGenerator.GetName();
                race = Race.GetRandom();
                Stats.Attribute attribute = ApplyRaceBonus(null).Value;
                clas = Class.Get(attribute);
                switch (clas.GetAttribute())
                {
                case Stats.Attribute.Strength:
                    ++str;
                    break;

                case Stats.Attribute.Dexterity:
                    ++dex;
                    break;

                case Stats.Attribute.Endurance:
                    ++end;
                    break;
                }
                BuyItems(false);
            }
            hp = hpmax = CalculateMaxHp();
        }
Пример #2
0
        Hero CreateCharacter()
        {
            // name
            Console.Write("Hero name: ");
            string name = Console.ReadLine();
            Hero   h    = new Hero(next_id++, true)
            {
                name       = name,
                controlled = true
            };

            // race
            Console.WriteLine("Pick race:");
            int           index   = 1;
            StringBuilder choices = new StringBuilder("r");

            foreach (Race race in Race.races)
            {
                Console.WriteLine($"{index}. {race.name} ({race.desc})");
                choices.Append($"{index}");
                ++index;
            }
            Console.WriteLine("r. random\n>");
            char rc = Utils.ReadKey(choices.ToString());

            if (rc == 'r')
            {
                h.race = Race.GetRandom();
            }
            else
            {
                h.race = Race.races[rc - '1'];
            }
            Stats.Attribute prefered_attribute = h.ApplyRaceBonus(null).Value;

            // class
            Console.WriteLine("Pick class:");
            index = 1;
            choices.Clear();
            foreach (Class clas in Class.classes)
            {
                Console.WriteLine($"{index}. {clas.name} ({clas.desc})");
                choices.Append($"{index}");
                ++index;
            }
            Console.WriteLine("r. random\n>");
            rc = Utils.ReadKey(choices.ToString());
            if (rc == 'r')
            {
                h.clas = Class.Get(prefered_attribute);
            }
            else
            {
                h.clas = Class.classes[rc - '1'];
            }

            h.PickAttribute();
            heroes.Add(h);
            return(h);
        }
Пример #3
0
        public Stats.Attribute?ApplyRaceBonus(IUnitController controller)
        {
            if (level == 1 || level % 4 == 0)
            {
                Stats.Attribute attribute = race.GetAttribute();
                bool            notify    = controller?.CombatDetails ?? false;
                switch (attribute)
                {
                case Stats.Attribute.Strength:
                    ++str;
                    if (notify)
                    {
                        controller.Notify($"{Name} increased strength.");
                    }
                    break;

                case Stats.Attribute.Dexterity:
                    ++dex;
                    if (notify)
                    {
                        controller.Notify($"{Name} increased dexterity.");
                    }
                    break;

                case Stats.Attribute.Endurance:
                    ++end;
                    if (notify)
                    {
                        controller.Notify($"{Name} increased endurance.");
                    }
                    break;
                }
                return(attribute);
            }
            return(null);
        }