예제 #1
0
 private static void EnsureChar(ref TestCharacter chr, CharacterPool pool)
 {
     chr = pool.Create();
     chr.SetMoney(100000);
     chr.GodMode = true;
     chr.EnsureInWorldAndLiving();
 }
예제 #2
0
        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;
        }
예제 #3
0
        public void SendRequest(TestCharacter sender, uint minLevel, uint maxLevel, string playerName,
                                string guildName, RaceMask2 raceMask, ClassMask2 classMask, List <ZoneId> zones, List <string> names)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_WHO))
            {
                packet.WriteUInt(minLevel);
                packet.WriteUInt(maxLevel);
                packet.WriteCString(playerName);
                packet.WriteCString(guildName);
                packet.WriteUInt((uint)raceMask);
                packet.WriteUInt((uint)classMask);

                packet.WriteUInt(zones.Count);
                foreach (ZoneId zone in zones)
                {
                    packet.WriteUInt((uint)zone);
                }

                packet.WriteUInt(names.Count);
                foreach (string name in names)
                {
                    packet.WriteCString(name);
                }

                sender.FakeClient.ReceiveCMSG(packet, true);
            }
        }
예제 #4
0
        public static void Initialize(TestContext testContext)
        {
            Setup.EnsureBasicSetup();
            Setup.EnsureItemsLoaded();

            chr1 = Setup.AllianceCharacterPool.Create();
            chr2 = Setup.AllianceCharacterPool.Create();
        }
예제 #5
0
 public void GetMail(TestCharacter getter)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_GET_MAIL_LIST))
     {
         packet.Write(EntityId.Zero);
         getter.FakeClient.ReceiveCMSG(packet, true);
     }
 }
예제 #6
0
        public CharacterRecord AddRecord()
        {
            var record = Setup.CreateCharRecord();

            ArchetypeMgr.EnsureInitialize();
            TestCharacter.PrepareRecord(this, record,
                                        ArchetypeMgr.GetArchetype(RaceId.Human, ClassId.Warrior), true);
            Characters.Add(record);
            return(record);
        }
예제 #7
0
파일: MailTests.cs 프로젝트: pallmall/WCell
		void EnsureChar(ref TestCharacter chr, CharacterPool pool)
		{
			//if (chr == null || chr.IsInWorld)
			{
				chr = pool.Create();
				chr.SetMoney(100000);
				chr.GodMode = true;
				chr.EnsureInWorldAndLiving();
			}
		}
예제 #8
0
		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>();
		}
예제 #9
0
        public void TestClassInitialize()
        {
            CharacterPool.RemoveAllChars();

            foreach (var chr in World.GetAllCharacters())
            {
                World.RemoveCharacter(chr);
            }

            _allianceChar1       = Setup.AllianceCharacterPool.Create();
            _allianceChar1.Class = WCell.Constants.ClassId.Priest;
            _allianceChar1.Race  = WCell.Constants.RaceId.Draenei;
            _allianceChar1.SetName("AllianceChar1");
            _allianceChar1.Level = 1;
            _allianceChar1.EnsureInWorld();

            _allianceChar2       = Setup.AllianceCharacterPool.Create();
            _allianceChar2.Class = WCell.Constants.ClassId.Druid;
            _allianceChar2.Race  = WCell.Constants.RaceId.NightElf;
            _allianceChar2.SetName("AllianceChar2");
            _allianceChar2.Level = 2;
            _allianceChar2.EnsureInWorld();

            _allianceChar3       = Setup.AllianceCharacterPool.Create();
            _allianceChar3.Class = WCell.Constants.ClassId.Paladin;
            _allianceChar3.Race  = WCell.Constants.RaceId.Human;
            _allianceChar3.SetName("AllianceChar3");
            _allianceChar3.Level = 3;
            _allianceChar3.EnsureInWorld();

            _hordeChar1       = Setup.HordeCharacterPool.Create();
            _hordeChar1.Class = WCell.Constants.ClassId.Druid;
            _hordeChar1.Race  = WCell.Constants.RaceId.Tauren;
            _hordeChar1.SetName("HordeChar1");
            _hordeChar1.Level = 1;
            _hordeChar1.EnsureInWorld();

            _hordeChar2       = Setup.HordeCharacterPool.Create();
            _hordeChar2.Class = WCell.Constants.ClassId.Paladin;
            _hordeChar2.Race  = WCell.Constants.RaceId.BloodElf;
            _hordeChar2.SetName("HordeChar2");
            _hordeChar2.Level = 2;
            _hordeChar2.EnsureInWorld();

            _hordeChar3       = Setup.HordeCharacterPool.Create();
            _hordeChar3.Class = WCell.Constants.ClassId.Warlock;
            _hordeChar3.Race  = WCell.Constants.RaceId.Undead;
            _hordeChar3.SetName("HordeChar3");
            _hordeChar3.Level = 3;
            _hordeChar3.EnsureInWorld();
        }
