Exemple #1
0
        public void TestSkillChange(SkillName skillName, int baseFixedPoint, int capFixedPoint)
        {
            // TODO: Eliminate all of this and just create a Skill directly
            var m = new Mobile(0x1);

            m.DefaultMobileInit();

            var skill = m.Skills[skillName];

            skill.BaseFixedPoint = baseFixedPoint;
            skill.CapFixedPoint  = capFixedPoint;

            var data = new SkillChange(skill).Compile();

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

            expectedData.Write(ref pos, (byte)0x3A); // Packet ID
            expectedData.Write(ref pos, (ushort)13); // Length
            expectedData.Write(ref pos, (byte)0xDF); // type: delta, capped

            var v  = skill.NonRacialValue;
            var uv = Math.Clamp((int)(v * 10), 0, 0xFFFF);

            expectedData.Write(ref pos, (ushort)skill.Info.SkillID);
            expectedData.Write(ref pos, (ushort)uv);
            expectedData.Write(ref pos, (ushort)skill.BaseFixedPoint);
            expectedData.Write(ref pos, (byte)skill.Lock);
            expectedData.Write(ref pos, (ushort)skill.CapFixedPoint);

            AssertThat.Equal(data, expectedData);
        }
        public void TestSkillChange(SkillName skillName, int baseFixedPoint, int capFixedPoint)
        {
            var m = new Mobile(0x1);

            m.DefaultMobileInit();

            var skill = m.Skills[skillName];

            skill.BaseFixedPoint = baseFixedPoint;
            skill.CapFixedPoint  = capFixedPoint;

            var expected = new SkillChange(skill).Compile();

            using var ns = PacketTestUtilities.CreateTestNetState();
            ns.SendSkillChange(skill);

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

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