Beispiel #1
0
        public void SetBattleShield(BattleShield battleShield)
        {
            BattleShield = battleShield.Copy() as BattleShield;
            BattleShield.SetOwner(this);

            ShieldAddedEventArgs e = new ShieldAddedEventArgs(BattleShield);

            OnShieldAdded(e);
        }
        protected void PrintShieldAddedMessage(object sender, ShieldAddedEventArgs e)
        {
            if (Config.ShowShieldAddedMessage)
            {
                IFighter senderAsFighter = sender as IFighter;

                if (senderAsFighter == null)
                {
                    throw new InvalidOperationException("Battlemanager.PrintShieldAddedMessage() subscribed to something that was not an IFighter, that's odd");
                }

                string shieldDisplayText = e.BattleShield.GetDisplayText();
                string output            = $"{senderAsFighter.DisplayName} was equipped with {shieldDisplayText}!";
                _output.WriteLine(output);
            }
        }
Beispiel #3
0
        public void SetBattleShieldMethod_AppropriatelyRaisesBattleShieldAddedEvent()
        {
            IBattleShield shield = new IronBattleShield(1, 0, 0);

            _fighter.SetBattleShield((BattleShield)shield);

            List <EventLog> logs = _logger.Logs;

            Assert.AreEqual(1, logs.Count);

            EventLog log = logs[0];

            Assert.AreEqual(EventType.ShieldAdded, log.Type);

            ShieldAddedEventArgs e = log.E as ShieldAddedEventArgs;

            Assert.NotNull(e);
            Assert.IsTrue(shield.AreEqual(e.BattleShield));
        }
        public void BattleManager_CorrectlyUnsubscribes_OnceShieldRemovedFromPlayer()
        {
            BattleShield shield     = new IronBattleShield(1, 0, 0);
            ShieldMove   shieldMove = new ShieldMove("foo", TargetType.Self, null, shield);

            _humanPlayer1.SetMove(shieldMove, 1);
            _humanPlayer1.SetMove(_doNothingMove);
            _humanPlayer1.SetMoveTarget(_humanPlayer1);
            _humanPlayer1.SetSpeed(1);

            _enemyPlayer1.SetMove(_basicAttackMove);
            _enemyPlayer1.SetStrength(1000);
            _enemyPlayer1.SetMoveTarget(_humanPlayer1);
            _chanceService.PushEventsOccur(true, false, true, false); //two attacks to end the battle, both hit, neither are crits

            _logger.Subscribe(EventType.ShieldAdded, _humanPlayer1);

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

            _battleManager.Battle(_humanTeam, _enemyTeam);

            int outputCountBefore = _output.GetOutputs().Length;

            ShieldAddedEventArgs e = _logger.Logs[0].E as ShieldAddedEventArgs;

            Assert.NotNull(e);

            BattleShield shieldCopy = e.BattleShield;

            shieldCopy.OnDamageTaken(new PhysicalDamageTakenEventArgs(7));

            int outputCountAfter = _output.GetOutputs().Length;

            Assert.AreEqual(outputCountBefore, outputCountAfter);
        }
Beispiel #5
0
 private void _logShieldAdded(object sender, ShieldAddedEventArgs e)
 {
     Logs.Add(new EventLog(EventType.ShieldAdded, sender, e));
 }
Beispiel #6
0
 public void OnShieldAdded(ShieldAddedEventArgs e)
 {
     ShieldAdded?.Invoke(this, e);
 }