예제 #1
0
        /// <summary>
        /// calculate NPC hit points based on battle mode
        /// </summary>
        /// <returns>NPC hit points</returns>
        private int CalculateNpcHitPoints(IBattle battleNpc)
        {
            int battleNpcHitPoints = 0;

            switch (NpcBattleResponse())
            {
            case BattleModeName.ATTACK:
                battleNpcHitPoints = battleNpc.Attack();
                break;

            case BattleModeName.DEFEND:
                battleNpcHitPoints = battleNpc.Defend();
                break;

            case BattleModeName.RETREAT:
                battleNpcHitPoints = battleNpc.Retreat();
                break;
            }
            if (_player.SpecialArmor == Player.Armor.High)
            {
                battleNpcHitPoints -= 2;
            }
            if (_player.SpecialArmor == Player.Armor.High)
            {
                battleNpcHitPoints -= 1;
            }

            return(battleNpcHitPoints);
        }
        private int CalculateNpcHitPoints(IBattle battleNpc)
        {
            int battleNpcHitPoints = 0;

            if (battleNpc is Enemy /*playerHitPoints >= battleNpcHitPoints*/)
            {
                Enemy battlingNpc = _currentNpc as Enemy;


                switch (NpcBattleResponse())
                {
                case BattleModeName.ATTACK:
                    battleNpcHitPoints = battleNpc.Attack();

                    break;

                case BattleModeName.DEFEND:
                    battleNpcHitPoints = battleNpc.Defend();

                    break;

                case BattleModeName.RETREAT:
                    battleNpcHitPoints = battleNpc.Retreat();
                    break;
                }
            }
            return(battleNpcHitPoints);
        }
예제 #3
0
 public void Attack(Guid target)
 {
     if (_battle == null)
     {
         return;
     }
     _battle.Attack(Id, target);
 }
예제 #4
0
        private int CalculateNPCHitPoints(IBattle battleNpc)
        {
            int npcHitPoints = 0;

            switch (NPCBattleResponse())
            {
            case BattleEnum.ATTACK:
                npcHitPoints = battleNpc.Attack();
                break;
            }
            return(npcHitPoints);
        }
예제 #5
0
        private int CalculateNpcHitPoints(IBattle battleNpc)
        {
            int battleNpcHitPoints = 0;

            switch (NpcBattleResponse())
            {
            case BattleModeName.ATTACK:
                battleNpcHitPoints = battleNpc.Attack();
                break;

            case BattleModeName.DEFEND:
                battleNpcHitPoints = battleNpc.Defend();
                break;

            case BattleModeName.RETREAT:
                battleNpcHitPoints = battleNpc.Retreat();
                break;
            }
            return(battleNpcHitPoints);
        }
        private int CaculateNpcHitPoints(IBattle battleNpc)
        {
            int battleNpcHitPoints = 0;

            switch (NpcBattleResponse())
            {
            case BattleModeName.Attack:
                battleNpcHitPoints = battleNpc.Attack();
                break;

            case BattleModeName.Defence:
                battleNpcHitPoints = battleNpc.Defend();
                break;

            case BattleModeName.Retreat:
                battleNpcHitPoints = battleNpc.Retreat();
                break;
            }
            return(battleNpcHitPoints);
        }
예제 #7
0
        private int CalculateNPCHitPoints(IBattle battleNPC)
        {
            int battleNPCHitPoints = 0;

            switch (NPCBattleResponse())
            {
            case BattleModeName.ATTACK:
                battleNPCHitPoints = battleNPC.Attack();
                _player.Health    -= 5;
                break;

            case BattleModeName.DEFEND:
                battleNPCHitPoints = battleNPC.Defend();
                _player.Health    -= 3;
                break;

            default:
                break;
            }

            return(battleNPCHitPoints);
        }
        public void Battle()
        {
            int newHitPoints;

            if (CurrentCharacter is IBattle)
            {
                int    playerAttackPoints    = 0;
                int    characterAttackPoints = 0;
                int    playerDefendPoints    = 0;
                int    characterDefendPoints = 0;
                string battleResults         = "";

                IBattle battleCharacter = CurrentCharacter as IBattle;

                if (_player.MyWeapon != null)
                {
                    playerAttackPoints = _player.Attack();
                    playerDefendPoints = _player.Defend();
                }
                if (battleCharacter.MyWeapon != null)
                {
                    characterAttackPoints = battleCharacter.Attack();
                    characterDefendPoints = battleCharacter.Defend();
                }

                battleResults = $"{_player.Name}: Attack = {playerAttackPoints}\t Defend = {playerDefendPoints}\n" +
                                $"{CurrentCharacter.Name}: Attack = {characterAttackPoints}\t Defend = {characterDefendPoints}";

                if (playerDefendPoints <= characterAttackPoints)
                {
                    newHitPoints      = _player.HitPoints + playerDefendPoints - characterAttackPoints;
                    _player.HitPoints = newHitPoints;
                    if (_player.HitPoints <= 0)
                    {
                        Character selectedCharacter = CurrentCharacter;
                        OnPlayerDeath();
                        battleResults += $"\n{selectedCharacter.Name} has killed you.";
                    }
                }
                else
                {
                    newHitPoints = _player.HitPoints - characterAttackPoints;
                    if (_player.HitPoints <= 0)
                    {
                        Character selectedCharacter = CurrentCharacter;
                        battleResults += $"\n{selectedCharacter.Name} has killed you.";
                    }
                }
                if (characterDefendPoints <= playerAttackPoints)
                {
                    newHitPoints = CurrentCharacter.HitPoints + characterDefendPoints - playerAttackPoints;
                    if (newHitPoints < 0)
                    {
                        newHitPoints = 0;
                    }
                    CurrentCharacter.HitPoints = newHitPoints;
                    if (CurrentCharacter.HitPoints == 0)
                    {
                        Character selectedCharacter = CurrentCharacter;
                        CurrentLocation.GameCharacters.Remove(CurrentCharacter);
                        battleResults += $"\nYou've attacked and defeated {selectedCharacter.Name}.";
                    }
                }
                if (CurrentCharacter != null)
                {
                    newHitPoints = CurrentCharacter.HitPoints - playerAttackPoints;
                    CurrentCharacter.HitPoints = newHitPoints;
                    if (CurrentCharacter.HitPoints <= 0)
                    {
                        battleResults += $"\nYou've attacked and defeated {CurrentCharacter.Name}.";
                        CurrentLocation.GameCharacters.Remove(CurrentCharacter);
                    }
                    else
                    {
                        battleResults += $"\n{CurrentCharacter.Name}'s Hit Points: {CurrentCharacter.HitPoints}";
                    }
                }

                _currentLocation.Message = battleResults;
            }
            else if (CurrentCharacter is Merchant || CurrentCharacter is Policeman || CurrentCharacter is Resident)
            {
                const int innocentAttackPenalty = 25;
                newHitPoints = _player.HitPoints - innocentAttackPenalty;

                _currentLocation.Message = $"{CurrentCharacter.Name} is an innocent person. You loose 25 hit points.";
                _player.HitPoints        = newHitPoints;
            }
        }