예제 #10
0
        public static TestCharacter CreateChar(bool isNew, Archetype archetype)
        {
            if (isNew)
            {
                Setup.EnsureBasicSetup();
            }
            else
            {
                // load items from DB -> Items need to be initialized
                Setup.EnsureItemsLoaded();
            }
            var chr = new TestCharacter(archetype, isNew);

            //chr.Load(); TODO: Fix this!
            return(chr);
        }
예제 #11
0
        void OnCreate(TestCharacter chr)
        {
            m_count++;

            if (EnsureLiving)
            {
                chr.EnsureLiving();
            }

            if (EnsureSameMap)
            {
                chr.TeleportTo(Setup.Kalimdor, true);
            }
            else            // if (!InWorld)
            {
                InWorld = true;
            }
        }
예제 #12
0
        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;
        }
예제 #13
0
        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);
            }));
        }
예제 #14
0
        public void SendRequest(TestCharacter sender, uint minLevel, uint maxLevel, string playerName, 
			string guildName, RaceMask2 raceMask, ClassMask2 classMask, List<ZoneId> zones, List<string> names)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_WHO))
            {
                packet.WriteUInt(minLevel);
                packet.WriteUInt(maxLevel);
                packet.WriteCString(playerName);
                packet.WriteCString(guildName);
                packet.WriteUInt((uint)raceMask);
                packet.WriteUInt((uint)classMask);

                packet.WriteUInt(zones.Count);
                foreach (ZoneId zone in zones)
                    packet.WriteUInt((uint)zone);

                packet.WriteUInt(names.Count);
                foreach (string name in names)
                    packet.WriteCString(name);

                sender.FakeClient.ReceiveCMSG(packet, true);
            }
        }
예제 #15
0
파일: MailTests.cs 프로젝트: pallmall/WCell
		/// <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);
		}
예제 #16
0
파일: MailTests.cs 프로젝트: pallmall/WCell
		/// <summary>
		/// Also temporarily sets godmode
		/// </summary>
		public void SendMail(TestCharacter sender, TestCharacter receiver, string subject)
		{
			SendMail(sender, receiver, subject, null);
		}
예제 #17
0
파일: MailTests.cs 프로젝트: pallmall/WCell
		public void SendMail(TestCharacter sender, TestCharacter receiver)
		{
			SendMail(sender, receiver, "Mail Subject");
		}
예제 #18
0
        void OnCreate(TestCharacter chr)
        {
            m_count++;

            if (EnsureLiving)
            {
                chr.EnsureLiving();
            }

            if (EnsureSameMap)
            {
                chr.TeleportTo(Setup.Kalimdor, true);
            }
            else// if (!InWorld)
            {
                InWorld = true;
            }
        }
예제 #19
0
        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);
        }
예제 #20
0
		public static TestCharacter CreateChar(bool isNew, Archetype archetype)
		{
			if (isNew)
			{
				Setup.EnsureBasicSetup();
			}
			else
			{
				// load items from DB -> Items need to be initialized
				Setup.EnsureItemsLoaded();
			}
			var chr = new TestCharacter(archetype, isNew);
			//chr.Load(); TODO: Fix this!
			return chr;
		}
예제 #21
0
		public static void Initialize(TestContext testContext)
		{
			chr = Setup.AllianceCharacterPool.Create();
		}
예제 #22
0
파일: MailTests.cs 프로젝트: pallmall/WCell
		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);
		}
예제 #23
0
파일: MailTests.cs 프로젝트: pallmall/WCell
		public void SendMail(TestCharacter sender, TestCharacter receiver, string subject, List<ItemRecord> items, uint money, uint cod)
		{
			SendMail(sender, receiver.Name, subject, items, money, cod);
		}
예제 #24
0
        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);
        }
예제 #25
0
        public void TestClassInitialize()
        {
            CharacterPool.RemoveAllChars();

            foreach (var chr in World.GetAllCharacters())
            {
                World.RemoveCharacter(chr);
            }

            _allianceChar1 = Setup.AllianceCharacterPool.Create();
            _allianceChar1.Class = WCell.Constants.ClassId.Priest;
            _allianceChar1.Race = WCell.Constants.RaceId.Draenei;
            _allianceChar1.SetName("AllianceChar1");
            _allianceChar1.Level = 1;
            _allianceChar1.EnsureInWorld();

            _allianceChar2 = Setup.AllianceCharacterPool.Create();
            _allianceChar2.Class = WCell.Constants.ClassId.Druid;
            _allianceChar2.Race = WCell.Constants.RaceId.NightElf;
            _allianceChar2.SetName("AllianceChar2");
            _allianceChar2.Level = 2;
            _allianceChar2.EnsureInWorld();

            _allianceChar3 = Setup.AllianceCharacterPool.Create();
            _allianceChar3.Class = WCell.Constants.ClassId.Paladin;
            _allianceChar3.Race = WCell.Constants.RaceId.Human;
            _allianceChar3.SetName("AllianceChar3");
            _allianceChar3.Level = 3;
            _allianceChar3.EnsureInWorld();

            _hordeChar1 = Setup.HordeCharacterPool.Create();
            _hordeChar1.Class = WCell.Constants.ClassId.Druid;
            _hordeChar1.Race = WCell.Constants.RaceId.Tauren;
            _hordeChar1.SetName("HordeChar1");
            _hordeChar1.Level = 1;
            _hordeChar1.EnsureInWorld();

            _hordeChar2 = Setup.HordeCharacterPool.Create();
            _hordeChar2.Class = WCell.Constants.ClassId.Paladin;
            _hordeChar2.Race = WCell.Constants.RaceId.BloodElf;
            _hordeChar2.SetName("HordeChar2");
            _hordeChar2.Level = 2;
            _hordeChar2.EnsureInWorld();

            _hordeChar3 = Setup.HordeCharacterPool.Create();
            _hordeChar3.Class = WCell.Constants.ClassId.Warlock;
            _hordeChar3.Race = WCell.Constants.RaceId.Undead;
            _hordeChar3.SetName("HordeChar3");
            _hordeChar3.Level = 3;
            _hordeChar3.EnsureInWorld();
        }
