Example #1
0
        public void RollIniative(Warrior one, Warrior two)
        {
            if (one.Iniative > two.Iniative)
            {
                //If first draws first
                first  = one;
                second = two;
            }
            else if (two.Iniative > one.Iniative)
            {
                //If second draws first
                first  = two;
                second = one;
            }
            else
            {
                //Randomize draw success
                var roll = HelperService.Randomize(1, 2);

                if (roll == 1)
                {
                    first  = one;
                    second = two;
                }
                else
                {
                    first  = two;
                    second = one;
                }
            }
        }
 public Warrior SpawnWarrior(int id)
 {
     return(new Warrior
     {
         Id = id,
         Name = GenerateName(),
         Iniative = HelperService.Randomize(1, 10),
         MinAttack = HelperService.Randomize(1, 3),
         MaxAttack = HelperService.Randomize(4, 8),
         MinDefense = HelperService.Randomize(2, 4),
         MaxDefense = HelperService.Randomize(5, 8),
         IsAlive = true
     });
 }
Example #3
0
        public void CommenceBattle(List <Warrior> warriors)
        {
            var first  = new Warrior();
            var second = new Warrior();

            first  = warriors[HelperService.RandomizeFromList(warriors.Count)];
            second = warriors[HelperService.RandomizeFromList(warriors.Count)];
            warriors.Remove(first);
            warriors.Remove(second);



            while (first.IsAlive && second.IsAlive)
            {
                //Battle to death
                Console.WriteLine($"{first.Name} furiously attacks!");
                var defenderIsHurt = Attack(HelperService.Randomize(first.MinAttack, first.MaxAttack), HelperService.Randomize(second.MinDefense, second.MaxDefense));

                if (defenderIsHurt)
                {
                    second.IsAlive = false;
                    Console.WriteLine($"{first.Name} viciously slays {second.Name}. May he feast forever in Valhalla.\n");
                    break;
                }
                else
                {
                    Deflect(first.Name, second.Name);
                    Console.WriteLine($"{second.Name} furiously attacks!");

                    defenderIsHurt = Attack(HelperService.Randomize(second.MinAttack, second.MaxAttack), HelperService.Randomize(first.MinDefense, first.MaxDefense));

                    if (defenderIsHurt)
                    {
                        first.IsAlive = false;
                        Console.WriteLine($"{second.Name} viciously slays {first.Name}. May he feast forever in Valhalla.\n");
                        break;
                    }

                    Deflect(second.Name, first.Name);
                }
            }
        }
        public string GenerateName()
        {
            var first  = HelperService.Randomize(1, 10);
            var second = HelperService.Randomize(1, 10);

            var    firstName = "";
            string lastName  = "";

            switch (first)
            {
            case 1:
                firstName = "Crogar";
                break;

            case 2:
                firstName = "Torulf";
                break;

            case 3:
                firstName = "Grognak";
                break;

            case 4:
                firstName = "Conan";
                break;

            case 5:
                firstName = "Hagrid";
                break;

            case 6:
                firstName = "Stoneface";
                break;

            case 7:
                firstName = "Edgar";
                break;

            case 8:
                firstName = "Thy Dungeonman";
                break;

            case 9:
                firstName = "Grokk";
                break;

            case 10:
                firstName = "Bork";
                break;

            default:
                firstName = "Mr Alias";
                break;
            }

            switch (second)
            {
            case 1:
                lastName = "the Horrible";
                break;

            case 2:
                lastName = "Swordsbane";
                break;

            case 3:
                lastName = "the Fat";
                break;

            case 4:
                lastName = "Gutmuncher";
                break;

            case 5:
                lastName = "the Awful";
                break;

            case 6:
                lastName = "Armbreaker";
                break;

            case 7:
                lastName = "the Terrible";
                break;

            case 8:
                lastName = "von Hell";
                break;

            case 9:
                lastName = "the Smelly";
                break;

            case 10:
                lastName = "Thunderaxe";
                break;

            default:
                lastName = "Undercover";
                break;
            }

            return($"{firstName} {lastName}");
        }