public void TestFireballChannelingActivation() { AttackContext.Owner = CreateDummyRobot(); MagicUser ActiveUser = new MagicUser(); MagicSpell ActiveSpell = new MagicSpell(ActiveUser, ActiveUser); MagicUserParams Params = new MagicUserParams(ActiveSpell.GlobalContext); ActiveUser.ManaReserves = 1000; ActiveUser.CurrentMana = 100; InvisibleMagicCoreFireball FireballCore1 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore1.ListLinkedMagicElement.Add(new ChannelExternalManaSource(Params)); ActiveSpell.ListMagicCore.Add(FireballCore1); ActiveSpell = new MagicSpell(ActiveSpell, ActiveUser); BaseAutomaticSkill NewSkill = ActiveSpell.ComputeSpell()[0]; CreateFireballEffectTripleThunder Fireball = (CreateFireballEffectTripleThunder)NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0]; for (int i = 0; i < 9; i++) { NewSkill.AddSkillEffectsToTarget(string.Empty); Assert.AreEqual(i + 1, Fireball.ChanneledMana); } NewSkill.AddSkillEffectsToTarget(string.Empty); Assert.AreEqual(1, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0]).NumberOfExecutions); Assert.AreEqual(0, ActiveUser.ChanneledMana); Assert.AreEqual(100, ActiveUser.CurrentMana); }
public void SetMagicUserLevelTest() { Dictionary <Dungeons_and_Dragons.Attribute, int> dict = new Dictionary <Dungeons_and_Dragons.Attribute, int>(); dict.Add(Dungeons_and_Dragons.Attribute.Strength, 15); dict.Add(Dungeons_and_Dragons.Attribute.Dexterity, 4); dict.Add(Dungeons_and_Dragons.Attribute.Intelligence, 10); dict.Add(Dungeons_and_Dragons.Attribute.Wisdom, 8); dict.Add(Dungeons_and_Dragons.Attribute.Constitution, 17); dict.Add(Dungeons_and_Dragons.Attribute.Charisma, 9); int xp = 0; int hp = 4; MagicUser magicUser = new MagicUser("Gandolf", Race.Human, dict, hp, xp); magicUser.IncreaseExperiencePoints(0); Assert.AreEqual(1, magicUser.currentLevel, "TEST1: The level is not as expected"); magicUser.IncreaseExperiencePoints(2499); Assert.AreEqual(1, magicUser.currentLevel, "TEST2: The level is not as expected"); magicUser.IncreaseExperiencePoints(1); Assert.AreEqual(2, magicUser.currentLevel, "TEST3: The level is not as expected"); magicUser.IncreaseExperiencePoints(2499); Assert.AreEqual(2, magicUser.currentLevel, "TEST4: The level is not as expected"); magicUser.IncreaseExperiencePoints(1); Assert.AreEqual(3, magicUser.currentLevel, "TEST5: The level is not as expected"); }
public void TestManaReserveUsage() { AttackContext.Owner = CreateDummyRobot(); MagicUser ActiveUser = new MagicUser(); MagicSpell ActiveSpell = new MagicSpell(ActiveUser, ActiveUser); MagicUserParams Params = new MagicUserParams(ActiveSpell.GlobalContext); ActiveUser.ManaReserves = 1000; ActiveUser.CurrentMana = 100; InvisibleMagicCoreFireball FireballCore1 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore1.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); ActiveSpell.ListMagicCore.Add(FireballCore1); ActiveSpell = new MagicSpell(ActiveSpell, ActiveUser); BaseAutomaticSkill NewSkill = ActiveSpell.ComputeSpell()[0]; for (int i = 0; i < 10; i++) { NewSkill.AddSkillEffectsToTarget(string.Empty); } Assert.AreEqual(0, ActiveUser.ChanneledMana); Assert.AreEqual(990, ActiveUser.ManaReserves); Assert.AreEqual(100, ActiveUser.CurrentMana); }
public void TestAddToCharactersInventory() { int initialItemsInInvetory = 0; int OneItemInInventory = 1; Dictionary <Dungeons_and_Dragons.Attribute, int> dict = new Dictionary <Dungeons_and_Dragons.Attribute, int>(); dict.Add(Dungeons_and_Dragons.Attribute.Strength, 12); dict.Add(Dungeons_and_Dragons.Attribute.Dexterity, 15); dict.Add(Dungeons_and_Dragons.Attribute.Intelligence, 17); dict.Add(Dungeons_and_Dragons.Attribute.Wisdom, 7); dict.Add(Dungeons_and_Dragons.Attribute.Constitution, 14); dict.Add(Dungeons_and_Dragons.Attribute.Charisma, 9); int xp = 0; int hp = 2; Character character = new MagicUser("Morris", Race.Halfling, dict, hp, xp); ShortSword shortSword = new ShortSword(); Assert.AreEqual(initialItemsInInvetory, character.inventory.Count, "TEST1: The number of items in the character's inventory is not as expected"); character.AddToCharactersInventory(shortSword); Assert.AreEqual(OneItemInInventory, character.inventory.Count, "TEST2: The number of items in the character's inventory is not as expected"); }
public void TestExplodingFireballPositionWithOffset() { AttackContext.Owner = CreateDummyRobot(); MagicUser ActiveUser = new MagicUser(); MagicSpell ActiveSpell = new MagicSpell(ActiveUser, ActiveUser); MagicUserParams Params = new MagicUserParams(ActiveSpell.GlobalContext); ActiveUser.ManaReserves = 1000; ActiveUser.CurrentMana = 100; InvisibleMagicCoreFireball FireballCore1 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore1.ListLinkedMagicElement.Add(new ChannelExternalManaSource(Params)); FireballCore1.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); InvisibleMagicCoreFireball FireballCore2 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore2.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); FireballCore2.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); FireballCore2.ListLinkedMagicElement.Add(new MagicCoreOffset(Params, AttackParams, -15, 0)); InvisibleMagicCoreFireball FireballCore3 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore3.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); FireballCore3.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); FireballCore3.ListLinkedMagicElement.Add(new MagicCoreOffset(Params, AttackParams, 55, 0)); FireballCore1.ListLinkedMagicElement.Add(FireballCore2); FireballCore1.ListLinkedMagicElement.Add(FireballCore3); ActiveSpell.ListMagicCore.Add(FireballCore1); ActiveSpell = new MagicSpell(ActiveSpell, ActiveUser); BaseAutomaticSkill NewSkill = ActiveSpell.ComputeSpell()[0]; CreateFireballEffectTripleThunder Fireball1 = (CreateFireballEffectTripleThunder)NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0]; Fireball1.ChanneledMana = 2000; NewSkill.AddSkillEffectsToTarget(string.Empty); Constants.TotalGameTime = 10; NewSkill.AddSkillEffectsToTarget(string.Empty); DummyMap.ListLayer[0].ListAttackCollisionBox[0].ListCollisionPolygon[0].Center = new Vector2(10, 10); //Channel enough Mana for 2 fireballs for (int i = 0; i < 50; i++) { DummyMap.ListLayer[0].ListAttackCollisionBox[0].Update(new GameTime(new TimeSpan(), new TimeSpan(0, 0, 0, 0, 16))); } Constants.TotalGameTime = 20; DummyMap.ListLayer[0].ListAttackCollisionBox[0].Update(new GameTime(new TimeSpan(), new TimeSpan(0, 0, 0, 50, 0))); Assert.AreEqual(0, DummyMap.ListLayer[0].ListAttackCollisionBox[0].ListCollisionPolygon[0].Center.X); Assert.AreEqual(70, DummyMap.ListLayer[0].ListAttackCollisionBox[1].ListCollisionPolygon[0].Center.X); }
public void TestExplodingFireballCreation() { MagicUser ActiveUser = new MagicUser(); MagicSpell ActiveSpell = new MagicSpell(ActiveUser, ActiveUser); MagicUserParams Params = new MagicUserParams(ActiveSpell.GlobalContext); InvisibleMagicCoreFireball FireballCore1 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore1.ListLinkedMagicElement.Add(new IncreasePower(Params)); FireballCore1.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); FireballCore1.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params)); MagicCoreEnchantlLevel1 EnchantCore = new MagicCoreEnchantlLevel1(Params); EnchantCore.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params)); FireballCore1.ListLinkedMagicElement.Add(EnchantCore); InvisibleMagicCoreFireball FireballCore2 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore2.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params)); FireballCore1.ListLinkedMagicElement.Add(FireballCore2); InvisibleMagicCoreFireball FireballCore3 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore3.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params)); FireballCore1.ListLinkedMagicElement.Add(FireballCore3); ActiveSpell.ListMagicCore.Add(FireballCore1); BaseAutomaticSkill NewSkill = new MagicSpell(ActiveSpell, ActiveUser).ComputeSpell()[0]; Assert.AreEqual("Fireball Effect", NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0].EffectTypeName); Assert.AreEqual(TimeEllapsedRequirement.Name, NewSkill.CurrentSkillLevel.ListActivation[1].ListRequirement[1].SkillRequirementName); Assert.AreEqual(3, NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0].ListFollowingSkill.Count); Assert.AreEqual("Enchant", NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0].ListFollowingSkill[0].CurrentSkillLevel.ListActivation[1].ListEffect[0].EffectTypeName); Assert.AreEqual("Fireball Effect", NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0].ListFollowingSkill[1].CurrentSkillLevel.ListActivation[1].ListEffect[0].EffectTypeName); Assert.AreEqual("Fireball Effect", NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0].ListFollowingSkill[2].CurrentSkillLevel.ListActivation[1].ListEffect[0].EffectTypeName); Assert.AreEqual(TimeEllapsedRequirement.Name, NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0].ListFollowingSkill[0].CurrentSkillLevel.ListActivation[1].ListRequirement[1].SkillRequirementName); Assert.AreEqual(TimeEllapsedRequirement.Name, NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0].ListFollowingSkill[1].CurrentSkillLevel.ListActivation[1].ListRequirement[1].SkillRequirementName); Assert.AreEqual(TimeEllapsedRequirement.Name, NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0].ListFollowingSkill[2].CurrentSkillLevel.ListActivation[1].ListRequirement[1].SkillRequirementName); }
public void TestIncreaseExperiencePoints_WithAPositive10PercentModifier() { Dictionary <Dungeons_and_Dragons.Attribute, int> dict = new Dictionary <Dungeons_and_Dragons.Attribute, int>(); dict.Add(Dungeons_and_Dragons.Attribute.Strength, 12); dict.Add(Dungeons_and_Dragons.Attribute.Dexterity, 15); dict.Add(Dungeons_and_Dragons.Attribute.Intelligence, 17); dict.Add(Dungeons_and_Dragons.Attribute.Wisdom, 7); dict.Add(Dungeons_and_Dragons.Attribute.Constitution, 14); dict.Add(Dungeons_and_Dragons.Attribute.Charisma, 9); int xp = 0; int hp = 2; Character character = new MagicUser("Morris", Race.Halfling, dict, hp, xp); character.SetExperiencePointMultiplier(10); character.IncreaseExperiencePoints(91); Assert.AreEqual(100, character.experiencePoints, "TEST1: The number of Experience Points returned was not as expected"); }
public void TestEquipToHand_WhereWeaponIsNotUseableByAMagicUser() { Dictionary <Dungeons_and_Dragons.Attribute, int> dict = new Dictionary <Dungeons_and_Dragons.Attribute, int>(); dict.Add(Dungeons_and_Dragons.Attribute.Strength, 15); dict.Add(Dungeons_and_Dragons.Attribute.Dexterity, 4); dict.Add(Dungeons_and_Dragons.Attribute.Intelligence, 10); dict.Add(Dungeons_and_Dragons.Attribute.Wisdom, 8); dict.Add(Dungeons_and_Dragons.Attribute.Constitution, 17); dict.Add(Dungeons_and_Dragons.Attribute.Charisma, 9); int xp = 0; int hp = 4; MagicUser magicUser = new MagicUser("Gandolf", Race.Human, dict, hp, xp); Sword sword = new Sword(); Assert.IsNull(magicUser.equippedInRightHand, "TEST1: It was expected that nothing should be equipped to the Magic-User's right hand"); bool val = magicUser.EquipToHand(sword, Hand.Right); Assert.IsFalse(val, "TEST2: It was expected equipping the sword to the right hand should return false"); Assert.IsNull(magicUser.equippedInRightHand, "TEST3: It was expected that the right hand is empty"); Assert.IsNull(magicUser.equippedInLeftHand, "TEST4: It was expected that the left hand is empty"); }
private INonPlayerCharacter NPC() { INonPlayerCharacter npc = new NonPlayerCharacter(); npc.Id += npcId++; npc.Level = 100; npc.KeyWords.Add("npc"); npc.ExamineDescription = "A test mob dressed in its finished lab coat."; npc.LongDescription = "A test mob performing tests."; npc.ShortDescription = "A test mob."; npc.SentenceDescription = "test"; IMagicUser magicUser = new MagicUser(); magicUser.AddSpells(npc, new Mage()); //npc.Personalities.Add(magicUser); IResponder responder = new Responder(); Response response = new Response(); response.RequiredWords.Add(new OptionalWords() { TriggerWords = new List <string>() { "hi" } }); response.Message = new TranslationMessage("hello there"); responder.Responses.Add(response); npc.Personalities.Add(responder); return(npc); }
public void TestExplodingFireballActivation() { AttackContext.Owner = CreateDummyRobot(); MagicUser ActiveUser = new MagicUser(); MagicSpell ActiveSpell = new MagicSpell(ActiveUser, ActiveUser); MagicUserParams Params = new MagicUserParams(ActiveSpell.GlobalContext); ActiveUser.ManaReserves = 1000; ActiveUser.CurrentMana = 100; InvisibleMagicCoreFireball FireballCore1 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore1.ListLinkedMagicElement.Add(new ChannelExternalManaSource(Params)); FireballCore1.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); InvisibleMagicCoreFireball FireballCore2 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore2.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); FireballCore2.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); InvisibleMagicCoreFireball FireballCore3 = new InvisibleMagicCoreFireball(Params, AttackParams); FireballCore3.ListLinkedMagicElement.Add(new ChannelInternalManaSource(Params)); FireballCore3.ListLinkedMagicElement.Add(new TriggerAfterTimeEllapsed(Params, 5)); FireballCore1.ListLinkedMagicElement.Add(FireballCore2); FireballCore1.ListLinkedMagicElement.Add(FireballCore3); ActiveSpell.ListMagicCore.Add(FireballCore1); ActiveSpell = new MagicSpell(ActiveSpell, ActiveUser); BaseAutomaticSkill NewSkill = ActiveSpell.ComputeSpell()[0]; CreateFireballEffectTripleThunder FireballEffect = (CreateFireballEffectTripleThunder)NewSkill.CurrentSkillLevel.ListActivation[1].ListEffect[0]; FireballEffect.ChanneledMana = 2000; NewSkill.AddSkillEffectsToTarget(string.Empty); Assert.AreEqual(0, DummyMap.ListLayer[0].ListAttackCollisionBox.Count); Assert.AreEqual(0, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0]).NumberOfExecutions); Assert.AreEqual(0, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0].ListLinkedMagicElement[2]).NumberOfExecutions); Assert.AreEqual(0, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0].ListLinkedMagicElement[3]).NumberOfExecutions); Constants.TotalGameTime = 10; NewSkill.AddSkillEffectsToTarget(string.Empty); Assert.AreEqual(1, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0]).NumberOfExecutions); Assert.AreEqual(0, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0].ListLinkedMagicElement[2]).NumberOfExecutions); Assert.AreEqual(0, ((InvisibleMagicCoreFireball)ActiveSpell.ListMagicCore[0].ListLinkedMagicElement[3]).NumberOfExecutions); Assert.AreEqual(1, DummyMap.ListLayer[0].ListAttackCollisionBox.Count); Assert.AreEqual(2, DummyMap.ListLayer[0].ListAttackCollisionBox[0].ListActiveSkill.Count); InvisibleFireball Fireball1 = (InvisibleFireball)DummyMap.ListLayer[0].ListAttackCollisionBox[0]; IMagicUser FireballParent = Fireball1.Parent; //Channel enough Mana for 2 fireballs for (int i = 0; i < 50; i++) { DummyMap.ListLayer[0].ListAttackCollisionBox[0].Update(new GameTime(new TimeSpan(), new TimeSpan(0, 0, 0, 0, 16))); Assert.AreEqual(2000 - i * 2, FireballParent.CurrentMana); } Constants.TotalGameTime = 20; Assert.AreEqual(true, DummyMap.ListLayer[0].ListAttackCollisionBox.Contains(Fireball1)); DummyMap.ListLayer[0].ListAttackCollisionBox[0].Update(new GameTime(new TimeSpan(), new TimeSpan(0, 0, 0, 50, 0))); Assert.AreEqual(false, DummyMap.ListLayer[0].ListAttackCollisionBox.Contains(Fireball1)); Assert.AreEqual(2, DummyMap.ListLayer[0].ListAttackCollisionBox.Count); }