Exemplo n.º 1
0
    public void Test_FighterHealthCannotExceedMaxHealth()
    {
        FighterStatsClass stats = new FighterStatsClass();
        const int         heal  = 20;

        stats.GetHealedBy(heal);

        Assert.AreEqual(stats.GetMaxHealth(), stats.GetCurrentHealth(), "Fighter health changed after healing with full health!");
        Assert.LessOrEqual(stats.GetCurrentHealth(), stats.GetMaxHealth(), "Fighter health exceeds full health after healing!");
    }
Exemplo n.º 2
0
    public void Test_FighterCanRevoverFromLastBreath()
    {
        FighterStatsClass stats    = new FighterStatsClass();
        int       lastBreathDamage = Mathf.FloorToInt(stats.GetMaxHealth() - (stats.GetLastBreathThreshold() * stats.GetMaxHealth()));
        const int heal             = 10;

        stats.ReceiveDamage(lastBreathDamage);
        Assert.AreEqual(FighterState.lastBreath, stats.GetCurrentFighterState(), "Fighter didn't get to last breath after his health dropped below the threshold!");

        stats.GetHealedBy(heal);
        Assert.AreEqual(FighterState.alive, stats.GetCurrentFighterState(), "Fighter didn't recover from last breath after his health exceeded the threshold!");
    }
Exemplo n.º 3
0
    public void Use(FighterStatsClass user, IGameController gameCtr = null)
    {
        if (usesLeft == 0)
        {
            Debug.LogWarning("Tried to use item when it had 0 uses left. No effect!");
            return;
        }
        if (user == null)
        {
            Debug.LogWarning("Tried to use item without a user. No effect!");
            return;
        }

        switch (type)
        {
        case ItemType.AttackBoost:
            user.AddLastingDamageBoost("Boost Item", 1.2f);
            if (gameCtr != null)
            {
                SoundEffectControl sfx = gameCtr.GetSFXControl();
                if (sfx != null)
                {
                    sfx.Boost();
                }
            }
            break;

        case ItemType.Healing:
            user.GetHealedBy(80);

            if (gameCtr != null)
            {
                SoundEffectControl sfx = gameCtr.GetSFXControl();
                if (sfx != null)
                {
                    sfx.Heal();
                }
            }
            break;

        case ItemType.DealDamage:
            if (gameCtr != null)
            {
                gameCtr.PlayerThrowBomb();
            }
            break;

        default:
            Debug.LogWarning("There was no behavior specified for item of type " + type.ToString());
            break;
        }
        usesLeft--;
    }
Exemplo n.º 4
0
    public void Test_FighterCannotReceiveNegativeHealing()
    {
        FighterStatsClass stats     = new FighterStatsClass();
        const int         damage    = 30;
        const int         wrongHeal = -20;
        int expectedHealth          = stats.GetMaxHealth() - damage;

        stats.ReceiveDamage(damage);
        stats.GetHealedBy(wrongHeal);

        LogAssert.Expect(LogType.Warning, "Fighter cannot be healed by a negative amount. Health will not be modified.");
        Assert.AreEqual(expectedHealth, stats.GetCurrentHealth(), "Fighter health was modified by negative healing!");
    }
Exemplo n.º 5
0
    public void Test_FighterCanBeHealed()
    {
        FighterStatsClass stats  = new FighterStatsClass();
        const int         damage = 30;
        const int         heal   = 20;
        int damagedHealth        = stats.GetMaxHealth() - damage;
        int expectedHealth       = damagedHealth + heal;

        stats.ReceiveDamage(damage);
        stats.GetHealedBy(heal);

        Assert.AreEqual(expectedHealth, stats.GetCurrentHealth(), "Fighter health is not at the expected value after healing!");
        Assert.AreNotEqual(damagedHealth, stats.GetCurrentHealth(), "Fighter health didn't change after healing!");
    }