public void Has_enough_mana() { _player.Level = 45; _player.Attributes = new Attributes() { Attribute = new Dictionary <EffectLocation, int> { { EffectLocation.Mana, 100 } } }; var spell = new Spell.Model.Spell() { Name = "chill touch", Cost = new SkillCost() { Table = new Dictionary <Cost, int> { { Cost.Mana, 10 } } } }; Assert.True(_spell.ManaCheck(spell, _player)); }
public void Not_enough_mana() { _player.Level = 45; _player.Attributes = new Attributes() { Attribute = new Dictionary <EffectLocation, int> { { EffectLocation.Mana, 0 } } }; _Spells.Cost.Table[Cost.Mana] = 100; var spell = new Spell.Model.Spell() { Name = "chill touch", Cost = new SkillCost() { Table = new Dictionary <Cost, int> { { Cost.Mana, 100 } } } }; Assert.False(_spell.ManaCheck(spell, _player)); _writer.Verify(w => w.WriteLine(It.Is <string>(s => s == "You don't have enough mana."), "mob"), Times.Once); }
public void Does_spell_affect_character() { _player.Status = CharacterStatus.Status.Standing; var spell = new Spell.Model.Spell() { Name = "Magic missile", ValidTargets = ValidTargets.TargetPlayerRoom | ValidTargets.TargetFightVictim }; Assert.True(_spell.SpellAffectsCharacter(spell)); }
public Item.Item CheckTargetItem(Spell.Model.Spell spell, string target, Room room, Player player) { var item = GetTargetItem(target, player); if (item == null) { _writer.WriteLine("You can't find that item on you.", player.ConnectionId); return(null); } return(item); }
public void message_for_cast_on_self() { var spell = new Spell.Model.Spell() { Name = "Magic missile", ValidTargets = ValidTargets.TargetPlayerRoom | ValidTargets.TargetFightVictim }; _player.Status = CharacterStatus.Status.Standing; _player.Gender = "Male"; _target.Id = Guid.NewGuid(); _player.Id = _target.Id; _spell.ReciteSpellCharacter(_player, _target, spell); _writer.Verify(w => w.WriteLine(It.Is <string>(s => s == "Malleus closes his eyes and utters the words, 'Magic missile'.")), Times.Once); }
public void message_for_cast_on_self() { var spell = new Spell.Model.Spell() { Name = "Magic missile", ValidTargets = ValidTargets.TargetPlayerRoom | ValidTargets.TargetFightVictim }; var room = new Room(); _player.Status = CharacterStatus.Status.Standing; _player.Gender = "Male"; _target.Id = Guid.NewGuid(); _player.Id = _target.Id; _player.ConnectionId = _target.Id.ToString(); _player.ClassName = "Mage"; _player.Attributes.Attribute[EffectLocation.Mana] = 500; _spell.ReciteSpellCharacter(_player, _target, spell, room); _writer.Verify(w => w.WriteLine(It.Is <string>(s => s == "You close your eyes and utter the words, 'Magic missile'."), _player.ConnectionId), Times.Once); }
/// <summary> /// Finds the target object of the spell /// </summary> /// <param name="spell">The Spell being cast</param> /// <param name="target">Target comes from the command param. cast enchant sword</param> /// <param name="room">Room the player is in</param> /// <param name="player">The PC casting the spell</param> /// <returns></returns> public Item.Item ReturnTargetObject(Spell.Model.Spell spell, string target, Room room, Player player) { // casting spell on item in inventory or worn // example spells, cast enchant sword, cast light sword if ((spell.ValidTargets & ValidTargets.TargetObjectInventory) != 0 || (spell.ValidTargets & ValidTargets.TargetObjectEquipped) != 0) { return(CheckTargetItem(spell, target, room, player)); } // TODO: unsure on these: //if ((spell.ValidTargets & ValidTargets.TargetObjectRoom) != 0 ) //{ // return CheckTargetItem(spell, target, room, player); //} //if ((spell.ValidTargets & ValidTargets.TargetObjectWorld) != 0) //{ // return CheckTargetItem(spell, target, room, player); //} return(null); }
public void message_for_cast_on_not_self() { var room = new Room(); var spell = new Spell.Model.Spell() { Name = "Magic missile", ValidTargets = ValidTargets.TargetPlayerRoom | ValidTargets.TargetFightVictim }; _player.Status = CharacterStatus.Status.Standing; _player.Gender = "Male"; _target.Name = "Bob"; _target.ClassName = "Mage"; _target.Id = Guid.NewGuid(); _player.Id = Guid.NewGuid(); _player.ConnectionId = "abc"; _target.ConnectionId = "bcd"; _spell.ReciteSpellCharacter(_player, _target, spell, room); _writer.Verify(w => w.WriteLine(It.Is <string>(s => s == "You look at Bob and utter the words, 'Magic missile'."), _player.ConnectionId), Times.Once); _writer.Verify(w => w.WriteLine(It.Is <string>(s => s == "Malleus looks at you and utters the words, 'Magic missile'."), _target.ConnectionId), Times.Once); }
public SpellTests() { _Spells = new Spell.Model.Spell() { Name = "Ogre strength", Effect = new Effect.Effect() { Modifier = new EffectModifier() { Value = 10, PositiveEffect = true }, Location = EffectLocation.Strength, Name = "OgreStrength", Duration = new EffectModifier() { Value = 10, PositiveEffect = true, }, Accumulate = true, Id = 1 }, Damage = new Dice() { DiceRoll = 1, DiceMinSize = 10, DiceMaxSize = 10 }, Description = "Makes you strong as an ogre", Rounds = 1, SpellGroup = new Sphere() }; _player = new Player() { Name = "Malleus", ClassName = "Paladin", Status = CharacterStatus.Status.Standing, Attributes = new Attributes() { Attribute = new Dictionary <EffectLocation, int> { { EffectLocation.Mana, 250 }, { EffectLocation.Strength, 0 } } }, Spells = new List <Spell.Model.Spell>(), Skills = new List <SkillList>() }; _player.Spells.Add(new Spell.Model.Spell() { Name = "chill touch", Cost = new SkillCost() { Table = new Dictionary <Cost, int> { { Cost.Mana, 10 } } } }); _target = new Player() { Attributes = new Attributes() { Attribute = new Dictionary <EffectLocation, int> { { EffectLocation.Strength, 0 }, { EffectLocation.Hitpoints, 2500 }, } } }; _room = new Room(); _writer = new Mock <IWriteToClient>(); _damage = new Mock <IDamage>(); _spellTargetCharacter = new Mock <ISpellTargetCharacter>(); _cache = new Mock <ICache>(); _updateClientUI = new Mock <IUpdateClientUI>(); _mobScript = new Mock <IMobScripts>(); _spell = new Spells(_writer.Object, _spellTargetCharacter.Object, _cache.Object, _damage.Object, _updateClientUI.Object, _mobScript.Object); var newSkill = new Skill.Model.Skill { Name = "magic missile", Id = 1, }; }