Exemplo n.º 1
0
        public void NextColor_DyingPlayer_ShouldGetSingleColorChance()
        {
            PlayerHPStaticRate health = new PlayerHPStaticRate(damageRate: 0.33f);
            PlayerState        player = new PlayerState(health);

            player.TakeDamage(); // hp normalized 0.67
            player.TakeDamage(); // hp normalized 0.34
            player.TakeDamage(); // hp normalized 0.01

            Difficulty diff      = new Difficulty(player);
            int        testCount = 99;

            int[] control = new int[testCount];
            int[] colors  = new int[testCount];

            colors[0]  = diff.NextSlot();
            control[0] = colors[0];

            for (int i = 1; i < testCount; i++)
            {
                control[i] = control[0];
                colors[i]  = diff.NextSlot();
            }

            CollectionAssert.AreEqual(control, colors);
        }
Exemplo n.º 2
0
        public void TakeDamage_ShouldDecreaseHP()
        {
            PlayerHPStaticRate health      = new PlayerHPStaticRate();
            PlayerState        playerState = new PlayerState(health);

            playerState.TakeDamage();

            Assert.Greater(health.MaxHP, playerState.HP);
        }
Exemplo n.º 3
0
        public void Regen_OnFullHP_HPShouldBeCappedAtMaxHP()
        {
            PlayerHPStaticRate health      = new PlayerHPStaticRate();
            PlayerState        playerState = new PlayerState(health);

            playerState.Regen();

            Assert.AreEqual(playerState.HP, health.MaxHP);
        }
Exemplo n.º 4
0
        public void TakeDamage_OnZeroHP_HPShouldBeCappedAtZero()
        {
            PlayerHPStaticRate health      = new PlayerHPStaticRate(damageRate: 1f); //instakill
            PlayerState        playerState = new PlayerState(health);

            playerState.TakeDamage(); //already dead
            playerState.TakeDamage();

            Assert.AreEqual(playerState.HP, 0);
        }