Attack Boon Changes

This commit is contained in:
2026-07-13 18:30:41 -07:00
parent 972e0d5b4f
commit 24800f4bcb
34 changed files with 1306 additions and 112 deletions
@@ -25,14 +25,14 @@ namespace ProjectM.Tests
{
for (uint seed = 1; seed < 200; seed += 7)
{
int n = BoonMath.PickBoons(seed, classId, ref pool, out byte a0, out byte a1, out byte a2);
int n = BoonMath.PickBoons(seed, classId, default(BoonEffects), ref pool, out byte a0, out byte a1, out byte a2);
Assert.AreEqual(3, n, "the default pool always fills 3 options");
Assert.AreNotEqual(a0, a1, "distinct");
Assert.AreNotEqual(a1, a2, "distinct");
Assert.AreNotEqual(a0, a2, "distinct");
// Deterministic re-draw.
BoonMath.PickBoons(seed, classId, ref pool, out byte b0, out byte b1, out byte b2);
BoonMath.PickBoons(seed, classId, default(BoonEffects), ref pool, out byte b0, out byte b1, out byte b2);
Assert.AreEqual(a0, b0);
Assert.AreEqual(a1, b1);
Assert.AreEqual(a2, b2);
@@ -73,7 +73,7 @@ namespace ProjectM.Tests
Entity MakePlayer(int netId, byte region, byte classId)
{
var e = em.CreateEntity(typeof(PlayerTag), typeof(BoonOffer), typeof(GhostOwner),
typeof(RegionTag), typeof(PlayerClass));
typeof(RegionTag), typeof(PlayerClass), typeof(BoonEffects));
em.SetComponentData(e, new GhostOwner { NetworkId = netId });
em.SetComponentData(e, new RegionTag { Region = region });
em.SetComponentData(e, new PlayerClass { ClassId = classId });
@@ -102,5 +102,44 @@ namespace ProjectM.Tests
}
}
}
static byte FamilyOf(ref BoonCatalogBlob pool, byte id)
{
int idx = BoonMath.FindDef(ref pool, id);
return idx >= 0 ? pool.Defs[idx].Family : (byte)0;
}
[Test]
public void PickBoons_NeverOffersTwoSameFamily_InOneDeal()
{
var blob = BoonCatalogData.BuildDefault(Allocator.Temp);
ref var pool = ref blob.Value;
for (byte classId = 0; classId <= 1; classId++)
for (uint seed = 1; seed < 200; seed += 3)
{
BoonMath.PickBoons(seed, classId, default(BoonEffects), ref pool, out byte a0, out byte a1, out byte a2);
byte f0 = FamilyOf(ref pool, a0), f1 = FamilyOf(ref pool, a1), f2 = FamilyOf(ref pool, a2);
Assert.AreNotEqual(f0, f1, "dominated-offer protection: no two same-family options in one deal");
Assert.AreNotEqual(f1, f2, "dominated-offer protection: no two same-family options in one deal");
Assert.AreNotEqual(f0, f2, "dominated-offer protection: no two same-family options in one deal");
}
blob.Dispose();
}
[Test]
public void PickBoons_ExcludesOwnedNonStackingFlag()
{
var blob = BoonCatalogData.BuildDefault(Allocator.Temp);
ref var pool = ref blob.Value;
var owned = new BoonEffects { Flags = BoonFlag.DashTrail }; // already own Blade Dash (id 5, both classes)
for (byte classId = 0; classId <= 1; classId++)
for (uint seed = 1; seed < 300; seed += 3)
{
BoonMath.PickBoons(seed, classId, owned, ref pool, out byte a0, out byte a1, out byte a2);
Assert.IsFalse(a0 == 5 || a1 == 5 || a2 == 5, "an owned non-stacking flag boon (Blade Dash) is never re-offered");
}
blob.Dispose();
}
}
}