예제 #26
0
파일: MailTests.cs 프로젝트: pallmall/WCell
		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);
			}
		}
예제 #27
0
파일: GroupTest.cs 프로젝트: pallmall/WCell
		public static void SendInvitePacket(TestCharacter inviter, string inviteeName)
		{
			var packet = new RealmPacketOut(RealmServerOpCode.CMSG_GROUP_INVITE);
			packet.WriteCString(inviteeName);

			inviter.FakeClient.ReceiveCMSG(packet, true);
		}
예제 #28
0
파일: GroupTest.cs 프로젝트: pallmall/WCell
		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);
		}
예제 #29
0
파일: GroupTest.cs 프로젝트: pallmall/WCell
		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);
		}
예제 #30
0
		void OnCreate(TestCharacter chr)
		{
			m_count++;

			if (EnsureLiving)
			{
				chr.EnsureLiving();
			}
			if (EnsureSameRegion)
			{
				chr.TeleportTo(Setup.Kalimdor, true);
			}
			else if (EnsureInWorld)
			{
				chr.EnsureInWorld();
			}
		}
예제 #31
0
        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();
        }
예제 #32
0
		/// <summary>
		/// Adds the given amount of Characters next to each other in Kalimdor
		/// </summary>
		public TestCharacter[] AddCharacters(int num)
		{
			var region = Setup.Kalimdor;
			var added = 0;

			if (DefaultIsNew)
			{
				Setup.EnsureBasicSetup();
			}
			else
			{
				Setup.EnsureItemsLoaded();
			}
			GC.Collect();

			var chars = new TestCharacter[num];
			for (uint index = 0; index < num; index++)
			{
				ThreadPool.QueueUserWorkItem((iObj) =>
				{
					var i = (uint)iObj;

					var chr = Create();
					chr.SetName("Char" + charNum++);

					// abuse entryid as identifier
					chr.SetUInt32(ObjectFields.ENTRY, i + 1);

					chars[i] = chr;

					region.AddMessage(new Message(() =>
					{
						var pos = Setup.DefaultPosition;
						region.AddObjectNow(chr, ref pos);

						added++;

						if (added == num)
						{
							lock (chars)
							{
								Monitor.Pulse(chars);
							}
						}
					}));
				}, index);
			}

			lock (chars)
			{
				// wait until all chars have been added
				Monitor.Wait(chars);
			}

			Thread.Sleep(Region.CharacterUpdateEnvironmentTicks * Region.DefaultUpdateDelay);

			// wait three more ticks on the region to let all pending updates process
			chars.Last().Region.WaitTicks(3);

			Setup.WriteRamUsage("Added {0} Characters", num);

			return chars;
		}
예제 #33
0
        /// <summary>
        /// Adds the given amount of Characters next to each other in Kalimdor
        /// </summary>
        public TestCharacter[] AddCharacters(int num)
        {
            var map   = Setup.Kalimdor;
            var added = 0;

            if (DefaultIsNew)
            {
                Setup.EnsureBasicSetup();
            }
            else
            {
                Setup.EnsureItemsLoaded();
            }
            GC.Collect();

            var chars = new TestCharacter[num];

            for (uint index = 0; index < num; index++)
            {
                ThreadPool.QueueUserWorkItem((iObj) =>
                {
                    var i = (uint)iObj;

                    var chr = Create();
                    chr.SetName("Char" + charNum++);

                    // abuse entryid as identifier
                    chr.SetUInt32(ObjectFields.ENTRY, i + 1);

                    chars[i] = chr;

                    map.AddMessage(new Message(() =>
                    {
                        var pos = Setup.DefaultPosition;
                        map.AddObjectNow(chr, ref pos);

                        added++;

                        if (added == num)
                        {
                            lock (chars)
                            {
                                Monitor.Pulse(chars);
                            }
                        }
                    }));
                }, index);
            }

            lock (chars)
            {
                // wait until all chars have been added
                Monitor.Wait(chars);
            }

            Thread.Sleep(Map.CharacterUpdateEnvironmentTicks * Map.DefaultUpdateDelay);

            // wait three more ticks on the map to let all pending updates process
            chars.Last().Map.WaitTicks(3);

            Setup.WriteRamUsage("Added {0} Characters", num);

            return(chars);
        }