Exemplo n.º 1
0
    public void GroupCombatRound(Warrior w1, List <Warrior> group)
    {
        roundCounter += 1;
        int attackValueW1  = w1.CalcAttack(rnd);
        int defenceValueG1 = group[0].CalcDefence(rnd);

        if (attackValueW1 > defenceValueG1)
        {
            int currentDam = w1.CalcDamage(rnd);
            group[0].TakeDamage(currentDam);
            PrintHitAttack(w1, group[0], currentDam);
        }
        else
        {
            PrintParry(w1, group[0]);
        }
        for (int i = 0; i < group.Count; i++)
        {
            if (group[0].CalcAttack(rnd) > w1.CalcDefenceMultibleOpponents(rnd, group.Count))
            {
                int currentDam = group[0].CalcDamage(rnd);
                w1.TakeDamage(currentDam);
                PrintHitAttack(group[i], w1, currentDam);
            }
            else
            {
                PrintParry(group[i], w1);
            }
        }
        print("b4 dead members are removed");
        RemoveDeadMembers(group);
        print("dead members removed. " + group.Count + " members left");
        GroupCombatOverCheck(w1, group, false);
    }
Exemplo n.º 2
0
    // The body of combat rounds. Ends in CombatOverCheck()
    public void CombatRound(Warrior w1, Warrior w2)
    {
        roundCounter += 1;
        int attackValueW1  = w1.CalcAttack(rnd);
        int attackValueW2  = w2.CalcAttack(rnd);
        int defenceValueW1 = w1.CalcDefence(rnd);
        int defenceValueW2 = w2.CalcDefence(rnd);

        if (attackValueW1 > defenceValueW2)
        {
            int currentDam = w1.CalcDamage(rnd);
            w2.TakeDamage(currentDam);
            PrintHitAttack(w1, w2, currentDam);
        }
        else
        {
            PrintParry(w1, w2);
        }

        if (attackValueW2 > defenceValueW1)
        {
            int currentDam = w2.CalcDamage(rnd);
            w1.TakeDamage(currentDam);
            PrintHitAttack(w2, w1, currentDam);
        }
        else
        {
            PrintParry(w2, w1);
        }
        CombatOverCheck(w1, w2, false);
    }
Exemplo n.º 3
0
        public void CalcDamage_CalcDamageWithValidWeaponAndArmor_ShouldReturnDamage()
        {
            Warrior warrior       = new Warrior("Valdemar");
            Armor   testPlateBody = new Armor()
            {
                ItemName        = "Common plate body armor",
                ItemLevel       = 1,
                ItemSlot        = ArmorSlots.BODY,
                ArmorType       = ArmorTypes.PLATE,
                ArmorAttributes = new PrimaryAttributes()
                {
                    Vitality = 2, Strength = 1
                }
            };

            warrior.EquipArmor(testPlateBody);
            Weapon testAxe = new Weapon()
            {
                ItemName         = "Common axe",
                ItemLevel        = 1,
                ItemSlot         = ArmorSlots.WEAPON,
                WeaponType       = WeaponTypes.AXE,
                WeaponAttributes = new WeaponAttributes()
                {
                    Damage = 7, AttackSpeed = 1.1
                }
            };

            warrior.EquipWeapon(testAxe);
            warrior.CalcDamage();

            Assert.Equal((7 * 1.1) * (1 + ((5 + 1) / 100)), warrior.Damage);
        }
Exemplo n.º 4
0
        public void CalcDamage_CalcDamageWithoutWeapon_ShouldReturnDamage()
        {
            Warrior warrior = new Warrior("Valdemar");

            warrior.CalcDamage();

            Assert.Equal(1 * (1 + (5 / 100)), warrior.Damage);
        }
Exemplo n.º 5
0
        public void CalcDamage_CalcDamageWithValidWeapon_ShouldReturnDamage()
        {
            Warrior warrior = new Warrior("Valdemar");
            Weapon  testAxe = new Weapon()
            {
                ItemName         = "Common axe",
                ItemLevel        = 1,
                ItemSlot         = ArmorSlots.WEAPON,
                WeaponType       = WeaponTypes.AXE,
                WeaponAttributes = new WeaponAttributes()
                {
                    Damage = 7, AttackSpeed = 1.1
                }
            };

            warrior.EquipWeapon(testAxe);
            warrior.CalcDamage();

            Assert.Equal((7 * 1.1) * (1 + (5 / 100)), warrior.Damage);
        }