Exemplo n.º 1
0
    public void Test_FighterCanChargeUpToThreeTimesButNotMore()
    {
        FighterStatsClass stats = new FighterStatsClass();
        int normalAttackValue   = stats.GetCurrentAttackDamage(false);

        stats.UseChargeForDamageBoost(true);
        int firstBoostValue = stats.GetCurrentAttackDamage(false);

        stats.UseChargeForDamageBoost(true);
        int secondBoostValue = stats.GetCurrentAttackDamage(false);

        stats.UseChargeForDamageBoost(true);
        int thirdBoostValue = stats.GetCurrentAttackDamage(false);

        stats.UseChargeForDamageBoost(true);
        int forthBoostValue = stats.GetCurrentAttackDamage(false);

        // TODO: Rechnung irgendwie hier rausziehen?
        int expectedDamage = Mathf.FloorToInt(stats.GetDefaultAttackDamage() * (1 + stats.GetMaxAmountOfChargings() * stats.GetChargeDamageBoost()));

        Assert.Less(normalAttackValue, firstBoostValue, "First charge for damage boost didn't increase damage!");
        Assert.Less(firstBoostValue, secondBoostValue, "Second charge for damage boost didn't increase damage!");
        Assert.Less(secondBoostValue, thirdBoostValue, "Third charge for damage boost didn't increase damage!");
        Assert.AreEqual(thirdBoostValue, forthBoostValue, "Forth charge for damage boost increased damage, but three boosts is the maximum!");
        Assert.AreEqual(expectedDamage, thirdBoostValue, "Fighter didn't deal 3x boost damage after trying to boost 4 times");
    }
Exemplo n.º 2
0
    public void Test_FighterGetCurrentAttackDamageCanBeDisplayedWithoutReset()
    {
        FighterStatsClass stats = new FighterStatsClass();

        stats.UseChargeForDamageBoost(true);
        int chargedValueDisplayed = stats.GetCurrentAttackDamage(false);
        int chargedValueForAttack = stats.GetCurrentAttackDamage();
        int resettedValue         = stats.GetCurrentAttackDamage(false);


        Assert.AreEqual(chargedValueDisplayed, chargedValueForAttack, "Displaying the attack damage resetted heavy damage even if it shouldn't have done that!");
        Assert.Less(resettedValue, chargedValueForAttack, "Heavy damage wasn't reset after one attack!");
    }
Exemplo n.º 3
0
    public void Test_FighterCanChargeForHeavyDamage()
    {
        FighterStatsClass stats        = new FighterStatsClass();
        int dummyEnemyLifeNormalDamage = 100;
        int dummyEnemyLifeHeavyDamage  = 100;

        dummyEnemyLifeNormalDamage -= stats.GetCurrentAttackDamage();
        stats.UseChargeForDamageBoost(true);
        dummyEnemyLifeHeavyDamage -= stats.GetCurrentAttackDamage();

        Assert.AreNotEqual(dummyEnemyLifeHeavyDamage, dummyEnemyLifeNormalDamage, "Heavy damage and normal attack damage are equal!");
        Assert.Less(dummyEnemyLifeHeavyDamage, dummyEnemyLifeNormalDamage, "Heavy damage wasn't more that normal attack damage!");
    }
Exemplo n.º 4
0
    public void Test_FighterCanReceiveLastingDamageBoost()
    {
        FighterStatsClass stats = new FighterStatsClass();
        int oldDamage           = stats.GetCurrentAttackDamage();

        string source = "Weapon X";
        float  boost  = 0.2f;

        stats.AddLastingDamageBoost(source, boost);

        int newDamage = stats.GetCurrentAttackDamage();

        Assert.Less(oldDamage, newDamage, "Lasting damage boost didn't increase attack damage!");
    }
Exemplo n.º 5
0
    public void Test_FighterChargeHeavyDamageIsRemovedAfterAttack()
    {
        FighterStatsClass stats         = new FighterStatsClass();
        int dummyEnemyLifeNormalDamage1 = 100;
        int dummyEnemyLifeHeavyDamage   = 100;
        int dummyEnemyLifeNormalDamage2 = 100;

        dummyEnemyLifeNormalDamage1 -= stats.GetCurrentAttackDamage();
        stats.UseChargeForDamageBoost(true);
        dummyEnemyLifeHeavyDamage   -= stats.GetCurrentAttackDamage();
        dummyEnemyLifeNormalDamage2 -= stats.GetCurrentAttackDamage();

        Assert.Less(dummyEnemyLifeHeavyDamage, dummyEnemyLifeNormalDamage2, "Heavy damage wasn't more that normal attack damage!");
        Assert.AreEqual(dummyEnemyLifeNormalDamage1, dummyEnemyLifeNormalDamage2, "Heavy damage wasn't reset after one attack!");
    }
