コード例 #1
0
        public void LevelUp_DoesNotOverwriteNonLevelUpSpells()
        {
            const int maxLevel  = LevelUpManager.MAX_LEVEL;
            var       expAmount = LevelUpManager.GetExpForLevel(maxLevel);

            var fooSpell = new Spell("Foo", MagicType.None, SpellType.Attack, TargetType.SingleEnemy, 10, 40);

            _fighter.AddSpell(fooSpell);
            var barSpell = new Spell("Bar", MagicType.None, SpellType.Attack, TargetType.SingleEnemy, 5, 10);

            _fighter.AddSpell(barSpell);

            _fighter.GainExp(expAmount);

            Assert.AreEqual(expAmount, _fighter.CurrentExp);
            Assert.AreEqual(maxLevel, _fighter.Level);

            var spells = GetSpellsByLevel(maxLevel);

            Assert.AreEqual(spells.Count + 2, _fighter.Spells.Count);
            Assert.IsTrue(spells.TrueForAll(s => _fighter.Spells.SingleOrDefault(fs => fs.Description == s.Description) != null));
            Assert.IsTrue(_fighter.Spells.SingleOrDefault(s => s.Description == fooSpell.Description) != null);
            Assert.IsTrue(_fighter.Spells.SingleOrDefault(s => s.Description == barSpell.Description) != null);
        }
コード例 #2
0
        public void AddSpellMethod_AppropriatelyRaisesEvents()
        {
            var spell = SpellFactory.GetSpell(MagicType.Fire, 1);

            _fighter.AddSpell(spell);

            var logs = _logger.Logs;

            Assert.AreEqual(1, logs.Count);
            Assert.AreEqual(EventType.SpellLearned, logs[0].Type);
            Assert.AreEqual(_fighter, logs[0].Sender);
            var e = logs[0].E as SpellsLearnedEventArgs;

            Assert.NotNull(e);
            Assert.AreEqual(spell, e.SpellsLearned[0]);
        }