Survival mode bugfixes and revive mechanism
All checks were successful
CI / lint (push) Successful in 31s
CI / build (push) Successful in 32s
CI / release (push) Successful in 32s

This commit is contained in:
Kamal Tufekcic 2026-07-08 18:10:09 +03:00
commit 2fa85e8b1f
14 changed files with 529 additions and 35 deletions

View file

@ -110,4 +110,79 @@ public class SurvivalEconomyTests
[InlineData(2, 50, true, 2.25)]
public void TeamMult_matches(int level, double perPick, bool increase, double expected) =>
T.Close(expected, SurvivalEconomy.TeamMult(level, perPick, increase));
// ---- Field Medic revive scaling (defaults: channel 4.0 -0.7/lvl min 1.5; HP 0.35 +0.1/lvl; charges = lvl*1) ----
// channelSeconds = max(ReviveChannelMin, ReviveChannelSeconds - (lvl-1)*ReviveChannelPerLevel).
[Theory]
[InlineData(1, 4.0)]
[InlineData(2, 3.3)]
[InlineData(3, 2.6)]
[InlineData(10, 1.5)] // -0.7*9 undershoots the 1.5 floor -> clamped
public void ReviveChannelSeconds_scales_and_floors(int level, double expected) =>
T.Close(expected, SurvivalEconomy.ReviveChannelSeconds(level, T.Surv()));
// hpFraction = clamp(ReviveHpBase + (lvl-1)*ReviveHpPerLevel, 0.05, 1.0).
[Theory]
[InlineData(1, 0.35)]
[InlineData(2, 0.45)]
[InlineData(3, 0.55)]
[InlineData(20, 1.0)] // upper clamp
public void ReviveHpFraction_scales_and_clamps(int level, double expected) =>
T.Close(expected, SurvivalEconomy.ReviveHpFraction(level, T.Surv()));
// chargesForWave = lvl <= 0 ? 0 : lvl * ReviveChargesPerLevel. Card-only: level 0 (no card) grants nothing.
[Theory]
[InlineData(0, 0)] // not a medic -> no revives
[InlineData(1, 1)]
[InlineData(2, 2)]
[InlineData(3, 3)]
public void ReviveChargesForWave_scales(int level, int expected) =>
Assert.Equal(expected, SurvivalEconomy.ReviveChargesForWave(level, T.Surv()));
[Fact]
public void FieldMedic_card_is_in_the_catalog() // card-only unlock lives on the draft catalog, cap 3
{
var card = T.Surv().Cards.Find(c => c.Key == CardKeys.FieldMedic);
Assert.NotNull(card);
Assert.Equal(3, card!.Cap);
}
// ---- HUD locator math (the arrow direction players are sent + the distance readout) ----
// NormalizeDeg wraps to the canonical (-180, 180] (so -180 -> +180).
[Theory]
[InlineData(0, 0)]
[InlineData(45, 45)]
[InlineData(180, 180)]
[InlineData(-180, 180)]
[InlineData(270, -90)]
[InlineData(-270, 90)]
[InlineData(360, 0)]
[InlineData(450, 90)]
public void NormalizeDeg_wraps_to_half_open(double input, double expected) =>
T.Close(expected, SurvivalEconomy.NormalizeDeg(input));
// ArrowIndex: relative bearing -> sector. arrows table = { ↑ ↖ ← ↙ ↓ ↘ → ↗ } indexed 0..7; 0 = ahead, CCW = left.
[Theory]
[InlineData(0, 0)] // ↑ ahead
[InlineData(45, 1)] // ↖ ahead-left
[InlineData(90, 2)] // ← left
[InlineData(135, 3)] // ↙ behind-left
[InlineData(180, 4)] // ↓ behind
[InlineData(-135, 5)] // ↘ behind-right
[InlineData(-90, 6)] // → right
[InlineData(-45, 7)] // ↗ ahead-right
[InlineData(360, 0)] // wraps to ahead
[InlineData(23, 1)] // rounds up into the ↖ sector
[InlineData(22, 0)] // rounds down into the ↑ sector
public void ArrowIndex_maps_bearing_to_sector(double relDeg, int expected) =>
Assert.Equal(expected, SurvivalEconomy.ArrowIndex(relDeg));
// LocatorMeters = max(1, round(dist/divisor)); floors at 1m so a downed ally never reads "0m".
[Theory]
[InlineData(0, 40, 1)] // floor
[InlineData(20, 40, 1)] // round(0.5)=0 -> floored to 1
[InlineData(120, 40, 3)]
[InlineData(200, 40, 5)]
public void LocatorMeters_floors_at_one(double dist, double divisor, int expected) =>
Assert.Equal(expected, SurvivalEconomy.LocatorMeters(dist, divisor));
}