Ejemplo n.º 1
0
        public void Subscribe(EventType type, IBattleShield shield)
        {
            switch (type)
            {
            case EventType.ShieldDestroyed:
                shield.ShieldDestroyed += _logShieldDestroyed;
                break;

            case EventType.ShieldHealed:
                shield.ShieldHealed += _logShieldHealed;
                break;

            case EventType.ShieldFortified:
                shield.ShieldFortified += _logShieldFortified;
                break;

            case EventType.DamageTaken:
                BattleShield battleShield = shield as BattleShield;
                if (battleShield != null)
                {
                    battleShield.DamageTaken += _logDamageTaken;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, "a valid EventType must be specified compatible with IBattleShield's implemented events");
            }
        }
Ejemplo n.º 2
0
 public virtual bool AreEqual(IBattleShield shield)
 {
     return(MaxHealth == shield.MaxHealth &&
            Defense == shield.Defense &&
            MagicResistance == shield.MagicResistance &&
            ShieldBusterDefense == shield.ShieldBusterDefense);
 }
Ejemplo n.º 3
0
 //Shield effect is always immediately executed.
 //If I want to ensure the shields are destroyed after X turns, that is a property of the shield, not the effect
 public ShieldFieldEffect(
     TargetType targetType,
     string moveName,
     IBattleShield battleShield)
     : base(targetType, moveName, 0, true)
 {
     BattleShield = battleShield;
 }
        public override bool AreEqual(IBattleShield shield)
        {
            var elementalShield = shield as ElementalBattleShield;

            return(elementalShield != null &&
                   base.AreEqual(shield) &&
                   elementalShield.ElementalType == ElementalType);
        }
Ejemplo n.º 5
0
        public ShieldMove(BattleMove copy) : base(copy)
        {
            ShieldMove shieldMove = copy as ShieldMove;

            if (shieldMove != null)
            {
                Shield = shieldMove.Shield.Copy();
            }
        }
Ejemplo n.º 6
0
        public void SubscribeAll(IBattleShield shield)
        {
            shield.ShieldHealed    += _logShieldHealed;
            shield.ShieldDestroyed += _logShieldDestroyed;
            shield.ShieldFortified += _logShieldFortified;

            BattleShield battleShield = shield as BattleShield;

            if (battleShield != null)
            {
                battleShield.DamageTaken        += _logDamageTaken;
                battleShield.MagicalDamageTaken += _logMagicalDamageTaken;
            }
        }
Ejemplo n.º 7
0
        public void RemovedFromPlayer_WhenDestroyed_MagicalDamage()
        {
            _humanPlayer1.SetBattleShield(_shield as BattleShield);
            IBattleShield shield = _humanPlayer1.BattleShield;

            _logger.SubscribeAll(shield);

            Assert.That(_humanPlayer1.BattleShield, Is.Not.Null);

            _humanPlayer1.MagicalDamage(_shield.MaxHealth, MagicType.Fire);

            Assert.That(_humanPlayer1.BattleShield, Is.Null);
            Assert.AreEqual(_humanPlayer1.MaxHealth, _humanPlayer1.CurrentHealth);
        }
Ejemplo n.º 8
0
        public void GetZeroTurnMove_FirstBattle_IsUnbustableShieldMove()
        {
            //Arrange
            _barbarian.PreBattleSetup(_enemyTeam, _humanTeam, _output, BattleConfigurationSpecialFlag.FirstBarbarianBattle);
            //Act
            BattleMoveWithTarget moveWithTarget = _barbarian.GetZeroTurnMove(_enemyTeam, _humanTeam);
            //Assert
            ShieldMove move = moveWithTarget.Move as ShieldMove;

            Assert.NotNull(move);

            IBattleShield shield = move.Shield;

            Assert.AreEqual(1, shield.ShieldBusterDefense);
        }
        protected void PrintFieldEffectImplementedMessage(IFighter effectExecutor, ShieldFieldEffect effect)
        {
            string teamString = GetFieldEffectTeamString(effectExecutor, effect);

            IBattleShield         battleShield    = effect.BattleShield;
            ElementalBattleShield elementalShield = battleShield as ElementalBattleShield;

            string shieldTypeString = "";

            if (elementalShield != null)
            {
                shieldTypeString = $"{elementalShield.ElementalType.ToString().ToLower()} elemental shields";
            }

            string output = $"{teamString} has gained {shieldTypeString}!";

            _output.WriteLine(output);
        }
