Beispiel #1
0
        private void CheckStats()
        {
            _player.DisplayEquipment();

            string[] types = Enum.GetNames(typeof(ItemType));

            ConsoleExtras.ColorLine("Change Equipment:\n\r 1. Back" +
                                    $"\n\r {string.Join("\n\r ", types.Select((type, index) => $"{index+2}. {type}"))}");

            int option = ConsoleExtras.GetIntInput(types.Length + 2);

            if (option == 1)
            {
                return;
            }

            var itemType = (ItemType)(option - 2);

            ConsoleExtras.ColorLine($"\nYour inventory of {itemType}s:\n\r 1. Back" +
                                    $"\n\r {string.Join("\n\r ", _inventory[itemType].Select((item, index) => $"{index + 2}. {item}"))}");

            option = ConsoleExtras.GetIntInput(_inventory[itemType].Count + 2);
            if (option == 1)
            {
                CheckStats();
                return;
            }

            SwapEquipment(itemType, option - 2);
            _player.ApplyItemStats();
        }
        public void GenerateNewItem()
        {
            var item = new Item(_owner.Level);

            ConsoleExtras.ColorLine($"Recieved new item!\n {item}", ConsoleColor.Blue);
            _inventory[item.Type].Add(item);
        }
        private static IMonster InstantiatePlayer()
        {
            ConsoleExtras.ColorLine("Enter a class: " + string.Join(", ", Enum.GetNames(typeof(Race))));
            IMonster player = GetMonster(ConsoleExtras.GetRaceInput());

            ConsoleExtras.ColorLine("\nWrite stat inputs for your monster.", ConsoleColor.Cyan);
            ConsoleExtras.ColorLine("TIP: if input is outside range, it will be automatically put within range", ConsoleColor.DarkYellow);
            GetStatInfo(player, out int health, out int defence, out int power, out int speed);

            return(player.Initialize(health, defence, power, speed));
        }
Beispiel #4
0
        public void Start()
        {
            Console.WriteLine("Enter a class: " + string.Join(", ", Enum.GetNames(typeof(Race))));

            _player = GetMonster(ConsoleExtras.GetRaceInput(), 1);
            Thread.Sleep(10); // Seperate the seed for System.Random's algorithm.
            _enemy  = InstantiateEnemy(_player.Race, _player.Level);
            _random = new Random();

            Continue = true;
            _round   = 0;
            _wave    = 1;
        }
        private static void GetStatInfo(IMonster monster, out int health, out int defence, out int power, out int speed)
        {
            ConsoleExtras.ColorLine($"Enter a value between {monster.Min.health} and {monster.Max.health} for health");
            health = ConsoleExtras.GetIntInput();

            ConsoleExtras.ColorLine($"Enter a value between {monster.Min.defence} and {monster.Max.defence} for defence");
            defence = ConsoleExtras.GetIntInput();

            ConsoleExtras.ColorLine($"Enter a value between {monster.Min.power} and {monster.Max.power} for power");
            power = ConsoleExtras.GetIntInput();

            ConsoleExtras.ColorLine($"Enter a value between {monster.Min.speed} and {monster.Max.speed} for speed");
            speed = ConsoleExtras.GetIntInput();
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            ConsoleExtras.ColorLine("What would you like to do?\n1. Test Monsters\n2. Start Simulation");
            bool @continue;

            switch (ConsoleExtras.GetIntInput())
            {
            case 1:
            {
                ConsoleExtras.ColorLine("How many tests per monster? (1-100)");
                int amount = Math.Min(Math.Max(1, ConsoleExtras.GetIntInput()), 100);
                Console.Clear();
                new BalanceTester(amount).TestMonsters();
                Console.WriteLine();
                @continue = true;
                break;
            }

            case 2:
            {
                var engine = new Engine();
                engine.Start();

                Console.Clear();

                while (engine.Continue)
                {
                    engine.Update();
                }

                ConsoleExtras.ColorLine("Want to play again?");
                @continue = ConsoleExtras.GetBoolInput();
                Console.Clear();
                break;
            }

            default:
                ConsoleExtras.ColorLine("INVALID OPTION", ConsoleColor.Red);
                @continue = true;
                break;
            }

            if (@continue)
            {
                Main(null);
            }
        }
        static void Main(string[] args)
        {
            IMonster player = InstantiatePlayer();
            IMonster enemy  = InstantiateEnemy(player.Race);

            Console.Clear();

            for (int i = 0; player.IsAlive && enemy.IsAlive; i++)
            {
                ConsoleExtras.ColorLine("Select Option:\n\r1. Fight\n\r2. Check Stats");

                switch (ConsoleExtras.GetIntInput())
                {
                case 1:
                    Attack(i, player, enemy);
                    break;

                case 2:
                    ConsoleExtras.ColorLine($"\nYour monster's stats:\t{player}", ConsoleColor.Cyan);
                    ConsoleExtras.ColorLine($"Enemy's stats:\t{enemy}\n", ConsoleColor.Red);
                    break;

                default:
                    ConsoleExtras.ColorLine("Invalid Selection", ConsoleColor.Red);
                    break;
                }

                Console.WriteLine();
            }

            if (player.IsAlive)
            {
                ConsoleExtras.ColorLine("YOU WIN!", ConsoleColor.Cyan);
            }
            else
            {
                ConsoleExtras.ColorLine("YOU LOSE", ConsoleColor.Red);
            }

            ConsoleExtras.ColorLine("Want to play again?");
            if (ConsoleExtras.GetBoolInput())
            {
                Console.Clear();
                Main(null);
            }
        }
        private static IMonster InstantiateEnemy(Race race)
        {
            var  ran    = new Random();
            int  length = Enum.GetValues(typeof(Race)).Length;
            Race randomRace;

            do
            {
                randomRace = (Race)ran.Next(0, length);
            }while (randomRace == race);
            IMonster enemy = GetMonster(randomRace);

            ConsoleExtras.ColorLine($"\nWrite stat inputs for enemy monster ({enemy.Name}).", ConsoleColor.Red);
            ConsoleExtras.ColorLine("TIP: if input is outside range, it will be automatically put within range", ConsoleColor.DarkYellow);
            GetStatInfo(enemy, out int health, out int defence, out int power, out int speed);

            return(enemy.Initialize(health, defence, power, speed));
        }
