Exemplo n.º 1
0
    private void Attack()
    {
        // Asking the BLL to do all the logic
        var response = _combatService.Attack(CurrentCharacter, Target.CurrentCharacter);

        // Getting the informations in order to play animations, effects, etc (everything that is adherent to unity engine)
        if (response.TookDamage)
        {
            PlayDamageEffect(Target, response.DamageValue);
        }

        if (response.IsDead)
        {
            PlayDeathEffect(Target);
        }
    }
Exemplo n.º 2
0
        public void Attack_WhenNoMoreHp_ExpectTargetDied()
        {
            // Arrange
            var player = new CharacterDto();

            player.Attack = 10;
            var target = new CharacterDto();

            player.Defense = 1;
            player.Hp      = 1;

            var service = new CombatService();

            // Act
            var result = service.Attack(player, target);

            result.IsDead.Should().BeTrue();
        }
Exemplo n.º 3
0
        public static string TryToAttack()
        {
            string message = GameStrings.NothingToAttackHereString;

            var monster = CurrentRoom.getMonster();

            // First, check if there is a monster to fight
            if (monster != null)
            {
                if (monster.isDead())
                {
                    message = $"The {monster.name} is dead.";
                }
                else
                {
                    // If a monster exists, attack it
                    message = CombatService.Attack(monster);
                    if (monster.isDead())
                    {
                        message += $"\n{monster.deathMessage}";
                    }
                    else
                    {
                        // If the monster is still alive, defend against its attack:
                        message += "\n" + CombatService.Defend(monster);
                        if (Player.isDead())
                        {
                            state    = false;
                            message += "\n" + Player.death;
                        }
                    }
                }
            }

            return(message);
        }
Exemplo n.º 4
0
        public async Task WhenAttacking_HealthIsRemovedFromTheTarget()
        {
            await _combatService.Attack(_user, _target, Channel);

            _statsRepository.Verify(repo => repo.UpdateHealth(_target.Id, It.IsAny <int>()));
        }