using NUnit.Framework; using ProjectM.Simulation; using Unity.Collections; using Unity.Entities; namespace ProjectM.Tests { /// /// Slice 2 — the pure class mapping: which Fire ability each class gets, and that the DRG-asymmetric trait /// seeds fold the right direction (Warrior = melee bruiser / tankier / slower; Ranger = ranged / faster / /// squishier + a wider auto-assist co-op hook), all on the reserved range. /// public class ClassTraitsTests { static DynamicBuffer SeededBuffer(World world, byte classId) { var em = world.EntityManager; var e = em.CreateEntity(); em.AddBuffer(e); var ecb = new EntityCommandBuffer(Allocator.Temp); ClassTraits.AppendSeeds(classId, e, ecb); ecb.Playback(em); ecb.Dispose(); return em.GetBuffer(e); } [Test] public void AbilityFor_And_Normalize_DefaultToWarrior() { Assert.AreEqual((byte)AbilityId.WarriorCone, ClassTraits.AbilityFor(ClassTraits.WarriorClass)); Assert.AreEqual((byte)AbilityId.Primary, ClassTraits.AbilityFor(ClassTraits.RangerClass)); Assert.AreEqual((byte)AbilityId.WarriorCone, ClassTraits.AbilityFor(0), "unknown class -> Warrior cone"); Assert.AreEqual(ClassTraits.WarriorClass, ClassTraits.Normalize(0)); Assert.AreEqual(ClassTraits.WarriorClass, ClassTraits.Normalize(99)); Assert.AreEqual(ClassTraits.RangerClass, ClassTraits.Normalize(ClassTraits.RangerClass)); } [Test] public void Warrior_Seeds_Buff_Melee_And_Tankiness_And_Slow() { using var world = new World("ClassTraitsWarrior"); var mods = SeededBuffer(world, ClassTraits.WarriorClass); Assert.AreEqual(4, mods.Length, "Warrior seeds 4 trait modifiers."); Assert.Greater(StatMath.Apply(10f, StatTarget.MeleeDamage, mods), 10f, "Warrior hits harder in melee."); Assert.Greater(StatMath.Apply(2.6f, StatTarget.MeleeRange, mods), 2.6f, "Warrior reaches further in melee."); Assert.Less(StatMath.Apply(5f, StatTarget.MoveSpeed, mods), 5f, "Warrior moves slower."); Assert.Greater(StatMath.Apply(100f, StatTarget.MaxHealth, mods), 100f, "Warrior is tankier."); for (int i = 0; i < mods.Length; i++) Assert.GreaterOrEqual(mods[i].SourceId, Tuning.ClassSourceId, "class seeds use the reserved SourceId range."); } [Test] public void Ranger_Seeds_Buff_Range_Speed_Assist_And_Leave_Melee_Weak() { using var world = new World("ClassTraitsRanger"); var mods = SeededBuffer(world, ClassTraits.RangerClass); Assert.AreEqual(4, mods.Length, "Ranger seeds 4 trait modifiers."); Assert.Greater(StatMath.Apply(5f, StatTarget.MoveSpeed, mods), 5f, "Ranger moves faster."); Assert.Less(StatMath.Apply(100f, StatTarget.MaxHealth, mods), 100f, "Ranger is squishier."); Assert.Greater(StatMath.Apply(20f, StatTarget.Range, mods), 20f, "Ranger has longer projectile range."); Assert.Greater(StatMath.Apply(0f, StatTarget.AutoTargetRange, mods), 0f, "Ranger has a wider auto-assist (the co-op hook)."); Assert.AreEqual(10f, StatMath.Apply(10f, StatTarget.MeleeDamage, mods), 0.001f, "Ranger melee is unbuffed (weaker than the Warrior)."); } } }