Beispiel #1
0
        public void TestMobileStatusCompact()
        {
            var m = new Mobile(0x1);

            m.DefaultMobileInit();

            var canBeRenamed = false;

            var data = new MobileStatusCompact(canBeRenamed, m).Compile();

            Span <byte> expectedData = stackalloc byte[43];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0x11);                  // Packet ID
            expectedData.Write(ref pos, (ushort)expectedData.Length); // Length

            expectedData.Write(ref pos, m.Serial);
            expectedData.WriteAsciiFixed(ref pos, m.Name ?? "", 30);

            expectedData.WriteReverseAttribute(ref pos, m.Hits, m.HitsMax, true);
            expectedData.Write(ref pos, canBeRenamed);

#if NO_LOCAL_INIT
            expectedData.Write(ref pos, (byte)0); // type
#endif

            AssertThat.Equal(data, expectedData);
        }
Beispiel #2
0
        public void TestMobileStatusCompact(bool canBeRenamed)
        {
            var m = new Mobile(0x1)
            {
                Name = "Random Mobile 1"
            };

            m.DefaultMobileInit();
            m.Str  = 50;
            m.Hits = 100;
            m.Int  = 75;
            m.Mana = 100;
            m.Dex  = 25;
            m.Stam = 100;

            var expected = new MobileStatusCompact(canBeRenamed, m).Compile();

            var ns = PacketTestUtilities.CreateTestNetState();

            ns.SendMobileStatusCompact(m, canBeRenamed);

            var result = ns.SendPipe.Reader.TryRead();

            AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
        }