ModernUO/Projects/UOContent.Tests/Tests/Misc/CorpseNotorietyTests.cs
Kamron Batman 92ed9c5456
fix: player corpse notoriety ignores the owner's body at death (#2669)
CorpseNotoriety returned Murderer for a player corpse whenever the corpse body was a monster
body. RunUO's check was `body.IsMonster && IsSummoned(owner)`, which is never true for a player;
the second half was lost when the branch was simplified (#134). Players who died while
polymorphed or in a necromancer form left a corpse with the wrong notoriety.

Player corpses also check murderer and criminal status before guild standing again, matching
RunUO and MobileNotoriety.

Tests: UOContent.Tests 1162 passed (4 new CorpseNotorietyTests).
2026-09-23 19:43:37 -07:00

40 lines
1.1 KiB
C#

using Server;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Xunit;
namespace UOContent.Tests;
[Collection("Sequential UOContent Tests")]
public class CorpseNotorietyTests
{
[Theory]
[InlineData(0, Notoriety.Innocent)] // Human body
[InlineData(746, Notoriety.Innocent)] // Horrific Beast, a monster body
[InlineData(0, Notoriety.Murderer, 5)]
[InlineData(746, Notoriety.Murderer, 5)]
public void PlayerCorpseNotorietyIgnoresTransformedBody(int bodyMod, int expected, int kills = 0)
{
var victim = new PlayerMobile(World.NewMobile);
victim.DefaultMobileInit();
victim.Kills = kills;
victim.BodyMod = bodyMod;
var looter = new PlayerMobile(World.NewMobile);
looter.DefaultMobileInit();
var corpse = new Corpse(victim, []);
try
{
Assert.Equal(expected, NotorietyHandlers.CorpseNotoriety(looter, corpse));
}
finally
{
corpse.Delete();
victim.Delete();
looter.Delete();
}
}
}