Ejemplo n.º 10
0
        public void Setup()
        {
            _logger        = new EventLogger();
            _input         = new MockInput();
            _output        = new MockOutput();
            _menuManager   = new TestMenuManager(_input, _output);
            _chanceService = new MockChanceService();

            _battleManager = new BattleManager(_chanceService, _input, _output);

            _humanPlayer1 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Ted");
            _humanPlayer2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "Jed");

            _enemyPlayer1 = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "Enemy");
            _enemyPlayer2 = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "Enemy");

            _humanTeam = new Team(_menuManager, _humanPlayer1, _humanPlayer2);
            _enemyTeam = new Team(_menuManager, _enemyPlayer1, _enemyPlayer2);

            _shield = new ElementalBattleShield(5, 0, ShieldMagicResistance, MagicType.None);
            _logger.SubscribeAll(_shield);
        }
        protected void PrintPhysicalDamageMessage(object sender, PhysicalDamageTakenEventArgs e)
        {
            int damage = e.Damage;

            if (Config.ShowPhysicalDamageMessages)
            {
                IBattleShield senderAsShield = sender as IBattleShield;

                string output;

                if (senderAsShield != null)
                {
                    output = $"{senderAsShield.Owner.DisplayName}'s {senderAsShield.GetDisplayText(false)} took {damage} damage!";
                }
                else
                {
                    output = $"It did {damage} damage!";
                }

                _output.WriteLine(output);
            }
        }
Ejemplo n.º 12
0
        public void RemovedFromPlayer_WhenDestroyed_PhysicalDamage()
        {
            _humanPlayer1.SetBattleShield(_shield as BattleShield);
            IBattleShield shield = _humanPlayer1.BattleShield;

            _logger.SubscribeAll(shield);

            Assert.That(_humanPlayer1.BattleShield, Is.Not.Null);

            _humanPlayer1.PhysicalDamage(_shield.MaxHealth);

            Assert.That(_humanPlayer1.BattleShield, Is.Null);
            Assert.AreEqual(_humanPlayer1.MaxHealth, _humanPlayer1.CurrentHealth);

            var logs = _logger.Logs;

            Assert.AreEqual(2, logs.Count); //damage taken and destroyed
            var log = logs[1];

            Assert.AreEqual(EventType.ShieldDestroyed, log.Type);
            Assert.IsInstanceOf <ShieldDestroyedEventArgs>(log.E);
            Assert.AreEqual(shield, log.Sender);
        }
Ejemplo n.º 13
0
        public void BattleManager_CorrectlyExecutes_ShieldFortifyingMove([Values(ShieldFortifyingType.Defense, ShieldFortifyingType.Health)] ShieldFortifyingType shieldFortifyingType)
        {
            ElementalBattleShield shield = new ElementalBattleShield(10, 5, 0, MagicType.Fire);

            shield.DecrementHealth(5);
            _humanFighter.SetBattleShield(shield);
            IBattleShield copiedShield = _humanFighter.BattleShield;

            ShieldFortifyingMove shieldFortifyingMove = new ShieldFortifyingMove("foo", TargetType.Self, null, shieldFortifyingType, 5);

            _humanFighter.SetMove(shieldFortifyingMove, 1);
            _humanFighter.SetMove(_runawayMove);
            _humanFighter.SetMoveTarget(_humanFighter);

            _enemy.SetMove(_doNothing);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.NotNull(copiedShield);

            int actualValue = shieldFortifyingType == ShieldFortifyingType.Defense ? copiedShield.Defense : copiedShield.CurrentHealth;

            Assert.AreEqual(10, actualValue);
        }
Ejemplo n.º 14
0
 public ShieldMove(string description, TargetType targetType, string executionText, IBattleShield shield)
     : base(description, BattleMoveType.Shield, targetType, executionText)
 {
     Shield = shield;
 }