Exemplo n.º 6
0
    public void Test_FighterCanRemoveLastingDamageBoost()
    {
        FighterStatsClass stats = new FighterStatsClass();
        int normalDamage        = stats.GetCurrentAttackDamage();

        string sourceA = "Item A";
        float  boostA  = 0.2f;

        stats.AddLastingDamageBoost(sourceA, boostA);

        stats.RemoveLastingDamageBoost(sourceA);
        int damageAfterRemoval = stats.GetCurrentAttackDamage();

        Assert.IsEmpty(stats.lastingDamageBoosts.Keys, "Lasting damage boosts still contain a boost after it was removed!");
        Assert.AreEqual(normalDamage, damageAfterRemoval, "Lasting damage boost couldn't be removed!");
    }
Exemplo n.º 7
0
    public void Test_FighterCannotRemoveNonexistantLastingDamageBoost()
    {
        FighterStatsClass stats = new FighterStatsClass();

        string sourceA = "Item A";
        float  boostA  = 0.2f;

        stats.AddLastingDamageBoost(sourceA, boostA);
        int boostedDamage = stats.GetCurrentAttackDamage();

        stats.RemoveLastingDamageBoost("wrongSource");
        int damageAfterAttemptedRemoval = stats.GetCurrentAttackDamage();

        Assert.AreEqual(boostedDamage, damageAfterAttemptedRemoval, "Attack damage was modified after trying to remove a non-existant lasting damage boost!");
        Assert.IsNotEmpty(stats.lastingDamageBoosts.Keys, "Lasting damage boost of different source was removed when trying to remove one of a non-existant source!");
        LogAssert.Expect(LogType.Warning, "Fighter cannot remove lasting damage boost of a source that never gave him a boost. Attacke damage will not be modified.");
    }
Exemplo n.º 8
0
    public void Test_FighterCanDealAttackDamage()
    {
        FighterStatsClass stats = new FighterStatsClass();
        int dummyEnemyLife      = 100;

        dummyEnemyLife -= stats.GetCurrentAttackDamage();

        Assert.Less(dummyEnemyLife, 100, "Enemy didn't receive any damage from fighter, no attack damage dealt!");
    }
Exemplo n.º 9
0
    public void Test_FighterCanReceiveMultipleLastingDamageBoosts()
    {
        FighterStatsClass stats = new FighterStatsClass();
        int normalDamage        = stats.GetCurrentAttackDamage();

        string sourceA = "Item A";
        float  boostA  = 0.2f;

        stats.AddLastingDamageBoost(sourceA, boostA);
        int firstBoostDamage = stats.GetCurrentAttackDamage();

        string sourceB = "Item B";
        float  boostB  = 0.2f;

        stats.AddLastingDamageBoost(sourceB, boostB);
        int secondBoostDamage = stats.GetCurrentAttackDamage();

        Assert.Contains(sourceA, stats.lastingDamageBoosts.Keys, "Lasting damage boosts don't contain a boost from source A!");
        Assert.Contains(sourceB, stats.lastingDamageBoosts.Keys, "Lasting damage boosts don't contain a boost from source B!");
        Assert.Less(normalDamage, firstBoostDamage, "First lasting damage boost didn't increase attack damage!");
        Assert.Less(firstBoostDamage, secondBoostDamage, "Second lasting damage boost didn't increase attack damage");
    }
Exemplo n.º 10
0
    public void Test_FighterCanReceiveOnlyOneLastingDamageBoostFromSameSource()
    {
        FighterStatsClass stats = new FighterStatsClass();

        string sourceA = "Item A";
        float  boostA  = 0.2f;

        stats.AddLastingDamageBoost(sourceA, boostA);
        int boostedDamage = stats.GetCurrentAttackDamage();

        try
        {
            stats.AddLastingDamageBoost(sourceA, boostA);
            Assert.Fail("Managed to add two lasting damage boosts from the same source without ArgumentException, that shouldn't be possible.");
        }
        catch (System.ArgumentException)
        {
            // do nothing - we expected ArgumentException
        }
        int damageAfterAttemptedDuplication = stats.GetCurrentAttackDamage();

        LogAssert.Expect(LogType.Warning, "Fighter cannot receive multiple lasting damage boosts from the same source. Attacke damage will not be modified.");
        Assert.AreEqual(boostedDamage, damageAfterAttemptedDuplication, "Managed to add two lasting damage boosts from the same source and increase damage with both, that shouldn't be possible.");
    }