Refactor alot of stuff

This commit is contained in:
2026-10-29 22:54:29 +01:00
parent c23b666ee4
commit 260abc2c98
138 changed files with 2835 additions and 466 deletions
@@ -58,6 +58,76 @@ public class PythonPipelineTests
combat.HandController.Add(card); combat.SelectEnemy(0);
Assert.That(combat.PlayCard(card), Is.True);
}
[TestCase(1, 2)]
[TestCase(2, 3)]
[TestCase(3, 3)]
[TestCase(4, 4)]
[TestCase(5, 4)]
public void UbuntuTurnDrawWaitsForOneChoiceAndPreservesOtherCards(int version, int count)
{
var distro = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Ubuntu.asset");
Set(combat, "_runConfig", new KernelPanic.Run.RunConfig(distro, Language.Python, Language.C,
distro.ExclusiveCards.Take(4).ToArray(), 17, version));
var cards = Enumerable.Range(0, 5).Select(_ => Card("lang_py_print")).ToArray();
cards[count - 1].TemporaryCostDelta = 5; // The expensive card must remain selectable.
combat.DeckController.InitializeInDrawOrder(cards);
var draw = (IEnumerator)Call(combat, "DrawForTurnSequenced");
Assert.That(draw.MoveNext(), Is.True);
Assert.That(combat.Python.Choices.Count, Is.EqualTo(count));
Assert.That(combat.HandController.Cards, Is.Empty);
Assert.That(combat.CanSurrenderRun, Is.False);
Assert.That(combat.Python.Choose(count - 1), Is.True);
Assert.That(draw.MoveNext(), Is.False);
Assert.That(combat.HandController.Cards, Is.EqualTo(new[] { cards[count - 1] }));
Assert.That(combat.DeckController.PeekTop(5), Is.EqualTo(cards.Where(c => c != cards[count - 1])));
Assert.That(cards[count - 1].TemporaryCostDelta, Is.EqualTo(version >= 4 ? 4 : 5));
Assert.That(combat.Python.Choose(0), Is.False);
combat.Python.BeginPhase(2);
Assert.That(cards[count - 1].TemporaryCostDelta, Is.EqualTo(5), "The V4 discount expires after the play phase.");
}
[Test]
public void UbuntuChoiceHandlesEmptyFullAndReshuffledDecks()
{
var distro = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Ubuntu.asset");
Set(combat, "_runConfig", new KernelPanic.Run.RunConfig(distro, Language.Python, Language.C,
distro.ExclusiveCards.Take(4).ToArray(), 17, 1));
Call(combat, "TryApplyUbuntuAptUpdate");
Assert.That(combat.Python.HasChoice, Is.False);
var card = Card("lang_py_print");
combat.DeckController.Discard(card);
combat.HandController.SetRamCapacity(1);
combat.HandController.Add(Card("lang_py_print"));
Call(combat, "TryApplyUbuntuAptUpdate");
Assert.That(combat.Python.HasChoice, Is.False);
Assert.That(combat.DeckController.DiscardPile, Does.Contain(card));
combat.HandController.Clear();
Call(combat, "TryApplyUbuntuAptUpdate");
Assert.That(combat.Python.Choices.Count, Is.EqualTo(1));
Assert.That(combat.Python.Choose(0), Is.True);
Assert.That(combat.HandController.Cards, Is.EqualTo(new[] { card }));
}
[TestCase("Mint")]
[TestCase("Fedora")]
[TestCase("Arch")]
[TestCase("Gentoo")]
[TestCase("NixOS")]
public void OtherDistrosDrawOneWithoutAChoice(string distroName)
{
var distro = AssetDatabase.LoadAssetAtPath<DistroDefinition>($"Assets/Data/Distros/{distroName}.asset");
Set(combat, "_runConfig", new KernelPanic.Run.RunConfig(distro, Language.Python, Language.C,
distro.ExclusiveCards.Take(4).ToArray(), 17, 1));
combat.DeckController.InitializeInDrawOrder(new[] { Card("lang_py_print"), Card("lang_py_print") });
var turn = (IEnumerator)Call(combat, "DrawForTurnSequenced");
Assert.That(turn.MoveNext(), Is.True);
var draw = (IEnumerator)turn.Current;
while (draw.MoveNext()) { }
Assert.That(turn.MoveNext(), Is.False);
Assert.That(combat.HandController.Cards.Count, Is.EqualTo(1));
Assert.That(combat.Python.HasChoice, Is.False);
}
private void ResolveQueue()
{
var routine = (IEnumerator)Call(combat, "InterpretQueueSequenced");