Exemplo n.º 1
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.º 2
0
    public void Test_FighterDiesIfHealthDropsToZero()
    {
        FighterStatsClass stats = new FighterStatsClass();
        int killDamage          = stats.GetCurrentHealth();

        stats.ReceiveDamage(killDamage);

        Assert.AreEqual(FighterState.dead, stats.GetCurrentFighterState(), "Fighter didn't die after health dropped to zero!");
    }
Exemplo n.º 3
0
    public void Test_FighterIsOnLastBreathWhileHealthBelowThreshhold()
    {
        FighterStatsClass stats = new FighterStatsClass();
        int lastBreathDamage    = Mathf.FloorToInt(stats.GetMaxHealth() - (stats.GetLastBreathThreshold() * stats.GetMaxHealth()));

        stats.ReceiveDamage(lastBreathDamage);

        Assert.AreEqual(FighterState.lastBreath, stats.GetCurrentFighterState(), "Fighter didn't get to last breath after his health dropped below the threshold!");
    }
Exemplo n.º 4
0
    public virtual bool AttackOpponent(FighterStatsClass opponent, bool CanBeDodged = true, bool ignoreTurnTime = false)
    {
        if (!CanAct() && !ignoreTurnTime)
        {
            Debug.LogWarning("Tried to attack an opponent when not allowed to do that!");
            return(false);
        }
        if (!ignoreTurnTime)
        {
            currentTurnTime = 0;
        }

        if (opponent == null)
        {
            Debug.LogWarning("Fighter tried to attack an opponent that's a nnullpointer. Can't attack non-existant opponents!");
        }
        else if (opponent.GetCurrentFighterState() == FighterState.dead)
        {
            Debug.LogWarning("Fighter tried to attack an opponent that already died. Can't attack dead opponents!");
        }
        else
        {
            if (CanBeDodged)
            {
                float dodgeRand = 1;
                dodgeRand = Random.value;
                if (dodgeRand >= opponent.GetDodgePropability())
                {
                    opponent.ReceiveDamage(GetCurrentAttackDamage());
                    return(true);
                }
                else
                {
                    opponent.ShowDodge();
                    return(false);
                }
            }
            else
            {
                opponent.ReceiveDamage(GetCurrentAttackDamage());
                return(true);
            }
        }
        return(false);
    }
Exemplo n.º 5
0
    public void Test_FighterStartsGameAlive()
    {
        FighterStatsClass stats = new FighterStatsClass();

        Assert.AreEqual(FighterState.alive, stats.GetCurrentFighterState(), "Fighter didn't start the game alive!");
    }