示例#1
0
        public List <int> PickEnemies(Team group, int max = 1)
        {
            IWeightedRandomizer <int> randomizer = new DynamicWeightedRandomizer <int>();

            for (int i = 0; i < Characters.Count; i++)
            {
                if (Characters[i].Group != group && Characters[i].Alive)
                {
                    randomizer.Add(i, Characters[i].HighValueTarget ? 8 : 1);
                }
            }

            List <int> result = new List <int>();

            int total = randomizer.Count;

            if (total > 0)
            {
                if (max > total)
                {
                    max = total;
                }
                if (max > 1)
                {
                    max = ClampMax(max);
                }

                for (int j = 0; j < max; j++)
                {
                    result.Add(randomizer.NextWithRemoval());
                }
            }

            return(result);
        }
示例#2
0
        public static void Generator()
        {
            //The generator method which holds the prefix arrays, weapon type array and calls the randomizer functions and weighted randomizer library to build the name, rarity and stats of the item

            IWeightedRandomizer <string> rarityRandomizer = new DynamicWeightedRandomizer <string>();

            rarityRandomizer.Add("Common", 10);
            rarityRandomizer.Add("Magic", 6);
            rarityRandomizer.Add("Rare", 4);
            rarityRandomizer.Add("Epic", 2);
            rarityRandomizer.Add("Legendary", 1);

            string[] meleePrefixesList  = { "Bronze", "Silver", "Golden" };
            string[] rangedPrefixesList = { "Accurate", "Fast", "Homing" };
            //TODO: Add functionality to prefixes: Elemental, speed, damage, crit?
            string[] weaponTypeList   = { "Wand", "Sword", "Axe", "Bow" };
            string   weaponType       = Randomize(weaponTypeList);
            string   weaponRarity     = rarityRandomizer.NextWithReplacement();
            string   prefix           = RandomizePrefix(meleePrefixesList, rangedPrefixesList, weaponType);
            float    rarityMultiplier = CreateRarityMultiplier(weaponRarity);
            int      minBaseDamage    = CreateDamageStat(weaponType, rarityMultiplier);
            int      maxBaseDamage    = minBaseDamage + new Random().Next(5, 7);
            double   attacksPerSecond = CreateAttacksPerSecond(weaponType, prefix, weaponRarity);

            //int criticalChance; TODO: add crits
            //float criticalMultiplier; TODO: add crits

            Console.WriteLine($"{prefix + " " + weaponType}");

            //Set this console line to match item rarity for some pizazz!
            switch (weaponRarity)
            {
            case "Magic":
                Console.ForegroundColor = ConsoleColor.Cyan;
                break;

            case "Rare":
                Console.ForegroundColor = ConsoleColor.Yellow;
                break;

            case "Epic":
                Console.ForegroundColor = ConsoleColor.Magenta;
                break;

            case "Legendary":
                Console.ForegroundColor = ConsoleColor.Red;
                break;
            }

            Console.WriteLine($"{weaponRarity + " " + weaponType}");

            //Now reset the console foreground colour
            Console.ResetColor();

            Console.WriteLine($"Damage: {minBaseDamage} - {maxBaseDamage}");
            Console.WriteLine($"Attacks Per Second: {attacksPerSecond}");
            Console.ReadLine();
        }
示例#3
0
        private int ClampMax(int max)
        {
            IWeightedRandomizer <int> randomizer = new DynamicWeightedRandomizer <int>();

            for (int i = 0; i < max; i++)
            {
                randomizer.Add(i + 1, max - i);
            }

            return(randomizer.NextWithRemoval());
        }
示例#4
0
        public int PickHealTarget(Team group)
        {
            IWeightedRandomizer <int> randomizer = new DynamicWeightedRandomizer <int>();

            for (int i = 0; i < Characters.Count; i++)
            {
                if (Characters[i].Group == group && Characters[i].Alive && Characters[i].Priority != HealPriority.Dont)
                {
                    if (Characters[i].Health <= Characters[i].HealingThreshold)
                    {
                        randomizer.Add(i, (int)Characters[i].Priority);
                    }
                }
            }

            if (randomizer.Count > 0)
            {
                return(randomizer.NextWithRemoval());
            }

            return(-1);
        }