static void Accept(TestCharacter leader, TestCharacter accepter) { // adding the new member: var newGroup = leader.Group == null; var packet = new RealmPacketOut(RealmServerOpCode.CMSG_GROUP_ACCEPT); accepter.FakeClient.ReceiveCMSG(packet, true); Assert.IsNotNull(leader.Group, "Leader was not in a group after invitation was accepted: " + leader); Assert.IsNotNull(accepter.Group, "New member is not in a group after accepting invitation: " + accepter); Assert.AreEqual(leader.Group, accepter.Group, "Leader and invited member are not in the same Group: {0} != {1}", leader.Group, accepter.Group); if (newGroup) { var packetInfo1 = leader.FakeClient.DequeueSMSGInfo(RealmServerOpCode.SMSG_GROUP_LIST); // New Group: First list is sent to the creator Assert.AreEqual(leader.FakeClient, packetInfo1.Client); var response1 = packetInfo1.Parser.ParsedPacket; // should only contain the new member var member1 = response1["Members"][0]["MemberName"].StringValue; Assert.AreEqual(accepter.Name, member1); Assert.AreEqual(leader.EntityId, response1["Leader"].EntityIdValue); } var packetInfo = accepter.FakeClient.DequeueSMSGInfo(RealmServerOpCode.SMSG_GROUP_LIST); var response = packetInfo.Parser.ParsedPacket; // leader comes first (usually) var member = response["Members"][0]["MemberName"].StringValue; Assert.AreEqual(leader.Name, member); }
public static Group CreateGroup(int count) { var pool = Setup.AllianceCharacterPool; pool.EnsureLiving = true; var members = new TestCharacter[count]; var leader = members[0] = pool.Create(); Asser.GreaterThan(count, 1); // invite leader.EnsureInWorldAndLiving(); for (uint i = 1; i < count; i++) { members[i] = pool.Create(); members[i].EnsureInWorldAndLiving(); Invite(leader, members[i]); } // accept for (uint i = 1; i < count; i++) { Accept(leader, members[i]); Assert.AreEqual(members[i].GroupMember, members[i - 1].GroupMember.Next); } var group = leader.Group; Assert.AreEqual(count, group.CharacterCount); return(group); }
public ICharacter CreateCharacter(int id) { var character = new TestCharacter(3, 2, costs[costIndex]); ++costIndex; return(character); }
private void EnsureChar(ref TestCharacter chr, CharacterPool pool) { chr = pool.Create(); chr.SetMoney(100000); chr.GodMode = true; chr.EnsureInWorldAndLiving(); }
public static void SendInvitePacket(TestCharacter inviter, string inviteeName) { var packet = new RealmPacketOut(RealmServerOpCode.CMSG_GROUP_INVITE); packet.WriteCString(inviteeName); inviter.FakeClient.ReceiveCMSG(packet, true); }
public static void Initialize(TestContext testContext) { Setup.EnsureBasicSetup(); Setup.EnsureItemsLoaded(); chr1 = Setup.AllianceCharacterPool.Create(); chr2 = Setup.AllianceCharacterPool.Create(); }
public IdleState(TestCharacterStateManager mgr) : base(mgr) { character = mgr.CharacterBase as TestCharacter; characterStateManager = mgr; Debug.LogError("IdleState : " + character.tag); }
public void CreateEnemyTeam() { for (int i = 0; i < team.Length; i++) { team[i] = new TestCharacter(); team[i].charType = CharacterType.Enemy; } }
public void GetMail(TestCharacter getter) { using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_GET_MAIL_LIST)) { packet.Write(EntityId.Zero); getter.FakeClient.ReceiveCMSG(packet, true); } }
public void TestBasicFunctionality() { Lua lua = new Lua(); //// //TestLuaFunctions testLuaFunctions = new TestLuaFunctions(); //lua.RegisterFunction("Say", testLuaFunctions, testLuaFunctions.GetType().GetMethod("Say")); //lua.RegisterFunction("CreateInstance", typeof(TestLuaFunctions).GetMethod("CreateInstance")); //lua.DoString("Say('pouet')"); //lua.DoString("instance = CreateInstance()"); //lua.DoString("instance:Say('woohoo')"); //TestLuaFunctions externalInstance = (TestLuaFunctions) lua["instance"]; //externalInstance.Say("using externally created instance to call Say"); // CreateWorld(); ITestCharacter testCharacter = TestCharacter.Create(); lua["testcharacter"] = testCharacter; lua.RegisterFunction("print", typeof(LuaOutput).GetMethod("Print")); //lua["this"] = bigBadMob; //lua["room"] = DependencyContainer.Instance.GetInstance<IWorld>().Rooms.First(); lua.RegisterFunction("getCharacter", this, GetType().GetMethod("GetCharacter")); lua.DoString( @"print('this is a debug message') local this = getCharacter() cName = this.DisplayName function luanet.each(o) local e = o:GetEnumerator() return function() if e:MoveNext() then return e.Current end end end local each = luanet.each; for c in each(this.Room.People) do local name = c == getCharacter() and 'me' or c.DisplayName; print('in room:'..name); end -- local globals = _G --for g in each(globals) do -- print('global:'..tostring(g)); --end"); //doesn't work lua.DoString("function this.pouet(s) print(s) end"); var cName = lua["cName"]; var luanet = lua["luanet"]; var globals = lua["_G"]; var testCharacter2 = lua["testcharacter"]; lua.Close(); }
/* * TODO - testing method, all pawn translation should happen using level logic, the setWorldPosition are just helper methods, so a level * should keep track of moving pawns, and what chunks or regions they are contained within. */ public static void CreateTestCharacterAtWorldPosition(Level level, Vector3 pos) { TestCharacter pawn = new TestCharacter(); pawn.construct(); pawn.setLevelContainer(level); pawn.init(); pawn.setWorldPosition(pos); }
static void Accept(TestCharacter leader, TestCharacter accepter) { var packet = new RealmPacketOut(RealmServerOpCode.CMSG_GUILD_ACCEPT); accepter.FakeClient.ReceiveCMSG(packet, true); // adding the new member: Assert.IsNotNull(leader.Guild); Assert.AreEqual(leader.Guild, accepter.Guild); }
public TestCharacterStateManager(TestCharacter character) : base() { IdleState = new IdleState(this); if (character != null) { CharacterBase = character; } }
void EnsureChar(ref TestCharacter chr, CharacterPool pool) { //if (chr == null || chr.IsInWorld) { chr = pool.Create(); chr.SetMoney(100000); chr.GodMode = true; chr.EnsureInWorldAndLiving(); } }
static void Invite(TestCharacter inviter, TestCharacter invitee) { SendInvitePacket(inviter, invitee.Name); // invited notification var parsedPacket = inviter.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_GUILD_COMMAND_RESULT); var inviteeName = parsedPacket["Name"].StringValue; Assert.AreEqual(invitee.Name, inviteeName); Assert.AreEqual(GuildResult.SUCCESS, parsedPacket["ResultCode"].Value, inviter + " failed to invite " + invitee); }
public static void Initialize(TestContext testContext) { // register the test packet handlers FakePacketMgr.Instance.Register(typeof(FakeClientTest)); RealmPacketMgr.Instance.Register(typeof(FakeClientTest)); Setup.EnsureBasicSetup(); m_chr = Setup.DefaultCharacter; m_chr.EnsureInWorld(); }
public static void Init(TestContext testContext) { chr = Setup.AllianceCharacterPool.Create(); client = chr.FakeClient; disenchantSpell = SpellHandler.Get(SpellId.DisenchantPT); disenchantSpell.CastDelay = 0; // we don't want to wait ItemMgr.LoadAll(); //LootMgr.LoadAll(); ContentMgr.Load <ItemLootItemEntry>(); }
public void Test_CharacterInteraction1() { TestCharacter testCharacter = new TestCharacter(); testCharacter.InitChar(true); GetPlayerManager.AddCharacterToList(testCharacter.m_Character); Debug.Log("Test Character made and added to the character list"); Debug.Log(testCharacter.m_Character.GetCharacterName() + ": has health stat of " + testCharacter.m_Character.GetCharacterHealth()); testCharacter.m_Character.ListUsableActions(); }
private static void VerifyMailSent(TestCharacter sender, TestCharacter receiver) { var mailResult = sender.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_SEND_MAIL_RESULT); Assert.IsNotNull(mailResult); var error = mailResult["Error"].Value; Assert.AreEqual(MailError.OK, error); var mailNotification = receiver.FakeClient.DequeueSMSGInfo(RealmServerOpCode.SMSG_RECEIVED_MAIL); Assert.IsNotNull(mailNotification); }
public void Test_AffixInteraction() { TestAffix1 testAffix1 = new TestAffix1(); testAffix1.InitAffix(); ActionData.AFFIX_DICTIONARY.Add(ActionData.AFFIX_LIST_ID.TEST_AFFIX_1, testAffix1); TestAction1 testAction1 = new TestAction1(); testAction1.SetInitPropertiesSelfTarget(); ActionData.ABILITY_DICTIONARY.Add(ActionData.ACTION_LIST_ID.ATTACK_BASIC, testAction1); Test_ListAllAffixesInDictionary(); TestCharacter testChar1 = new TestCharacter(); testChar1.InitChar(true); TestCharacter testChar2 = new TestCharacter(); testChar2.InitChar(false); testChar2.m_Character.SetCharacterName("Enemy Test"); GetPlayerManager.AddCharacterToList(testChar1.m_Character); GetPlayerManager.AddCharacterToList(testChar2.m_Character); PerformActionDataModel testDataModel = new PerformActionDataModel(ActionData.ACTION_LIST_ID.ATTACK_BASIC, GenericActionModel.ACTION_TARGET_AMOUNT.SINGLE_TARGET, testChar1.m_Character, testChar2.m_Character); GetCombatManager.ProcessAction(testDataModel); for (int i = 0; i < GetPlayerManager.GetCharacterList().Count; i++) { Debug.Log("Health - " + GetPlayerManager.GetCharacterList()[i].GetCharacterName() + " : " + GetPlayerManager.GetCharacterList()[i].GetCharacterHealth()); } GetCombatManager.ProcessAffix(); Debug.Log("Affixes Processed"); for (int i = 0; i < GetPlayerManager.GetCharacterList().Count; i++) { Debug.Log("Health - " + GetPlayerManager.GetCharacterList()[i].GetCharacterName() + " : " + GetPlayerManager.GetCharacterList()[i].GetCharacterHealth()); } Debug.Log("Test Case Over"); }
public void Test_CharacterInteraction2() { TestCharacter testChar1 = new TestCharacter(); testChar1.InitChar(true); TestCharacter testChar2 = new TestCharacter(); testChar2.InitChar(false); testChar2.m_Character.SetCharacterName("Enemy Test"); PerformActionDataModel testDataModel = new PerformActionDataModel(ActionData.ACTION_LIST_ID.ATTACK_BASIC, GenericActionModel.ACTION_TARGET_AMOUNT.SINGLE_TARGET, testChar1.m_Character, testChar2.m_Character); GetCombatManager.ProcessAction(testDataModel); }
static void Invite(TestCharacter inviter, TestCharacter invitee) { SendInvitePacket(inviter, invitee.Name); var relation = inviter.GetRelationTo(invitee, CharacterRelationType.GroupInvite); Assert.IsNotNull(relation, "Invitation ({0} -> {1}) was not issued", inviter, invitee); // invited notification var parsedPacket = inviter.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_PARTY_COMMAND_RESULT); Assert.IsNotNull(parsedPacket, "SMSG_PARTY_COMMAND_RESULT was not sent"); var inviteeName = parsedPacket["Name"].StringValue; Assert.AreEqual(invitee.Name, inviteeName); Assert.AreEqual(GroupResult.NoError, parsedPacket["Result"].Value); }
public static Guild CreateGuild(int count) { var pool = Setup.AllianceCharacterPool; pool.EnsureLiving = true; Asser.GreaterThan(count, 1); // create leader.EnsureInWorldAndLiving(); leader.EnsureNoGuild(); new Guild(leader.Record, "TestGuild " + Utility.Random(1, 1000)); var guild = leader.Guild; Assert.IsNotNull(guild); // invite var members = new TestCharacter[count - 1]; for (uint i = 1; i < count; i++) { var member = members[i - 1] = pool.Create(); member.EnsureInWorldAndLiving(); member.EnsureNoGuild(); Invite(leader, member); } // accept for (uint i = 1; i < count; i++) { var member = members[i - 1]; Accept(leader, member); var character = member; var guildMember = guild[character.Name]; Assert.IsNotNull(guildMember); } Assert.AreEqual(count, guild.MemberCount); return(guild); }
public void SendMail(TestCharacter sender, string receiver, string subject, List <ItemRecord> items, uint money, uint cod) { using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_SEND_MAIL)) { packet.Write(EntityId.Zero); packet.Write(receiver); packet.Write(subject); packet.Write("Mail Content"); packet.Write((uint)MailStationary.Normal); //Unknown1 packet.Write((uint)0); if (items != null) { //Number of Items packet.Write((byte)items.Count); // TODO: Items + Enchants etc for (int i = 0; i < items.Count; i++) { //Slot Number packet.Write((byte)i); //Item EntityId packet.Write(items[i].EntityId); } } else { packet.Write((byte)0); } //Money packet.Write(money); //COD packet.Write(cod); //Unknown2 packet.Write((uint)0); //Unknown3 packet.Write((uint)0); sender.FakeClient.ReceiveCMSG(packet, true); } }
public static void ApplyAura(TestCharacter chr, Spell spell) { Assert.IsTrue(spell.IsAura || spell.IsAreaAura, "Spell {0} is not an Aura", spell); chr.EnsureInWorld(); chr.ShapeshiftForm = ShapeshiftForm.Normal; chr.Auras.Clear(); Assert.AreEqual(0, chr.Auras.Count); // important: Execute this in the Map's thread chr.Map.AddMessageAndWait(new Message(() => { chr.SpellCast.TriggerSelf(spell); var failure = chr.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_SPELL_FAILURE); Assert.IsNull(failure, failure != null ? "Spell failed: " + failure["FailReason"].Value : ""); Assert.AreEqual(1, chr.Auras.Count, "Aura was not added."); var aura = chr.Auras[spell, !spell.HasHarmfulEffects]; Assert.IsNotNull(aura); Assert.AreEqual(spell.GetDuration(chr.SharedReference, chr), (uint)aura.Duration); Assert.AreNotEqual(0, spell.GetDuration(chr.SharedReference, chr)); Asser.GreaterOrEqual(spell.GetDuration(chr.SharedReference, chr), (uint)aura.TimeLeft); aura.Cancel(); Assert.IsNull(chr.Auras[spell, !spell.HasHarmfulEffects]); Assert.AreEqual(0, chr.Auras.Count); })); }
public void Test_ActionInteraction() { TestCharacter testChar1 = new TestCharacter(); testChar1.InitChar(true); testChar1.m_Character.SetCharacterName("Player"); TestCharacter testChar2 = new TestCharacter(); testChar2.InitChar(false); TestCharacter testChar3 = new TestCharacter(); testChar3.InitChar(false); GetPlayerManager.AddCharacterToList(testChar1.m_Character); GetPlayerManager.AddCharacterToList(testChar2.m_Character); GetPlayerManager.AddCharacterToList(testChar3.m_Character); PerformActionDataModel testActionSelfTarget = new PerformActionDataModel(ActionData.ACTION_LIST_ID.SHIELD_ONE, GenericActionModel.ACTION_TARGET_AMOUNT.SINGLE_TARGET, testChar1.m_Character); PerformActionDataModel testActionAllTarget = new PerformActionDataModel(ActionData.ACTION_LIST_ID.ATTACK_ONE, GenericActionModel.ACTION_TARGET_AMOUNT.ALL_TARGETS, testChar1.m_Character); PerformActionDataModel testActionMultiOffensive = new PerformActionDataModel(ActionData.ACTION_LIST_ID.ATTACK_TWO, GenericActionModel.ACTION_TARGET_AMOUNT.MULTI_TARGET_OFFENSIVE, testChar1.m_Character); PerformActionDataModel testActionMultiDefensive = new PerformActionDataModel(ActionData.ACTION_LIST_ID.SHIELD_TWO, GenericActionModel.ACTION_TARGET_AMOUNT.MULTI_TARGET_DEFENSIVE, testChar1.m_Character); GetCombatManager.ProcessAction(testActionSelfTarget); GetCombatManager.ProcessAction(testActionAllTarget); GetCombatManager.ProcessAction(testActionMultiOffensive); GetCombatManager.ProcessAction(testActionMultiDefensive); for (int i = 0; i < GetPlayerManager.GetCharacterList().Count; i++) { Debug.Log("Health - " + GetPlayerManager.GetCharacterList()[i].GetCharacterName() + " : " + GetPlayerManager.GetCharacterList()[i].GetCharacterHealth()); } Debug.Log("Test Case Over"); }
public void SendMail(TestCharacter sender, TestCharacter receiver, string subject, List <ItemRecord> items, uint money, uint cod) { SendMail(sender, receiver.Name, subject, items, money, cod); }
/// <summary> /// Also temporarily sets godmode /// </summary> public void SendMail(TestCharacter sender, TestCharacter receiver, string subject, List <ItemRecord> items) { SendMail(sender, receiver, subject, items, 0, 0); }
/// <summary> /// Also temporarily sets godmode /// </summary> public void SendMail(TestCharacter sender, TestCharacter receiver, string subject) { SendMail(sender, receiver, subject, null); }
public void SendMail(TestCharacter sender, TestCharacter receiver) { SendMail(sender, receiver, "Mail Subject"); }