Beispiel #9
0
        public void Update()
        {
            _round++;
            ConsoleExtras.ColorLine("Select Option:\n\r1. Fight\n\r2. Check Stats\n\r3. Check Equipment\n\r4. Quit");

            switch (ConsoleExtras.GetIntInput(5))
            {
            case 1:
                ConsoleExtras.ColorLine($"\nRound {_round}, Wave {_wave}:");
                Attack(_player, _enemy);
                break;

            case 2:
                ConsoleExtras.ColorLine($"\nYour stats:\n{_player}", ConsoleColor.Cyan);
                ConsoleExtras.ColorLine($"Enemy's stats:\n{_enemy}\n", ConsoleColor.Red);
                break;

            case 3:
                CheckStats();
                break;

            case 4:
                Continue = false;
                return;
            }

            if (!_enemy.IsAlive)
            {
                ConsoleExtras.ColorLine("New Enemy has appeared!", ConsoleColor.DarkRed);
                _enemy = InstantiateEnemy(_player.Race, _random.Next(_player.Level - 1, _player.Level + 1));
                _round = 0;
                _wave++;
            }

            if (!_player.IsAlive)
            {
                Continue = false;
            }

            Console.WriteLine();
        }
        private static void Attack(int counter, IMonster player, IMonster enemy)
        {
            ConsoleExtras.ColorLine($"\nRound {counter + 1}:");

            if (player.Speed >= enemy.Speed)
            {
                player.Attack(enemy);
                if (enemy.IsAlive)
                {
                    enemy.Attack(player);
                }
            }
            else
            {
                enemy.Attack(player);
                if (player.IsAlive)
                {
                    player.Attack(enemy);
                }
            }
        }
        static void Main(string[] args)
        {
            bool @continue;

            var engine = new Engine();

            engine.Start();

            Console.Clear();

            while (engine.Continue)
            {
                engine.Update();
            }

            ConsoleExtras.ColorLine("Want to play again?");
            @continue = ConsoleExtras.GetBoolInput();
            Console.Clear();

            if (@continue)
            {
                Main(null);
            }
        }