Rebalance most languages and revamp main game loop
This commit is contained in:
@@ -71,7 +71,7 @@ public class CampaignTests
|
||||
Assert.That(pair[0].PairId, Is.GreaterThanOrEqualTo(0));
|
||||
Assert.That(pair[1].PairId, Is.EqualTo(pair[0].PairId));
|
||||
((List<EnemyInstance>)_combat.Enemies).Clear();
|
||||
Set(_run, "currentWaveNumber", 5);
|
||||
Set(_run, "currentWaveNumber", RunJourney.BossWave);
|
||||
Call(_combat, "SpawnEncounter");
|
||||
Assert.That(_combat.Enemies.Count(enemy => enemy.Archetype.Tier == EnemyTier.Boss), Is.EqualTo(1));
|
||||
}
|
||||
@@ -107,6 +107,30 @@ public class CampaignTests
|
||||
Assert.That(RandomRoll.DrawCount, Is.EqualTo(draws));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtendedEncountersEscalateWithoutAnEarlyBossAndContinueIntoSurvival()
|
||||
{
|
||||
int draws = RandomRoll.DrawCount;
|
||||
for (int seed = 0; seed < 50; seed++)
|
||||
for (int wave = 1; wave <= 12; wave++)
|
||||
{
|
||||
var plan = EncounterDirector.Plan(wave, WaveRoute.Repair, seed, 2);
|
||||
Assert.That(plan.Enemies.All(id => EnemyArchetypeCatalog.Get(id).Id == id), Is.True);
|
||||
Assert.That(plan.Enemies.Count(id => id == "race_condition") % 2, Is.Zero);
|
||||
if (wave < 10) Assert.That(plan.Enemies, Does.Not.Contain("kernel_overseer"));
|
||||
if (wave == 10) Assert.That(plan.Enemies.Count(id => id == "kernel_overseer"), Is.EqualTo(1));
|
||||
if (wave > 10) Assert.That(plan.Title, Does.StartWith("Survival"));
|
||||
Assert.That(plan.UptimeBonus, Is.EqualTo((wave - 1) * CombatTuning.EnemyUptimeGrowthPerWave));
|
||||
if (wave > 1)
|
||||
{
|
||||
var elite = EncounterDirector.Plan(wave, WaveRoute.Challenge, seed, 2);
|
||||
Assert.That(elite.Enemies.Count, Is.EqualTo(plan.Enemies.Count + 1));
|
||||
Assert.That(elite.Enemies.Last(), Is.EqualTo("daemon"));
|
||||
}
|
||||
}
|
||||
Assert.That(RandomRoll.DrawCount, Is.EqualTo(draws));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildRewardBlocksDepartureAndOnlyUpgradesTheChosenCardOnce()
|
||||
{
|
||||
@@ -309,7 +333,7 @@ public class CampaignTests
|
||||
[Test]
|
||||
public void CompletedCampaignIsAVictoryAndCannotContinueOrCompleteTwice()
|
||||
{
|
||||
RepositoryAfter(5);
|
||||
RepositoryAfter(RunJourney.BossWave);
|
||||
Assert.That(_run.CampaignChoicePending, Is.True);
|
||||
_combat.ContinueToNextWave();
|
||||
Assert.That(_combat.AwaitingWaveContinue, Is.True);
|
||||
@@ -326,13 +350,13 @@ public class CampaignTests
|
||||
public void EndlessIsExplicitAndKeepsTheSameRunAndRewards()
|
||||
{
|
||||
Assert.That(_run.EnterEndless(), Is.False);
|
||||
RepositoryAfter(5);
|
||||
RepositoryAfter(RunJourney.BossWave);
|
||||
string id = _run.RunId;
|
||||
int bandwidth = _run.AccruedBandwidth;
|
||||
Assert.That(_run.EnterEndless(), Is.True);
|
||||
Assert.That(_run.EnterEndless(), Is.False);
|
||||
Assert.That(_run.CampaignChoicePending, Is.False);
|
||||
Assert.That(_run.CurrentWaveNumber, Is.EqualTo(6));
|
||||
Assert.That(_run.CurrentWaveNumber, Is.EqualTo(RunJourney.BossWave + 1));
|
||||
Assert.That(_run.AccruedBandwidth, Is.EqualTo(bandwidth));
|
||||
Assert.That(_run.RunId, Is.EqualTo(id));
|
||||
Assert.That(_run.RewardsSettled, Is.False);
|
||||
@@ -353,7 +377,7 @@ public class CampaignTests
|
||||
int draws = RandomRoll.DrawCount;
|
||||
var lines = ExecutionPreview.Build(_combat);
|
||||
Assert.That(lines[1], Does.Contain(python.Definition.DisplayName).And.Contain("FIFO").And.Contain("Memory Leak"));
|
||||
Assert.That(lines[2], Does.Contain(thunk.Definition.DisplayName).And.Contain("LIFO x1.5"));
|
||||
Assert.That(lines[2], Does.Contain(thunk.Definition.DisplayName).And.Contain("LIFO x1.75"));
|
||||
Assert.That(lines[3], Does.Contain(map.Definition.DisplayName));
|
||||
Assert.That(ExecutionPreview.Build(_combat), Is.EqualTo(lines));
|
||||
Assert.That(RandomRoll.DrawCount, Is.EqualTo(draws));
|
||||
|
||||
@@ -74,15 +74,15 @@ public class CardCatalogTests
|
||||
yield return new TestCaseData("shop_hs_dollar_bang", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=Haskell|_maxAmount=5|_minAmount=5|_trueDamage=False;ShieldEffect|_amount=2", true, false, false,
|
||||
"stack: deal 5. gain 2 Shield.",
|
||||
"stack: deal 7. gain 4 Shield. [upgraded]").SetName("Catalog_preserves_shop_hs_dollar_bang");
|
||||
yield return new TestCaseData("lang_py_print", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=Python|_maxAmount=3|_minAmount=3|_trueDamage=False", false, false, false,
|
||||
"queue: deal 3.",
|
||||
"queue: deal 5. [upgraded]").SetName("Catalog_preserves_lang_py_print");
|
||||
yield return new TestCaseData("lang_py_import_antigravity", "DrawEffect|_count=2", false, false, false,
|
||||
"queue: draw 2.",
|
||||
"queue: draw 4. [upgraded]").SetName("Catalog_preserves_lang_py_import_antigravity");
|
||||
yield return new TestCaseData("lang_py_for_loop", "DealDamageEffect|_allEnemies=True|_canCrit=True|_language=Python|_maxAmount=2|_minAmount=2|_trueDamage=False", false, true, false,
|
||||
"queue: deal 2 to all enemies.",
|
||||
"queue: deal 4 to all enemies. [upgraded]").SetName("Catalog_preserves_lang_py_for_loop");
|
||||
yield return new TestCaseData("lang_py_print", "PythonEffect|_amount=4|_operation=Print", true, false, false,
|
||||
"payload: deal 4 to a chosen enemy.",
|
||||
"payload: deal 6 to a chosen enemy. [upgraded]").SetName("Catalog_preserves_lang_py_print");
|
||||
yield return new TestCaseData("lang_py_import_antigravity", "PythonEffect|_amount=2|_operation=Draw", false, false, false,
|
||||
"preparation: immediately draw 2 (fixed).",
|
||||
"preparation: immediately draw 2 (fixed). [upgraded]").SetName("Catalog_preserves_lang_py_import_antigravity");
|
||||
yield return new TestCaseData("lang_py_for_loop", "PythonEffect|_amount=2|_operation=Loop", false, false, false,
|
||||
"modifier: gain 2 Shield. repeat the next payload once. unused repeat expires after next round.",
|
||||
"modifier: gain 4 Shield. repeat the next payload once. unused repeat expires after next round. [upgraded]").SetName("Catalog_preserves_lang_py_for_loop");
|
||||
yield return new TestCaseData("lang_js_console_log", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=JavaScript|_maxAmount=9|_minAmount=3|_trueDamage=False", true, false, true,
|
||||
"deal 3-9.",
|
||||
"deal 5-11. [upgraded]").SetName("Catalog_preserves_lang_js_console_log");
|
||||
@@ -92,51 +92,51 @@ public class CardCatalogTests
|
||||
yield return new TestCaseData("lang_rs_fn_main", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=Rust|_maxAmount=6|_minAmount=6|_trueDamage=False", true, false, true,
|
||||
"deal 6. overkill becomes shield.",
|
||||
"deal 8. overkill becomes shield. [upgraded]").SetName("Catalog_preserves_lang_rs_fn_main");
|
||||
yield return new TestCaseData("lang_rs_unwrap", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=Rust|_maxAmount=9|_minAmount=9|_trueDamage=False;DrawEffect|_count=1", true, false, true,
|
||||
"deal 9. overkill becomes shield. draw 1.",
|
||||
"deal 11. overkill becomes shield. draw 3. [upgraded]").SetName("Catalog_preserves_lang_rs_unwrap");
|
||||
yield return new TestCaseData("lang_rs_unwrap", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=Rust|_maxAmount=5|_minAmount=5|_trueDamage=False;FixedDrawEffect|_count=1", true, false, true,
|
||||
"deal 5. overkill becomes shield. draw 1 (fixed).",
|
||||
"deal 7. overkill becomes shield. draw 1 (fixed). [upgraded]").SetName("Catalog_preserves_lang_rs_unwrap");
|
||||
yield return new TestCaseData("lang_rs_borrow", "ShieldEffect|_amount=5", false, false, false,
|
||||
"gain 5 shield.",
|
||||
"gain 7 shield. [upgraded]").SetName("Catalog_preserves_lang_rs_borrow");
|
||||
yield return new TestCaseData("lang_c_malloc", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=C|_maxAmount=12|_minAmount=12|_trueDamage=False", true, false, true,
|
||||
"deal 12. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card.",
|
||||
"deal 14. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card. [upgraded]").SetName("Catalog_preserves_lang_c_malloc");
|
||||
yield return new TestCaseData("lang_c_printf", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=C|_maxAmount=7|_minAmount=7|_trueDamage=False;RepairCorruptedCardsEffect|_count=1", true, false, true,
|
||||
"deal 7. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card. then repair up to 1 corrupted card in your active deck.",
|
||||
"deal 9. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card. then repair up to 3 corrupted cards in your active deck. [upgraded]").SetName("Catalog_preserves_lang_c_printf");
|
||||
yield return new TestCaseData("lang_c_printf", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=C|_maxAmount=4|_minAmount=4|_trueDamage=False;RepairCorruptedCardsEffect|_count=1", true, false, true,
|
||||
"deal 4. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card. then repair up to 1 corrupted card in your active deck.",
|
||||
"deal 6. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card. then repair up to 3 corrupted cards in your active deck. [upgraded]").SetName("Catalog_preserves_lang_c_printf");
|
||||
yield return new TestCaseData("lang_c_pointer", "PreviousLanguageDamageEffect|_baseAmount=9|_language=C|_matchingAmount=15", true, false, true,
|
||||
"deal 9; 15 if the previous card was C. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card.",
|
||||
"deal 11; 17 if the previous card was C. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card. [upgraded]").SetName("Catalog_preserves_lang_c_pointer");
|
||||
yield return new TestCaseData("lang_java_public_static_main", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=Java|_maxAmount=7|_minAmount=7|_trueDamage=False", true, false, true,
|
||||
"uses 2 RAM. deal 7. overkill spills. JIT: Java cards cost 1 less this combat each time you play a Java card; discount decays by 1 after each wave.",
|
||||
"uses 2 RAM. deal 9. overkill spills. JIT: Java cards cost 1 less this combat each time you play a Java card; discount decays by 1 after each wave. [upgraded]").SetName("Catalog_preserves_lang_java_public_static_main");
|
||||
"uses 2 RAM. deal 7. overkill spills. JIT: -1 Cycle per 2 Java plays, capped at -3; discount cools by 1 after each wave.",
|
||||
"uses 2 RAM. deal 9. overkill spills. JIT: -1 Cycle per 2 Java plays, capped at -3; discount cools by 1 after each wave. [upgraded]").SetName("Catalog_preserves_lang_java_public_static_main");
|
||||
yield return new TestCaseData("lang_java_system_out_println", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=Java|_maxAmount=5|_minAmount=5|_trueDamage=False", true, false, true,
|
||||
"uses 2 RAM. deal 5. overkill spills. JIT applies; discount decays by 1 after each wave.",
|
||||
"uses 2 RAM. deal 7. overkill spills. JIT applies; discount decays by 1 after each wave. [upgraded]").SetName("Catalog_preserves_lang_java_system_out_println");
|
||||
"uses 2 RAM. deal 5. overkill spills. JIT: -1 Cycle per 2 Java plays, capped at -3; discount cools by 1 after each wave.",
|
||||
"uses 2 RAM. deal 7. overkill spills. JIT: -1 Cycle per 2 Java plays, capped at -3; discount cools by 1 after each wave. [upgraded]").SetName("Catalog_preserves_lang_java_system_out_println");
|
||||
yield return new TestCaseData("lang_java_new_object", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=Java|_maxAmount=3|_minAmount=3|_trueDamage=False", true, false, true,
|
||||
"uses 2 RAM. deal 3. overkill spills. JIT applies; discount decays by 1 after each wave.",
|
||||
"uses 2 RAM. deal 5. overkill spills. JIT applies; discount decays by 1 after each wave. [upgraded]").SetName("Catalog_preserves_lang_java_new_object");
|
||||
yield return new TestCaseData("ubuntu_ask_ubuntu", "AskUbuntuEffect", false, false, false,
|
||||
"queue: draw 2.",
|
||||
"queue: draw 4. [upgraded]").SetName("Catalog_preserves_ubuntu_ask_ubuntu");
|
||||
yield return new TestCaseData("ubuntu_unattended_upgrades", "ShieldEffect|_amount=4;ApplyStatusEffect|_duration=2|_skipNextTick=True|_stacks=4|_statusType=UnattendedUpgrades|_targetSelf=True", false, false, false,
|
||||
"queue: gain 4 shield now and next 2 turns.",
|
||||
"queue: gain 6 shield now and next 2 turns. [upgraded]").SetName("Catalog_preserves_ubuntu_unattended_upgrades");
|
||||
"uses 2 RAM. deal 3. overkill spills. JIT: -1 Cycle per 2 Java plays, capped at -3; discount cools by 1 after each wave.",
|
||||
"uses 2 RAM. deal 5. overkill spills. JIT: -1 Cycle per 2 Java plays, capped at -3; discount cools by 1 after each wave. [upgraded]").SetName("Catalog_preserves_lang_java_new_object");
|
||||
yield return new TestCaseData("ubuntu_ask_ubuntu", "PythonEffect|_amount=0|_operation=Inspect", false, false, false,
|
||||
"preparation: inspect the top 3 cards. take one; others keep their order.",
|
||||
"preparation: inspect the top 3 cards. take one; others keep their order. [upgraded]").SetName("Catalog_preserves_ubuntu_ask_ubuntu");
|
||||
yield return new TestCaseData("ubuntu_unattended_upgrades", "PythonEffect|_amount=3|_operation=Unattended", false, false, false,
|
||||
"automation: gain 3 Shield now and before the queue on each of the next 2 rounds. uses 1 of 2 script slots.",
|
||||
"automation: gain 5 Shield now and before the queue on each of the next 2 rounds. uses 1 of 2 script slots. [upgraded]").SetName("Catalog_preserves_ubuntu_unattended_upgrades");
|
||||
yield return new TestCaseData("mint_fix_broken", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=JavaScript|_maxAmount=8|_minAmount=8|_trueDamage=False;CleanseEffect|_harmfulOnly=True", true, false, true,
|
||||
"deal 8. cleanse harmful statuses.",
|
||||
"deal 10. cleanse harmful statuses. [upgraded]").SetName("Catalog_preserves_mint_fix_broken");
|
||||
yield return new TestCaseData("lang_js_typeof", "ChanceDamageEffect|_damageAmount=8|_language=JavaScript|_successPercent=75", true, false, true,
|
||||
"75%: deal 8. 25%: deal 0.",
|
||||
"75%: deal 10. 25%: deal 0. [upgraded]").SetName("Catalog_preserves_lang_js_typeof");
|
||||
yield return new TestCaseData("shop_py_list_append", "QueuedGrowthDamageEffect|_baseAmount=4|_language=Python", true, false, false,
|
||||
"queue: deal 4; +1 each time re-queued.",
|
||||
"queue: deal 8; +1 each time re-queued. [upgraded]").SetName("Catalog_preserves_shop_py_list_append");
|
||||
yield return new TestCaseData("shop_py_async_def", "DrawEffect|_count=2;NextTurnCycleEffect|_amount=1", false, false, false,
|
||||
"queue: draw 2. gain 1 cycle next turn.",
|
||||
"queue: draw 4. gain 3 cycle next turn. [upgraded]").SetName("Catalog_preserves_shop_py_async_def");
|
||||
yield return new TestCaseData("shop_py_zip", "QueueRepeatEffect|_count=2", false, false, false,
|
||||
"next 2 queued cards resolve twice.",
|
||||
"next 4 queued cards resolve twice. [upgraded]").SetName("Catalog_preserves_shop_py_zip");
|
||||
yield return new TestCaseData("lang_js_typeof", "ChanceDamageEffect|_damageAmount=14|_language=JavaScript|_successPercent=75", true, false, true,
|
||||
"75%: deal 14. 25%: deal 0.",
|
||||
"75%: deal 16. 25%: deal 0. [upgraded]").SetName("Catalog_preserves_lang_js_typeof");
|
||||
yield return new TestCaseData("shop_py_list_append", "PythonEffect|_amount=6|_operation=List", true, false, false,
|
||||
"payload: deal 6. +2 per subsequent hand play this wave; replays do not grow it.",
|
||||
"payload: deal 12. +2 per subsequent hand play this wave; replays do not grow it. [upgraded]").SetName("Catalog_preserves_shop_py_list_append");
|
||||
yield return new TestCaseData("shop_py_async_def", "PythonEffect|_amount=0|_operation=Async", false, false, false,
|
||||
"automation: draw 1 immediately on play (fixed). capture the next payload without modifiers; replay it before the queue on each of the next 2 rounds. uses 1 of 2 script slots.",
|
||||
"automation: draw 1 immediately on play (fixed). capture the next payload without modifiers; replay it before the queue on each of the next 2 rounds. uses 1 of 2 script slots. [upgraded]").SetName("Catalog_preserves_shop_py_async_def");
|
||||
yield return new TestCaseData("shop_py_zip", "PythonEffect|_amount=2|_operation=Zip", true, false, false,
|
||||
"modifier: deal 2. the next single-target damage payload hits all enemies. unused conversion expires after next round.",
|
||||
"modifier: deal 4. the next single-target damage payload hits all enemies. unused conversion expires after next round. [upgraded]").SetName("Catalog_preserves_shop_py_zip");
|
||||
yield return new TestCaseData("shop_js_math_random", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=JavaScript|_maxAmount=20|_minAmount=2|_trueDamage=False", true, false, true,
|
||||
"deal 2-20.",
|
||||
"deal 4-22. [upgraded]").SetName("Catalog_preserves_shop_js_math_random");
|
||||
@@ -152,24 +152,24 @@ public class CardCatalogTests
|
||||
yield return new TestCaseData("ubuntu_do_release_upgrade", "UpgradeHandCardsEffect|_maxCount=3|_minCount=1", false, false, false,
|
||||
"upgrade 1-3 random hand cards.",
|
||||
"upgrade 3-5 random hand cards. [upgraded]").SetName("Catalog_preserves_ubuntu_do_release_upgrade");
|
||||
yield return new TestCaseData("ubuntu_apt_install", "GenerateCardEffect|_language=Python|_rarity=Common", false, false, false,
|
||||
"queue: generate a random common Python card at 0c.",
|
||||
"queue: generate a random common Python card at 0c. [upgraded]").SetName("Catalog_preserves_ubuntu_apt_install");
|
||||
yield return new TestCaseData("ubuntu_apt_install", "PythonEffect|_amount=0|_operation=Install", false, false, false,
|
||||
"preparation: choose one of 3 Python cards. temporary copy costs 0 this turn and exhausts after play.",
|
||||
"preparation: choose one of 3 Python cards. temporary copy costs 0 this turn and exhausts after play. [upgraded]").SetName("Catalog_preserves_ubuntu_apt_install");
|
||||
yield return new TestCaseData("ubuntu_pro_trial", "NoOpCardEffect|_message=ubuntu pro trial is unplayable", false, false, false,
|
||||
"unplayable. exhausts at end of combat.",
|
||||
"unplayable. exhausts at end of combat. [upgraded]").SetName("Catalog_preserves_ubuntu_pro_trial");
|
||||
yield return new TestCaseData("mint_update_manager", "UpdateManagerEffect|_amount=5", false, false, false,
|
||||
"queue: deal 5 to all enemies. repeats at the end of your next turn.",
|
||||
"queue: deal 7 to all enemies. repeats at the end of your next turn. [upgraded]").SetName("Catalog_preserves_mint_update_manager");
|
||||
yield return new TestCaseData("mint_cinnamon", "ShieldEffect|_amount=3;DrawEffect|_count=1", false, false, false,
|
||||
"queue: gain 3 shield. draw 1.",
|
||||
"queue: gain 5 shield. draw 3. [upgraded]").SetName("Catalog_preserves_mint_cinnamon");
|
||||
yield return new TestCaseData("mint_update_manager", "PythonEffect|_amount=3|_operation=Update", false, true, false,
|
||||
"payload: deal 3 to all enemies; 5 if an automation ran earlier this phase.",
|
||||
"payload: deal 5 to all enemies; 7 if an automation ran earlier this phase. [upgraded]").SetName("Catalog_preserves_mint_update_manager");
|
||||
yield return new TestCaseData("mint_cinnamon", "PythonEffect|_amount=3|_operation=Cinnamon", false, false, false,
|
||||
"payload: gain 3 Shield; 5 if an earlier Python payload dealt damage this phase.",
|
||||
"payload: gain 5 Shield; 7 if an earlier Python payload dealt damage this phase. [upgraded]").SetName("Catalog_preserves_mint_cinnamon");
|
||||
yield return new TestCaseData("mint_nemo", "ConditionalShieldRepeatDamageEffect|_amount=6|_language=JavaScript", true, false, true,
|
||||
"deal 6. if you have shield, deal it again.",
|
||||
"deal 8. if you have shield, deal it again. [upgraded]").SetName("Catalog_preserves_mint_nemo");
|
||||
yield return new TestCaseData("mint_timeshift", "TimeshiftSnapshotEffect", false, false, false,
|
||||
"queue: record uptime now. at end of your next turn, restore to it if lower.",
|
||||
"queue: record uptime now. at end of your next turn, restore to it if lower. [upgraded]").SetName("Catalog_preserves_mint_timeshift");
|
||||
yield return new TestCaseData("mint_timeshift", "PythonEffect|_amount=0|_operation=Timeshift", false, false, false,
|
||||
"automation: save your Uptime when this resolves. after enemies act in each of the next 2 rounds, heal up to 6 Uptime, without exceeding the saved value. no healing this round or if defeated. healing does not scale with upgrades. uses 1 of 2 script slots until both rounds finish; ends when the wave ends.",
|
||||
"automation: save your Uptime when this resolves. after enemies act in each of the next 2 rounds, heal up to 6 Uptime, without exceeding the saved value. no healing this round or if defeated. healing does not scale with upgrades. uses 1 of 2 script slots until both rounds finish; ends when the wave ends. [upgraded]").SetName("Catalog_preserves_mint_timeshift");
|
||||
yield return new TestCaseData("fedora_dnf_autoremove", "DnfAutoremoveEffect|_cycleGain=1|_damageAmount=7", true, false, true,
|
||||
"deal 7. exhaust a junk/NOP/broken card from hand; if you do, gain 1 cycle. if not, do nothing.",
|
||||
"deal 9. exhaust a junk/NOP/broken card from hand; if you do, gain 3 cycle. if not, do nothing. [upgraded]").SetName("Catalog_preserves_fedora_dnf_autoremove");
|
||||
@@ -177,8 +177,8 @@ public class CardCatalogTests
|
||||
"deal 7. Java cards cost 1 less this turn.",
|
||||
"deal 9. Java cards cost 1 less this turn. [upgraded]").SetName("Catalog_preserves_fedora_first_to_package");
|
||||
yield return new TestCaseData("fedora_dnf_update", "DealDamageEffect|_allEnemies=False|_canCrit=True|_language=Java|_maxAmount=9|_minAmount=9|_trueDamage=False", true, false, true,
|
||||
"deal 9. overkill spills. costs 1 less per Java card played this combat.",
|
||||
"deal 11. overkill spills. costs 1 less per Java card played this combat. [upgraded]").SetName("Catalog_preserves_fedora_dnf_update");
|
||||
"deal 9. overkill spills. JIT: -1 Cycle per 2 Java plays, capped at -3; discount cools by 1 after each wave.",
|
||||
"deal 11. overkill spills. JIT: -1 Cycle per 2 Java plays, capped at -3; discount cools by 1 after each wave. [upgraded]").SetName("Catalog_preserves_fedora_dnf_update");
|
||||
yield return new TestCaseData("fedora_rawhide", "RawhideEffect", false, false, false,
|
||||
"draw 2. next card this turn gains bleeding edge.",
|
||||
"draw 4. next card this turn gains bleeding edge. [upgraded]").SetName("Catalog_preserves_fedora_rawhide");
|
||||
@@ -192,8 +192,8 @@ public class CardCatalogTests
|
||||
"fix a broken card and draw 1; if none, deal 6.",
|
||||
"fix a broken card and draw 3; if none, deal 8. [upgraded]").SetName("Catalog_preserves_arch_consult_wiki");
|
||||
yield return new TestCaseData("arch_makepkg", "BtwScaledDamageEffect|_baseAmount=7|_language=C|_perBtw=3", true, false, true,
|
||||
"deal 7 + btw x3; x4 at Arch v3+. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card.",
|
||||
"deal 9 + btw x3; x4 at Arch v3+. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card. [upgraded]").SetName("Catalog_preserves_arch_makepkg");
|
||||
"deal 7 + btw x3. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card.",
|
||||
"deal 9 + btw x3. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card. [upgraded]").SetName("Catalog_preserves_arch_makepkg");
|
||||
yield return new TestCaseData("arch_aur_helper", "RandomCommonLanguageCardEffect", false, false, false,
|
||||
"add a random C/Rust common card to hand; it costs 0 this turn.",
|
||||
"add a random C/Rust common card to hand; it costs 0 this turn. [upgraded]").SetName("Catalog_preserves_arch_aur_helper");
|
||||
@@ -345,6 +345,19 @@ public class CardCatalogTests
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase("arch", 2, 3)]
|
||||
[TestCase("arch", 3, 4)]
|
||||
[TestCase("arch", 5, 4)]
|
||||
[TestCase("ubuntu", 5, 3)]
|
||||
public void MakepkgShowsOnlyTheActiveVersionMultiplier(string distro, int version, int multiplier)
|
||||
{
|
||||
var card = new CardInstance(Database.FindById("arch_makepkg"));
|
||||
card.ApplyMagnitudeUpgrade(2);
|
||||
string rules = CardEffectFactory.GetRulesText(card, distro, version);
|
||||
Assert.That(rules, Does.StartWith($"deal 9 + btw x{multiplier}."));
|
||||
Assert.That(rules, Does.Not.Contain("v3"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializedOverrideStillWinsAndUsesItsOwnDescription()
|
||||
{
|
||||
|
||||
@@ -138,7 +138,7 @@ public class CardPreviewTests
|
||||
{
|
||||
var queuedPreview = CardPreviewService.Build(combat, card, Target);
|
||||
Assert.That(queuedPreview.MinimumDamage, Is.EqualTo(preview.MinimumDamage), "Queued preview must not add the play hook twice.");
|
||||
ResolveEffects(card);
|
||||
ResolveEffects(card, combat.LazyStack.Entries.First(entry => entry.Card == card).MultiplierPercent);
|
||||
}
|
||||
Assert.That(before - Target.CurrentUptime, Is.EqualTo(preview.MinimumDamage));
|
||||
Assert.That(preview.MaximumDamage, Is.EqualTo(preview.MinimumDamage));
|
||||
@@ -240,7 +240,7 @@ public class CardPreviewTests
|
||||
Player.ForceMaxRolls = false;
|
||||
Player.JavaScriptFlatDamageBonus = 2;
|
||||
var preview = CardPreviewService.Build(combat, Card("lang_js_typeof"), Target);
|
||||
Assert.That((preview.MinimumDamage, preview.MaximumDamage), Is.EqualTo((2, 15)));
|
||||
Assert.That((preview.MinimumDamage, preview.MaximumDamage), Is.EqualTo((2, 24)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -252,14 +252,47 @@ public class CardPreviewTests
|
||||
Play(first);
|
||||
Play(second);
|
||||
var third = Card("lang_hs_thunk");
|
||||
Assert.That(CardPreviewService.Build(combat, first, Target).MaximumDamage, Is.EqualTo(4));
|
||||
Assert.That(CardPreviewService.Build(combat, second, Target).MaximumDamage, Is.EqualTo(6));
|
||||
Assert.That(CardPreviewService.Build(combat, first, Target).MaximumDamage, Is.EqualTo(6));
|
||||
Assert.That(CardPreviewService.Build(combat, second, Target).MaximumDamage, Is.EqualTo(7));
|
||||
Assert.That(CardPreviewService.Build(combat, third, Target).MaximumDamage, Is.EqualTo(8));
|
||||
Assert.That(CardPreviewService.Build(combat, second).Details, Does.Contain("captured: x1.5"));
|
||||
Assert.That(CardPreviewService.Build(combat, second).Details, Does.Contain("captured: x1.75"));
|
||||
Assert.That(CardPreviewService.Build(combat, third).Details, Does.Contain("next stack: x2.0"));
|
||||
int before = Target.CurrentUptime;
|
||||
ResolveEffects(second, combat.LazyStack.Entries.First(entry => entry.Card == second).MultiplierPercent);
|
||||
Assert.That(before - Target.CurrentUptime, Is.EqualTo(6));
|
||||
Assert.That(before - Target.CurrentUptime, Is.EqualTo(7));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void JavaAcceptedPlaysWarmGraduallyCapAndCoolWithoutChangingDamage()
|
||||
{
|
||||
Configure("Ubuntu", 1);
|
||||
var main = Card("lang_java_public_static_main");
|
||||
var println = Card("lang_java_system_out_println");
|
||||
var allocation = Card("lang_java_new_object");
|
||||
Assert.That((main.Definition.CycleCost, println.Definition.CycleCost, allocation.Definition.CycleCost),
|
||||
Is.EqualTo((2, 1, 0)));
|
||||
int[] costs = { 2, 2, 1, 1, 0, 0, 0, 0, 0 };
|
||||
int before = Target.CurrentUptime;
|
||||
for (int plays = 0; plays < costs.Length; plays++)
|
||||
{
|
||||
var preview = CardPreviewService.Build(combat, main, Target);
|
||||
Assert.That(preview.Cost, Is.EqualTo(costs[plays]), $"After {plays} Java plays");
|
||||
Assert.That(preview.MaximumDamage, Is.EqualTo(7));
|
||||
if (plays < costs.Length - 1) Play(Card("lang_java_new_object"));
|
||||
}
|
||||
Assert.That(before - Target.CurrentUptime, Is.EqualTo(24), "Eight unchanged 3-damage hits.");
|
||||
Assert.That(Player.Cycles, Is.EqualTo(100), "The entry card is free but still uses hand space.");
|
||||
Assert.That(CardPreviewService.Build(combat, println, Target).MaximumDamage, Is.EqualTo(5));
|
||||
Call(combat, "DecayJavaWarmupForNextWave");
|
||||
Assert.That(combat.GetEffectiveCardCost(main), Is.Zero);
|
||||
Call(combat, "DecayJavaWarmupForNextWave");
|
||||
Assert.That(combat.GetEffectiveCardCost(main), Is.EqualTo(1), "Excess plays cannot bank extra cooling immunity.");
|
||||
Call(combat, "DecayJavaWarmupForNextWave");
|
||||
Assert.That(combat.GetEffectiveCardCost(main), Is.EqualTo(2));
|
||||
Call(combat, "DecayJavaWarmupForNextWave");
|
||||
Assert.That(combat.GetEffectiveCardCost(main), Is.EqualTo(2));
|
||||
combat.AddJavaCostDiscountThisTurn(1);
|
||||
Assert.That(combat.GetEffectiveCardCost(main), Is.EqualTo(1), "Turn discounts still stack independently.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -397,7 +430,8 @@ public class CardPreviewTests
|
||||
{
|
||||
var card = Card("lang_c_malloc");
|
||||
card.CorruptForRounds(3, 1);
|
||||
var populate = typeof(CombatManager).Assembly.GetType("KernelPanic.UI.SoftwareCardView").GetMethod("Populate");
|
||||
var populate = typeof(CombatManager).Assembly.GetType("KernelPanic.UI.SoftwareCardView")
|
||||
.GetMethod("Populate", new[] { typeof(VisualElement), typeof(CardInstance), typeof(int) });
|
||||
var face = new VisualElement();
|
||||
populate.Invoke(null, new object[] { face, card, 3 });
|
||||
var preview = CardPreviewService.Build(combat, card);
|
||||
|
||||
@@ -44,12 +44,12 @@ public class CardUtilityEffectTests
|
||||
_temporary.Clear();
|
||||
}
|
||||
|
||||
[TestCase("ubuntu", 2, 2)]
|
||||
[TestCase("ubuntu", 3, 3)]
|
||||
[TestCase("ubuntu", 5, 3)]
|
||||
[TestCase("UBUNTU", 3, 3)]
|
||||
[TestCase("mint", 5, 2)]
|
||||
[TestCase(null, 3, 2)]
|
||||
[TestCase("ubuntu", 2, 3)]
|
||||
[TestCase("ubuntu", 3, 5)]
|
||||
[TestCase("ubuntu", 5, 5)]
|
||||
[TestCase("UBUNTU", 3, 5)]
|
||||
[TestCase("mint", 5, 3)]
|
||||
[TestCase(null, 3, 3)]
|
||||
public void CatalogAskUbuntuUsesBonusOnlyForUbuntuVersionThreeAndLater(string distro, int version, int expected)
|
||||
{
|
||||
if (distro != null) Configure(distro, version);
|
||||
@@ -58,8 +58,10 @@ public class CardUtilityEffectTests
|
||||
|
||||
ExecuteCatalog(card);
|
||||
|
||||
Assert.That(_combat.HandController.Cards.Count, Is.EqualTo(expected));
|
||||
Assert.That(_combat.DeckController.DrawPile.Count, Is.EqualTo(10 - expected));
|
||||
Assert.That(_combat.Python.Choices.Count, Is.EqualTo(expected));
|
||||
Assert.That(_combat.Python.Choose(0), Is.True);
|
||||
Assert.That(_combat.HandController.Cards.Count, Is.EqualTo(1));
|
||||
Assert.That(_combat.DeckController.DrawPile.Count, Is.EqualTo(9));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -73,8 +75,10 @@ public class CardUtilityEffectTests
|
||||
|
||||
ExecuteCatalog(card);
|
||||
|
||||
Assert.That(_combat.HandController.Cards.Count, Is.EqualTo(8), "Three base draws plus two flat and three magnitude.");
|
||||
Assert.That(_combat.DeckController.DrawPile.Count, Is.EqualTo(4));
|
||||
Assert.That(_combat.Python.Choices.Count, Is.EqualTo(5), "Inspection count is fixed, regardless of effect bonuses.");
|
||||
Assert.That(_combat.Python.Choose(0), Is.True);
|
||||
Assert.That(_combat.HandController.Cards.Count, Is.EqualTo(1));
|
||||
Assert.That(_combat.DeckController.DrawPile.Count, Is.EqualTo(11));
|
||||
}
|
||||
|
||||
[TestCase(2)]
|
||||
@@ -193,6 +197,43 @@ public class CardUtilityEffectTests
|
||||
Assert.That(_combat.DeckController.DrawPile, Is.Empty);
|
||||
}
|
||||
|
||||
[TestCase(0, 0)]
|
||||
[TestCase(2, 3)]
|
||||
[TestCase(6, 10)]
|
||||
public void UnwrapReplacementDrawDoesNotScaleWithMagnitudeOrSourceBonuses(int magnitude, int flatBonus)
|
||||
{
|
||||
FillDeck(12);
|
||||
var card = Card("lang_rs_unwrap", Language.Rust);
|
||||
card.ApplyMagnitudeUpgrade(magnitude);
|
||||
Player.FlatEffectBonus = flatBonus;
|
||||
|
||||
ExecuteCatalog(card);
|
||||
|
||||
Assert.That(_combat.HandController.Cards.Count, Is.EqualTo(1));
|
||||
Assert.That(_combat.DeckController.DrawPile.Count, Is.EqualTo(11));
|
||||
Assert.That(CardEffectFactory.GetRulesText(card), Does.Contain("draw 1 (fixed)"));
|
||||
}
|
||||
|
||||
[TestCase(0)]
|
||||
[TestCase(1)]
|
||||
public void UnwrapFixedDrawPreservesBlockedJavaCardAndDrawOrder(int ram)
|
||||
{
|
||||
_combat.HandController.SetRamCapacity(ram);
|
||||
var java = Card("java_top", Language.Java);
|
||||
var next = Card("python_next");
|
||||
SetDrawOrder(java, next);
|
||||
var card = Card("lang_rs_unwrap", Language.Rust);
|
||||
|
||||
ExecuteCatalog(card);
|
||||
|
||||
Assert.That(_combat.HandController.Cards, Is.Empty);
|
||||
Assert.That(_combat.DeckController.DrawPile, Is.EqualTo(new[] { next, java }));
|
||||
_combat.HandController.SetRamCapacity(2);
|
||||
ExecuteCatalog(card);
|
||||
Assert.That(_combat.HandController.Cards, Is.EqualTo(new[] { java }));
|
||||
Assert.That(_combat.DeckController.DrawPile, Is.EqualTo(new[] { next }));
|
||||
}
|
||||
|
||||
private void Configure(string distroId, int version)
|
||||
{
|
||||
var distro = ScriptableObject.CreateInstance<DistroDefinition>();
|
||||
|
||||
@@ -112,6 +112,67 @@ public class CombatLayoutTests
|
||||
enemies.Add(new EnemyInstance(EnemyArchetypeCatalog.Get("memory_leak"), 4));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator PythonChoicesFitViewportsAndResolveThroughAKeyboardSubmit()
|
||||
{
|
||||
var database = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
|
||||
_combat.SetGeneratedCardPool(database.AllCards);
|
||||
foreach (var size in new[] { new Vector2(1280, 720), new Vector2(390, 844), new Vector2(960, 400) })
|
||||
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
||||
{
|
||||
UIPreferences.TextSize = textSize;
|
||||
Resize(size);
|
||||
_combat.Python.Clear();
|
||||
_combat.HandController.Clear();
|
||||
var card = new CardInstance(database.FindById("ubuntu_apt_install"));
|
||||
var context = new CombatContext(card, _combat.PlayerState, Array.Empty<CombatantState>(), _combat,
|
||||
_combat.DamagePipeline, new StatusEffectController(), _combat.DeckController, _combat.HandController, _combat.Enemies);
|
||||
foreach (var effect in CardEffectFactory.CreateEffects(card.Definition)) effect.Execute(context);
|
||||
Call(_view, "RefreshOverlay");
|
||||
for (int frame = 0; frame < 5; frame++) yield return null;
|
||||
var buttons = _root.Query<Button>().ToList().Where(b => b.name?.StartsWith("PythonChoice") == true).ToList();
|
||||
Assert.That(buttons.Count, Is.EqualTo(3));
|
||||
var dialog = _root.Q("PythonChoiceDialog");
|
||||
Assert.That(dialog, Is.Not.Null);
|
||||
AssertContainedHorizontally(dialog, _root, size.ToString());
|
||||
Assert.That(dialog.worldBound.yMin, Is.GreaterThanOrEqualTo(_root.worldBound.yMin - 1));
|
||||
Assert.That(dialog.worldBound.yMax, Is.LessThanOrEqualTo(_root.worldBound.yMax + 1));
|
||||
foreach (var button in buttons)
|
||||
{
|
||||
AssertContainedHorizontally(button, _root, size.ToString());
|
||||
Assert.That(button.worldBound.height, Is.GreaterThanOrEqualTo(47.99f));
|
||||
Assert.That(button.Q<Label>(className: "software-name"), Is.Not.Null);
|
||||
Assert.That(button.Q<Label>(className: "software-cost").text, Is.EqualTo("0c"));
|
||||
Assert.That(button.Q<Label>(className: "python-choice-action").text, Does.StartWith("> install"));
|
||||
foreach (var label in button.Query<Label>().ToList()) AssertContainedHorizontally(label, button, size.ToString());
|
||||
}
|
||||
buttons[2].Focus();
|
||||
for (int frame = 0; frame < 3; frame++) yield return null;
|
||||
var viewport = _root.Q<ScrollView>("PythonChoiceScroll").contentViewport;
|
||||
if (buttons[2].worldBound.height > viewport.worldBound.height)
|
||||
Assert.That(buttons[2].worldBound.yMin, Is.EqualTo(viewport.worldBound.yMin).Within(1));
|
||||
else Assert.That(buttons[2].worldBound.yMax, Is.LessThanOrEqualTo(viewport.worldBound.yMax + 1));
|
||||
buttons[0].Focus();
|
||||
using (var submit = NavigationSubmitEvent.GetPooled()) buttons[0].SendEvent(submit);
|
||||
Assert.That(_combat.Python.HasChoice, Is.False);
|
||||
Assert.That(_combat.HandController.Cards.Count, Is.EqualTo(1));
|
||||
Call(_view, "RefreshOverlay");
|
||||
card = new CardInstance(database.FindById("ubuntu_unattended_upgrades"));
|
||||
context = new CombatContext(card, _combat.PlayerState, Array.Empty<CombatantState>(), _combat,
|
||||
_combat.DamagePipeline, new StatusEffectController(), _combat.DeckController, _combat.HandController, _combat.Enemies);
|
||||
foreach (var effect in CardEffectFactory.CreateEffects(card.Definition)) effect.Execute(context);
|
||||
foreach (var effect in CardEffectFactory.CreateEffects(card.Definition)) effect.Execute(context);
|
||||
Call(_view, "RefreshTracks");
|
||||
for (int frame = 0; frame < 5; frame++) yield return null;
|
||||
var readout = _root.Q("PythonAutomationReadout");
|
||||
Assert.That(readout.Query<Label>().ToList().Count, Is.EqualTo(3));
|
||||
foreach (var label in readout.Query<Label>().ToList()) AssertContainedHorizontally(label, _root, size.ToString());
|
||||
Assert.That(_root.Q(className: "scheduler").ClassListContains("scheduler-idle"), Is.False);
|
||||
Assert.That(_root.Q<Button>(className: "primary-action").worldBound.yMax,
|
||||
Is.LessThanOrEqualTo(_root.worldBound.yMax + 1), size.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator FirstBattleGuideAndReplayControlFitAcrossViewports()
|
||||
{
|
||||
@@ -240,6 +301,49 @@ public class CombatLayoutTests
|
||||
Assert.That(overlay.Query<Label>().ToList().Any(label => label.text.Contains("FINAL ROUND 0")), Is.False);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator FullMapUsesTheViewportAndPreviewsWithoutCommittingKeyboardOrMouseChoices()
|
||||
{
|
||||
_run.RepositoryChanged += () => Call(_view, "RefreshOverlay");
|
||||
foreach (var size in new[] { new Vector2(1280, 720), new Vector2(1920, 1080) })
|
||||
{
|
||||
Resize(size);
|
||||
Set(_run, "currentWaveNumber", 2); Set(_run, "_wavesCleared", 1);
|
||||
_run.GenerateRepositoryOffers(null, null);
|
||||
Set(_combat, "_awaitingWaveContinue", true); Set(_view, "_routeSelectionOpen", true);
|
||||
Call(_view, "RefreshOverlay");
|
||||
for (int i = 0; i < 8; i++) yield return null;
|
||||
var scroll = _root.Q<ScrollView>("RouteMapScroll");
|
||||
var canvas = _root.Q("RouteCanvas");
|
||||
Assert.That(scroll.worldBound.width, Is.GreaterThan(size.x * .55f));
|
||||
Assert.That(scroll.worldBound.height, Is.GreaterThan(size.y * .5f));
|
||||
Assert.That(canvas.Query(className: "route-map-wave").ToList().Count, Is.EqualTo(9));
|
||||
Assert.That(canvas.Query(className: "route-map-node").ToList().Count, Is.GreaterThanOrEqualTo(21));
|
||||
var here = canvas.Q("CurrentMapPosition");
|
||||
Assert.That(here.worldBound.yMax + 24, Is.LessThanOrEqualTo(scroll.contentViewport.worldBound.yMax + 1));
|
||||
var repair = canvas.Q<Button>("RouteRepair");
|
||||
var elite = canvas.Q<Button>("RouteChallenge");
|
||||
int selected = _run.Journey.selectedNodeId;
|
||||
repair.Focus();
|
||||
using (var key = KeyDownEvent.GetPooled('d', KeyCode.D, EventModifiers.None))
|
||||
{ key.target = repair; repair.SendEvent(key); }
|
||||
Assert.That(_root.focusController.focusedElement, Is.SameAs(elite));
|
||||
Assert.That(_run.Journey.selectedNodeId, Is.EqualTo(selected));
|
||||
Assert.That(_root.Q("RoutePreview").Query<Label>().ToList().Any(l => l.text == "Elite detour"), Is.True);
|
||||
var boss = canvas.Q(className: "map-boss");
|
||||
using (var hover = MouseEnterEvent.GetPooled()) { hover.target = boss; boss.SendEvent(hover); }
|
||||
Assert.That(_root.Q("RoutePreview").Query<Label>().ToList().Any(l => l.text == "Kernel Overseer"), Is.True);
|
||||
Assert.That(_run.Journey.selectedNodeId, Is.EqualTo(selected));
|
||||
using (var submit = NavigationSubmitEvent.GetPooled()) { submit.target = elite; elite.SendEvent(submit); }
|
||||
Assert.That(_run.Journey.selectedRoute, Is.EqualTo(WaveRoute.Challenge));
|
||||
for (int i = 0; i < 4; i++) yield return null;
|
||||
var screen = _root.Q("RouteSelectionScreen");
|
||||
using (var escape = KeyDownEvent.GetPooled('\0', KeyCode.Escape, EventModifiers.None))
|
||||
{ escape.target = screen; screen.SendEvent(escape); }
|
||||
Assert.That(_root.Q("RouteSelectionScreen"), Is.Null);
|
||||
}
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator RouteChoicesAndMilestoneRemainReadableAndReachable()
|
||||
{
|
||||
@@ -247,9 +351,9 @@ public class CombatLayoutTests
|
||||
_run.RepositoryChanged += () => Call(_view, "RefreshOverlay");
|
||||
foreach (var size in Viewports)
|
||||
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
||||
foreach (int nextWave in new[] { 2, 3, 6 })
|
||||
foreach (int nextWave in new[] { 2, 3, RunJourney.BossWave + 1 })
|
||||
{
|
||||
bool milestone = nextWave == 6;
|
||||
bool milestone = nextWave == RunJourney.BossWave + 1;
|
||||
UIPreferences.TextSize = textSize;
|
||||
Resize(size);
|
||||
Set(_run, "currentWaveNumber", nextWave);
|
||||
@@ -270,6 +374,20 @@ public class CombatLayoutTests
|
||||
boot.SendEvent(submit);
|
||||
}
|
||||
for (int frame = 0; frame < 6; frame++) yield return null;
|
||||
if (nextWave == 3)
|
||||
{
|
||||
Assert.That(overlay.Q("BuildRewardScreen"), Is.Not.Null);
|
||||
Assert.That(overlay.Q("RunMap"), Is.Null, "Rewards and route selection must be separate screens.");
|
||||
Assert.That(overlay.Q("RouteEvent"), Is.Null);
|
||||
Assert.That(overlay.Q<DropdownField>("BuildRewardCard").value, Does.Contain(_run.RunDeck[0].Definition.DisplayName));
|
||||
Assert.That(overlay.Q("BuildRewardPreviews").childCount, Is.EqualTo(2));
|
||||
int before = _run.Bits;
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
{ var button = overlay.Q<Button>("RewardBits"); submit.target = button; button.SendEvent(submit); }
|
||||
Assert.That(_run.Bits, Is.EqualTo(before + RunManager.BuildRewardBits));
|
||||
for (int frame = 0; frame < 6; frame++) yield return null;
|
||||
Assert.That(overlay.Q("BuildRewardScreen"), Is.Null);
|
||||
}
|
||||
var section = overlay.Q("RunRouteChoices");
|
||||
var scroll = overlay.Q<ScrollView>(className: "repository-body");
|
||||
string context = $"{size}, {textSize}, milestone={milestone}";
|
||||
@@ -278,15 +396,9 @@ public class CombatLayoutTests
|
||||
Assert.That(_combat.AwaitingWaveContinue, Is.True, "Opening departure must not start the wave.");
|
||||
var confirm = overlay.Q<Button>("ConfirmRouteButton");
|
||||
if (milestone) Assert.That(confirm, Is.Null, context);
|
||||
else Assert.That(confirm.enabledInHierarchy, Is.EqualTo(nextWave != 3), context);
|
||||
if (nextWave == 3)
|
||||
{
|
||||
var target = section.Q<Label>("BuildRewardTarget");
|
||||
Assert.That(target, Is.Not.Null, context);
|
||||
Assert.That(target.text, Does.Contain(_run.RunDeck[0].Definition.DisplayName), context);
|
||||
AssertContainedHorizontally(target, scroll.contentViewport, context);
|
||||
Assert.That(section.Q<Button>("RewardBits"), Is.Not.Null, context);
|
||||
}
|
||||
else Assert.That(confirm.enabledInHierarchy, Is.True, context);
|
||||
Assert.That(section.Q("RouteEvent"), Is.Null, "Map browsing must not contain event controls.");
|
||||
Assert.That(section.Query<Label>().ToList().Any(label => label.text.Contains("THEN / WAVE")), Is.False);
|
||||
Assert.That(scroll.contentViewport.worldBound.height, Is.GreaterThan(35), context);
|
||||
foreach (var label in section.Query<Label>().ToList())
|
||||
{
|
||||
@@ -297,7 +409,9 @@ public class CombatLayoutTests
|
||||
}
|
||||
foreach (var button in section.Query<Button>().ToList())
|
||||
{
|
||||
scroll.ScrollTo(button);
|
||||
var routeScroll = section.Q<ScrollView>("RouteMapScroll");
|
||||
if (routeScroll != null && routeScroll.Contains(button)) routeScroll.ScrollTo(button);
|
||||
else scroll.ScrollTo(button);
|
||||
for (int frame = 0; frame < 2; frame++) yield return null;
|
||||
AssertContainedHorizontally(button, scroll.contentViewport, context);
|
||||
Assert.That(button.worldBound.yMin, Is.GreaterThanOrEqualTo(scroll.contentViewport.worldBound.yMin - 1), context);
|
||||
@@ -310,26 +424,34 @@ public class CombatLayoutTests
|
||||
{
|
||||
AssertContainedHorizontally(confirm, overlay, context);
|
||||
Assert.That(confirm.worldBound.yMax, Is.LessThanOrEqualTo(overlay.worldBound.yMax + 1), context);
|
||||
var challenge = overlay.Q<Button>("RouteChallenge");
|
||||
Assert.That(Mathf.Abs(back.worldBound.width - confirm.worldBound.width), Is.LessThanOrEqualTo(2), context);
|
||||
Assert.That(Mathf.Abs(back.worldBound.height - confirm.worldBound.height), Is.LessThanOrEqualTo(2), context);
|
||||
Assert.That(overlay.Q("RunMap"), Is.Not.Null, context);
|
||||
var canvas = overlay.Q("RouteCanvas");
|
||||
Assert.That(canvas, Is.Not.Null, "Trails and markers must share one continuous canvas.");
|
||||
foreach (var marker in canvas.Query(className: "route-map-node").ToList())
|
||||
{
|
||||
Assert.That(marker.parent, Is.SameAs(canvas), context);
|
||||
Assert.That(marker.layout.width, Is.EqualTo(60).Within(1), context);
|
||||
Assert.That(marker.layout.height, Is.EqualTo(60).Within(1), context);
|
||||
}
|
||||
if (nextWave == 2)
|
||||
{
|
||||
var here = canvas.Q("CurrentMapPosition");
|
||||
var selected = canvas.Q(className: "map-selected");
|
||||
Assert.That(here, Is.Not.Null, context);
|
||||
Assert.That(here.layout.center.y, Is.GreaterThan(selected.layout.center.y), "Travel proceeds upward from the player's position.");
|
||||
Assert.That(canvas.Query(className: "map-future").ToList().All(n => n.layout.center.y < selected.layout.center.y), Is.True, context);
|
||||
}
|
||||
var choice = _run.AvailableRouteNodes.FirstOrDefault(n => !RunRouteMap.IsEvent(n.Route)) ?? _run.AvailableRouteNodes[0];
|
||||
var challenge = overlay.Q<Button>("Route" + choice.Route);
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
{
|
||||
submit.target = challenge;
|
||||
challenge.SendEvent(submit);
|
||||
}
|
||||
Assert.That(_run.Journey.selectedRoute, Is.EqualTo(WaveRoute.Challenge), context);
|
||||
Assert.That(_run.Journey.selectedRoute, Is.EqualTo(choice.Route), context);
|
||||
Assert.That(overlay.Q("RouteSelectionScreen"), Is.Not.Null, "Route selection must survive refresh.");
|
||||
if (nextWave == 3)
|
||||
{
|
||||
int bitsBefore = _run.Bits;
|
||||
var reward = overlay.Q<Button>("RewardBits");
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
{
|
||||
submit.target = reward;
|
||||
reward.SendEvent(submit);
|
||||
}
|
||||
Assert.That(_run.Bits, Is.EqualTo(bitsBefore + RunManager.BuildRewardBits), context);
|
||||
Assert.That(overlay.Q<Button>("ConfirmRouteButton").enabledInHierarchy, Is.True, context);
|
||||
}
|
||||
}
|
||||
back = overlay.Q<Button>("BackToRepositoryButton");
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
@@ -340,11 +462,147 @@ public class CombatLayoutTests
|
||||
Assert.That(overlay.Q("RunRouteChoices"), Is.Null, context);
|
||||
Assert.That(overlay.Q(className: "repository-offers"), Is.Not.Null, context);
|
||||
Assert.That(overlay.Q<Button>("SaveAndExitRunButton").enabledInHierarchy, Is.True, context);
|
||||
if (!milestone) Assert.That(_run.Journey.selectedRoute, Is.EqualTo(WaveRoute.Challenge));
|
||||
if (!milestone) Assert.That(_run.AvailableRouteNodes.Any(n => n.Id == _run.Journey.selectedNodeId), Is.True);
|
||||
LogAssert.NoUnexpectedReceived();
|
||||
}
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator RewardScreenPreviewsWithoutMutatingAndOpensOnlyTheMapAfterClaim()
|
||||
{
|
||||
_run.RepositoryChanged += () => Call(_view, "RefreshOverlay");
|
||||
foreach (var size in Viewports)
|
||||
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
||||
{
|
||||
UIPreferences.TextSize = textSize; Resize(size);
|
||||
Set(_run, "currentWaveNumber", 3); Set(_run, "_wavesCleared", 2);
|
||||
_run.Journey.pendingRewardWave = 2;
|
||||
_run.GenerateRepositoryOffers(null, null);
|
||||
Set(_combat, "_awaitingWaveContinue", true);
|
||||
Set(_view, "_routeSelectionOpen", true); Set(_view, "_routeEventOpen", false);
|
||||
Call(_view, "RefreshOverlay");
|
||||
for (int frame = 0; frame < 6; frame++) yield return null;
|
||||
var screen = _root.Q("BuildRewardScreen");
|
||||
string context = $"reward {size} {textSize}";
|
||||
Assert.That(screen, Is.Not.Null, context);
|
||||
Assert.That(screen.Q("RunMap"), Is.Null, context);
|
||||
Assert.That(screen.Q("RouteEvent"), Is.Null, context);
|
||||
var scroll = screen.Q<ScrollView>(className: "repository-body");
|
||||
foreach (var label in screen.Q("BuildRewardChoices").Query<Label>().ToList())
|
||||
{
|
||||
AssertContainedHorizontally(label, scroll.contentViewport, context);
|
||||
float height = label.MeasureTextSize(label.text, label.contentRect.width,
|
||||
VisualElement.MeasureMode.AtMost, 0, VisualElement.MeasureMode.Undefined).y;
|
||||
Assert.That(height, Is.LessThanOrEqualTo(label.contentRect.height + 2), context + ": " + label.text);
|
||||
}
|
||||
foreach (string name in new[] { "BuildRewardCard", "RewardMagnitude", "RewardDraw" })
|
||||
{
|
||||
var control = screen.Q(name); scroll.ScrollTo(control);
|
||||
for (int frame = 0; frame < 2; frame++) yield return null;
|
||||
AssertContainedHorizontally(control, scroll.contentViewport, context);
|
||||
Assert.That(control.worldBound.yMin, Is.GreaterThanOrEqualTo(scroll.contentViewport.worldBound.yMin - 1), context);
|
||||
Assert.That(control.worldBound.yMax, Is.LessThanOrEqualTo(scroll.contentViewport.worldBound.yMax + 1), context);
|
||||
}
|
||||
foreach (string name in new[] { "ClaimBuildRewardButton", "RewardBits", "BackToRepositoryButton" })
|
||||
{
|
||||
var control = screen.Q(name);
|
||||
AssertContainedHorizontally(control, screen, context);
|
||||
Assert.That(control.worldBound.yMax, Is.LessThanOrEqualTo(screen.worldBound.yMax + 1), context);
|
||||
Assert.That(scroll.Contains(control), Is.False, "Reward actions must remain fixed outside the scrolling previews.");
|
||||
}
|
||||
var before = _run.RunDeck.Select(c => (c.MagnitudeBonus, c.DrawRider)).ToArray();
|
||||
var picker = screen.Q<DropdownField>("BuildRewardCard"); picker.index = Math.Min(1, _run.RunDeck.Count - 1);
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
{ var button = screen.Q<Button>("RewardDraw"); submit.target = button; button.SendEvent(submit); }
|
||||
Assert.That(_run.RunDeck.Select(c => (c.MagnitudeBonus, c.DrawRider)), Is.EqualTo(before), context);
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
{ var button = screen.Q<Button>("BackToRepositoryButton"); submit.target = button; button.SendEvent(submit); }
|
||||
Assert.That(_run.BuildRewardPending, Is.True, context);
|
||||
Assert.That(_root.Q("BuildRewardScreen"), Is.Null, context);
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
{ var button = _root.Q<Button>("BootNextWaveButton"); submit.target = button; button.SendEvent(submit); }
|
||||
Assert.That(_root.Q("BuildRewardScreen"), Is.Not.Null, context);
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
{ var button = _root.Q<Button>("RewardBits"); submit.target = button; button.SendEvent(submit); }
|
||||
Assert.That(_root.Q("BuildRewardScreen"), Is.Null, context);
|
||||
Assert.That(_root.Q("RouteSelectionScreen"), Is.Not.Null, context);
|
||||
Assert.That(_root.Q("RouteEventScreen"), Is.Null, context);
|
||||
Assert.That(_run.BuildRewardPending, Is.False, context);
|
||||
}
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator RewardUpgradeCommitsOnlyThePreviewedCardAndReturnsToMap()
|
||||
{
|
||||
_run.RepositoryChanged += () => Call(_view, "RefreshOverlay");
|
||||
Set(_run, "currentWaveNumber", 3); Set(_run, "_wavesCleared", 2);
|
||||
_run.Journey.pendingRewardWave = 2; _run.GenerateRepositoryOffers(null, null);
|
||||
Set(_combat, "_awaitingWaveContinue", true); Set(_view, "_routeSelectionOpen", true);
|
||||
Resize(new Vector2(1280, 720)); Call(_view, "RefreshOverlay");
|
||||
for (int frame = 0; frame < 5; frame++) yield return null;
|
||||
_root.Q<DropdownField>("BuildRewardCard").index = 1;
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
{ var button = _root.Q<Button>("RewardDraw"); submit.target = button; button.SendEvent(submit); }
|
||||
Assert.That(_run.RunDeck[1].DrawRider, Is.Zero, "Previewing must not grant the upgrade.");
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
{ var button = _root.Q<Button>("ClaimBuildRewardButton"); submit.target = button; button.SendEvent(submit); }
|
||||
Assert.That(_run.RunDeck[1].DrawRider, Is.EqualTo(1));
|
||||
Assert.That(_run.RunDeck[0].DrawRider, Is.Zero);
|
||||
Assert.That(_run.BuildRewardPending, Is.False);
|
||||
Assert.That(_root.Q("BuildRewardScreen"), Is.Null);
|
||||
Assert.That(_root.Q("RunMap"), Is.Not.Null);
|
||||
Assert.That(_root.Q("RouteEvent"), Is.Null);
|
||||
Assert.That(_run.ClaimBuildReward(_run.RunDeck[1], CardUpgradeKind.DrawRider), Is.False);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator SacrificeControlsAndCardPreviewsFitSmallScreens()
|
||||
{
|
||||
foreach (var size in new[] { new Vector2(1280, 720), new Vector2(390, 844), new Vector2(960, 400) })
|
||||
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
||||
{
|
||||
UIPreferences.TextSize = textSize; Resize(size);
|
||||
Set(_run, "currentWaveNumber", 2); Set(_run, "_wavesCleared", 1);
|
||||
_run.GenerateRepositoryOffers(null, null); _run.SelectRoute(WaveRoute.Sacrifice);
|
||||
Set(_combat, "_awaitingWaveContinue", true);
|
||||
Set(_view, "_routeSelectionOpen", true); Set(_view, "_routeEventOpen", true);
|
||||
var overlay = _root.Q(className: "overlay"); overlay.Clear(); overlay.style.display = DisplayStyle.Flex;
|
||||
overlay.Add((VisualElement)Call(_view, "BuildRouteSelectionView"));
|
||||
for (int frame = 0; frame < 6; frame++) yield return null;
|
||||
string context = $"Sacrifice {size} {textSize}";
|
||||
var scroll = overlay.Q<ScrollView>(className: "repository-body");
|
||||
var panel = overlay.Q("RouteEvent");
|
||||
Assert.That(panel, Is.Not.Null, context);
|
||||
Assert.That(overlay.Q("RouteEventScreen"), Is.Not.Null, context);
|
||||
Assert.That(overlay.Q("RunMap"), Is.Null, context);
|
||||
Assert.That(overlay.Q("BuildRewardChoices"), Is.Null, context);
|
||||
foreach (var label in panel.Query<Label>().ToList())
|
||||
{
|
||||
AssertContainedHorizontally(label, scroll.contentViewport, context);
|
||||
float height = label.MeasureTextSize(label.text, label.contentRect.width,
|
||||
VisualElement.MeasureMode.AtMost, 0, VisualElement.MeasureMode.Undefined).y;
|
||||
Assert.That(height, Is.LessThanOrEqualTo(label.contentRect.height + 2), context + ": " + label.text);
|
||||
}
|
||||
foreach (string name in new[] { "RouteDonor", "RouteTarget" })
|
||||
{
|
||||
var control = panel.Q(name); Assert.That(control, Is.Not.Null, context + " " + name);
|
||||
scroll.ScrollTo(control);
|
||||
for (int frame = 0; frame < 3; frame++) yield return null;
|
||||
AssertContainedHorizontally(control, scroll.contentViewport, context);
|
||||
Assert.That(control.worldBound.yMin, Is.GreaterThanOrEqualTo(scroll.contentViewport.worldBound.yMin - 1), context);
|
||||
Assert.That(control.worldBound.yMax, Is.LessThanOrEqualTo(scroll.contentViewport.worldBound.yMax + 1), context);
|
||||
}
|
||||
foreach (string name in new[] { "ResolveRouteEventButton", "SkipRouteEventButton", "BackToRouteButton" })
|
||||
{
|
||||
var control = overlay.Q(name);
|
||||
AssertContainedHorizontally(control, overlay, context);
|
||||
Assert.That(control.worldBound.yMax, Is.LessThanOrEqualTo(overlay.worldBound.yMax + 1), context);
|
||||
Assert.That(scroll.Contains(control), Is.False, "Event actions must remain fixed outside the scrolling previews.");
|
||||
}
|
||||
Assert.That(overlay.Q<Button>("ConfirmRouteButton"), Is.Null, context);
|
||||
}
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator ExecutionPreviewWrapsAndDoesNotDisplaceDispatchControls()
|
||||
{
|
||||
@@ -604,7 +862,7 @@ public class CombatLayoutTests
|
||||
for (int frame = 0; frame < 4; frame++) yield return null;
|
||||
var chip = _root.Query(className: "card-chip").ToList().Single(item => item.userData == second);
|
||||
Assert.That(chip.focusable, Is.True);
|
||||
Assert.That(chip.tooltip, Does.Contain("Haskell captured: x1.5"));
|
||||
Assert.That(chip.tooltip, Does.Contain("Haskell captured: x1.75"));
|
||||
Assert.That(chip.tooltip, Does.Contain("Already played"));
|
||||
Assert.That(chip.tooltip, Does.Not.Contain("Successful play package Shield"));
|
||||
Assert.That(chip.tooltip, Does.Contain("Compilation 0/4"));
|
||||
@@ -613,7 +871,7 @@ public class CombatLayoutTests
|
||||
Call(_view, "RefreshTracks");
|
||||
Assert.That(_root.focusController.focusedElement, Is.SameAs(chip));
|
||||
Assert.That(chip.tooltip, Does.Contain("Compilation 1/4"));
|
||||
Assert.That(chip.tooltip, Does.Contain("Haskell captured: x1.5"));
|
||||
Assert.That(chip.tooltip, Does.Contain("Haskell captured: x1.75"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using KernelPanic.Meta;
|
||||
using KernelPanic.Data;
|
||||
using KernelPanic.UI;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class DailyQuestLayoutTests
|
||||
{
|
||||
[Test]
|
||||
public void WidgetAndDetailsDistinguishAllThreeStatesWithoutAdditionalFocusTargets()
|
||||
{
|
||||
var state = new DailyQuestState
|
||||
{
|
||||
selectedQuests = new[] { DailyQuestKind.Cards, DailyQuestKind.Damage, DailyQuestKind.Waves },
|
||||
cards = 15, damage = 200, waves = 3, claimedMask = 1 << (int)DailyQuestKind.Waves,
|
||||
refreshAtUtcTicks = DateTime.UtcNow.AddHours(12).Ticks
|
||||
};
|
||||
var widget = DailyQuestView.BuildWidget(state, DateTime.UtcNow, () => { });
|
||||
Assert.That(widget.Q<Label>("DailyQuestRewardReady").text, Is.EqualTo("1 reward ready"));
|
||||
Assert.That(widget.Q<Label>("DailyQuestCompleted").text, Is.EqualTo("2/3 completed"));
|
||||
Assert.That(widget.Q<Label>("DailyQuestClaimed").text, Is.EqualTo("1 claimed"));
|
||||
foreach (var child in widget.Query<VisualElement>().ToList().Where(child => child != widget))
|
||||
Assert.That(child.pickingMode, Is.EqualTo(PickingMode.Ignore), "Every part of the widget belongs to its button.");
|
||||
var overlay = DailyQuestView.BuildOverlay(state, DateTime.UtcNow, (_, _) => { }, () => { });
|
||||
Assert.That(overlay.Q<Button>("ClaimDailyQuestCards").text, Is.EqualTo("[ in progress ]"));
|
||||
Assert.That(overlay.Q<Button>("ClaimDailyQuestDamage").text, Is.EqualTo("> CLAIM REWARD"));
|
||||
Assert.That(overlay.Q<Button>("ClaimDailyQuestWaves").text, Is.EqualTo("[ CLAIMED ]"));
|
||||
Assert.That(overlay.Q<Button>("ClaimDailyQuestCards").enabledSelf, Is.False);
|
||||
Assert.That(overlay.Q<Button>("ClaimDailyQuestDamage").enabledSelf, Is.True);
|
||||
Assert.That(overlay.Q<Button>("ClaimDailyQuestWaves").enabledSelf, Is.False);
|
||||
Assert.That(overlay.Q("DailyQuestCards").Q<Label>(className: "daily-detail-progress").text, Is.EqualTo("[######....]"));
|
||||
foreach (var label in overlay.Query<Label>(className: "daily-detail-progress").ToList())
|
||||
Assert.That(label.text.Length, Is.EqualTo(12));
|
||||
state.claimedMask |= 1 << (int)DailyQuestKind.Damage;
|
||||
widget = DailyQuestView.BuildWidget(state, DateTime.UtcNow, () => { });
|
||||
Assert.That(widget.Q("DailyQuestRewardReady").style.display.value, Is.EqualTo(DisplayStyle.None));
|
||||
Assert.That(widget.Q<Label>("DailyQuestInspect").text, Is.EqualTo("> inspect tasks"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator MenuQuestsWrapAndClaimsRemainReachableAcrossViewports()
|
||||
{
|
||||
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null)
|
||||
Assert.Ignore("Requires a rendered editor panel.");
|
||||
var window = ScriptableObject.CreateInstance<TerminalFocusTestWindow>();
|
||||
var previousSize = UIPreferences.TextSize;
|
||||
try
|
||||
{
|
||||
window.minSize = new Vector2(100, 100);
|
||||
window.maxSize = new Vector2(4000, 3000);
|
||||
window.Show();
|
||||
var root = window.rootVisualElement;
|
||||
// Match UIDocument stylesheet scope and order, including the later readability sheet.
|
||||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/MainMenu.uxml").CloneTree(root);
|
||||
var font = typeof(MainMenuController).Assembly.GetType("KernelPanic.UI.TerminalFontResolver")
|
||||
.GetMethod("Resolve").Invoke(null, new object[] { null }) as UnityEngine.TextCore.Text.FontAsset;
|
||||
root.style.unityFontDefinition = new StyleFontDefinition(font);
|
||||
typeof(MainMenuController).Assembly.GetType("KernelPanic.UI.TerminalTheme")
|
||||
.GetMethod("Attach", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { root });
|
||||
root.Q("BootIntroPanel").style.display = DisplayStyle.None;
|
||||
root.Q("ShellRoot").style.opacity = 1;
|
||||
var featured = new FeaturedUnitPanel();
|
||||
featured.Bind(root, null);
|
||||
featured.Refresh(new[] { AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Ubuntu.asset") });
|
||||
var scroll = root.Q<ScrollView>(className: "home-scroll");
|
||||
// 1024x576 also covers 1280x720 with the player's 1.25 panel scale.
|
||||
foreach (var size in new[] { new Vector2(1920, 1080), new Vector2(1366, 768), new Vector2(1280, 720), new Vector2(1024, 576), new Vector2(390, 844), new Vector2(960, 400) })
|
||||
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
||||
foreach (int group in new[] { 0, 3, 6 })
|
||||
{
|
||||
UIPreferences.TextSize = textSize;
|
||||
window.position = new Rect(20, 20, size.x, size.y);
|
||||
root.style.width = size.x;
|
||||
root.style.height = size.y;
|
||||
var data = SaveData.CreateDefault();
|
||||
var now = DateTime.UtcNow;
|
||||
DailyQuests.Refresh(data.dailyQuests, now);
|
||||
data.dailyQuests.selectedQuests = new[] { DailyQuests.Pool[group],
|
||||
DailyQuests.Pool[(group + 1) % DailyQuests.Pool.Count], DailyQuests.Pool[(group + 2) % DailyQuests.Pool.Count] };
|
||||
foreach (var kind in DailyQuests.Active(data.dailyQuests))
|
||||
DailyQuests.Record(data.dailyQuests, kind, int.MaxValue, now);
|
||||
var host = root.Q("DailyQuestsHost");
|
||||
host.Clear();
|
||||
VisualElement overlay = null;
|
||||
void RefreshWidget()
|
||||
{
|
||||
host.Clear();
|
||||
host.Add(DailyQuestView.BuildWidget(data.dailyQuests, now, () =>
|
||||
{
|
||||
overlay = DailyQuestView.BuildOverlay(data.dailyQuests, now, (kind, period) =>
|
||||
{
|
||||
Assert.That(DailyQuests.Claim(data, kind, period, now), Is.True);
|
||||
RefreshWidget();
|
||||
}, () => overlay.RemoveFromHierarchy());
|
||||
root.Add(overlay);
|
||||
}));
|
||||
}
|
||||
RefreshWidget();
|
||||
scroll.scrollOffset = Vector2.zero;
|
||||
for (int frame = 0; frame < 6; frame++) yield return null;
|
||||
string context = $"{size}, {textSize}";
|
||||
Assert.That(host.Query(className: "daily-service-entry").ToList().Count, Is.EqualTo(3), context);
|
||||
Assert.That(host.Q<ProgressBar>(), Is.Null);
|
||||
Assert.That(host.parent, Is.SameAs(root.Q("FeaturedUnitPanel").parent));
|
||||
Assert.That(host.worldBound.yMin, Is.GreaterThanOrEqualTo(root.Q("FeaturedUnitPanel").worldBound.yMax - 1), context);
|
||||
if (size.x >= 1280)
|
||||
{
|
||||
Assert.That(host.worldBound.yMax, Is.LessThanOrEqualTo(scroll.contentViewport.worldBound.yMax + 1), context + ": fits below neofetch");
|
||||
Assert.That(host.worldBound.xMin, Is.GreaterThan(root.Q(className: "command-column").worldBound.xMin + 300), context);
|
||||
}
|
||||
foreach (var label in host.Query<Label>().ToList())
|
||||
{
|
||||
Assert.That(label.worldBound.xMin, Is.GreaterThanOrEqualTo(scroll.contentViewport.worldBound.xMin - 1), context);
|
||||
Assert.That(label.worldBound.xMax, Is.LessThanOrEqualTo(scroll.contentViewport.worldBound.xMax + 1), context);
|
||||
float needed = label.MeasureTextSize(label.text, label.contentRect.width,
|
||||
VisualElement.MeasureMode.AtMost, 0, VisualElement.MeasureMode.Undefined).y;
|
||||
Assert.That(label.contentRect.height + 2, Is.GreaterThanOrEqualTo(needed), context + ": " + label.text);
|
||||
}
|
||||
var before = root.Q(className: "content-row").worldBound;
|
||||
using (var submit = NavigationSubmitEvent.GetPooled())
|
||||
{
|
||||
var widget = host.Q<Button>("DailyQuestWidget");
|
||||
submit.target = widget;
|
||||
widget.SendEvent(submit);
|
||||
}
|
||||
for (int frame = 0; frame < 6; frame++) yield return null;
|
||||
Assert.That(root.Q(className: "content-row").worldBound.yMin, Is.EqualTo(before.yMin).Within(1), "Opening details cannot push the menu downward.");
|
||||
Assert.That(root.Q(className: "content-row").worldBound.height, Is.EqualTo(before.height).Within(1), "Details must not add menu height.");
|
||||
var dialog = overlay.Q("DailyQuestDialog");
|
||||
Assert.That(dialog.worldBound.xMin, Is.GreaterThanOrEqualTo(0), context);
|
||||
Assert.That(dialog.worldBound.xMax, Is.LessThanOrEqualTo(size.x + 1), context);
|
||||
Assert.That(dialog.worldBound.yMin, Is.GreaterThanOrEqualTo(0), context);
|
||||
Assert.That(dialog.worldBound.yMax, Is.LessThanOrEqualTo(size.y + 1), context);
|
||||
var details = overlay.Q<ScrollView>("DailyQuestDetailScroll");
|
||||
// Include the two-line confirmation in the desktop fit requirement.
|
||||
var feedback = overlay.Q<Label>("DailyQuestFeedback");
|
||||
feedback.text = "[ OK ] Daily task completed.\n[ OK ] +250 Bandwidth, +125 Entropy deposited.";
|
||||
feedback.style.display = DisplayStyle.Flex;
|
||||
for (int frame = 0; frame < 3; frame++) yield return null;
|
||||
if (size.x >= 1024 && size.y >= 576)
|
||||
Assert.That(details.contentContainer.worldBound.height, Is.LessThanOrEqualTo(details.contentViewport.worldBound.height + 1),
|
||||
context + ": all three tasks fit without scrolling, including feedback");
|
||||
if (size.y <= 400)
|
||||
Assert.That(details.contentContainer.worldBound.height, Is.GreaterThan(details.contentViewport.worldBound.height), context + ": short viewports scroll");
|
||||
var headerBounds = overlay.Q("DailyQuestHeader").worldBound;
|
||||
foreach (var kind in DailyQuests.Active(data.dailyQuests))
|
||||
{
|
||||
var reward = DailyQuests.Reward(kind);
|
||||
Assert.That(details.Q("DailyQuest" + kind).Query<Label>().ToList().Select(label => label.text),
|
||||
Does.Contain($"+{reward.Bandwidth} Bandwidth / +{reward.Entropy} Entropy"));
|
||||
}
|
||||
foreach (var label in details.Query<Label>().ToList())
|
||||
{
|
||||
Assert.That(label.worldBound.xMax, Is.LessThanOrEqualTo(details.contentViewport.worldBound.xMax + 1), context + label.text);
|
||||
float needed = label.MeasureTextSize(label.text, label.contentRect.width,
|
||||
VisualElement.MeasureMode.AtMost, 0, VisualElement.MeasureMode.Undefined).y;
|
||||
Assert.That(label.contentRect.height + 2, Is.GreaterThanOrEqualTo(needed), context + label.text);
|
||||
}
|
||||
foreach (var button in details.Query<Button>().ToList())
|
||||
{
|
||||
details.ScrollTo(button);
|
||||
for (int frame = 0; frame < 3; frame++) yield return null;
|
||||
Assert.That(overlay.Q("DailyQuestHeader").worldBound, Is.EqualTo(headerBounds), "The header stays fixed while scrolling.");
|
||||
Assert.That(button.worldBound.yMin, Is.GreaterThanOrEqualTo(details.contentViewport.worldBound.yMin - 1), context);
|
||||
Assert.That(button.worldBound.yMax, Is.LessThanOrEqualTo(details.contentViewport.worldBound.yMax + 1), context);
|
||||
using var submit = NavigationSubmitEvent.GetPooled();
|
||||
submit.target = button;
|
||||
button.SendEvent(submit);
|
||||
}
|
||||
Assert.That(data.bandwidthBalance, Is.EqualTo(DailyQuests.Active(data.dailyQuests).Sum(kind => DailyQuests.Reward(kind).Bandwidth)));
|
||||
Assert.That(data.entropyBalance, Is.EqualTo(DailyQuests.Active(data.dailyQuests).Sum(kind => DailyQuests.Reward(kind).Entropy)));
|
||||
Assert.That(host.Q<Label>("DailyQuestCompleted").text, Is.EqualTo("3/3 completed"));
|
||||
Assert.That(host.Q("DailyQuestRewardReady").style.display.value, Is.EqualTo(DisplayStyle.None));
|
||||
using (var escape = KeyDownEvent.GetPooled(new Event { type = EventType.KeyDown, keyCode = KeyCode.Escape }))
|
||||
{
|
||||
escape.target = overlay.Q<Button>("CloseDailyQuests");
|
||||
overlay.Q<Button>("CloseDailyQuests").SendEvent(escape);
|
||||
}
|
||||
Assert.That(root.Q("DailyQuestOverlay"), Is.Null);
|
||||
LogAssert.NoUnexpectedReceived();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
UIPreferences.TextSize = previousSize;
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a41d2608975f4d4c99e00d5f20eeac05
|
||||
@@ -0,0 +1,344 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using KernelPanic.Combat;
|
||||
using KernelPanic.Core;
|
||||
using KernelPanic.Meta;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
public class DailyQuestTests
|
||||
{
|
||||
private static readonly DateTime Start = new(2026, 10, 24, 12, 30, 0, DateTimeKind.Utc);
|
||||
private string _directory;
|
||||
private SaveService _save;
|
||||
|
||||
private static SaveData FixedQuests()
|
||||
{
|
||||
var data = SaveData.CreateDefault();
|
||||
data.dailyQuests.refreshAtUtcTicks = Start.AddDays(1).Ticks;
|
||||
data.dailyQuests.selectionSeed = 17;
|
||||
DailyQuests.Refresh(data.dailyQuests, Start);
|
||||
return data;
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_directory = Path.Combine(Path.GetTempPath(), "KernelPanic-DailyTests-" + Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(_directory);
|
||||
_save = new SaveService(Path.Combine(_directory, "save.json"));
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown() => Directory.Delete(_directory, true);
|
||||
|
||||
[Test]
|
||||
public void LegacyDataStartsWithThreeEmptyQuestsWithoutChangingBalances()
|
||||
{
|
||||
var data = JsonUtility.FromJson<SaveData>("{\"entropyBalance\":73,\"bandwidthBalance\":129}");
|
||||
data.EnsureLists();
|
||||
Assert.That(DailyQuests.Refresh(data.dailyQuests, Start), Is.True);
|
||||
Assert.That(data.dailyQuests.refreshAtUtcTicks, Is.EqualTo(Start.AddHours(24).Ticks));
|
||||
for (int i = 0; i < DailyQuests.Count; i++)
|
||||
{
|
||||
Assert.That(DailyQuests.Progress(data.dailyQuests, (DailyQuestKind)i), Is.Zero);
|
||||
Assert.That(DailyQuests.Claimed(data.dailyQuests, (DailyQuestKind)i), Is.False);
|
||||
}
|
||||
Assert.That(data.entropyBalance, Is.EqualTo(73));
|
||||
Assert.That(data.bandwidthBalance, Is.EqualTo(129));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResetOccursAtExactlyTwentyFourHoursAndKeepsItsAnchorAfterDaysAway()
|
||||
{
|
||||
var data = FixedQuests();
|
||||
DailyQuests.Record(data.dailyQuests, DailyQuestKind.Waves, 3, Start);
|
||||
long firstPeriod = data.dailyQuests.refreshAtUtcTicks;
|
||||
Assert.That(DailyQuests.Refresh(data.dailyQuests, Start.AddDays(1).AddTicks(-1)), Is.False);
|
||||
Assert.That(DailyQuests.Refresh(data.dailyQuests, Start.AddDays(1)), Is.True);
|
||||
Assert.That(data.dailyQuests.waves, Is.Zero);
|
||||
Assert.That(DailyQuests.Claim(data, DailyQuestKind.Waves, firstPeriod, Start.AddDays(1)), Is.False);
|
||||
DailyQuests.Record(data.dailyQuests, DailyQuestKind.Cards, 10, Start.AddDays(1));
|
||||
Assert.That(DailyQuests.Refresh(data.dailyQuests, Start.AddDays(8).AddHours(7)), Is.True);
|
||||
Assert.That(data.dailyQuests.refreshAtUtcTicks, Is.EqualTo(Start.AddDays(9).Ticks));
|
||||
Assert.That(data.dailyQuests.cards, Is.Zero);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ClockRollbackDoesNotResetClaimsOrMoveTheDeadline()
|
||||
{
|
||||
var data = FixedQuests();
|
||||
DailyQuests.Record(data.dailyQuests, DailyQuestKind.Cards, 25, Start);
|
||||
long period = data.dailyQuests.refreshAtUtcTicks;
|
||||
Assert.That(DailyQuests.Claim(data, DailyQuestKind.Cards, period, Start), Is.True);
|
||||
Assert.That(DailyQuests.Refresh(data.dailyQuests, Start.AddHours(-2)), Is.False);
|
||||
Assert.That(data.dailyQuests.refreshAtUtcTicks, Is.EqualTo(period));
|
||||
Assert.That(DailyQuests.Claim(data, DailyQuestKind.Cards, period, Start.AddHours(-2)), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EachQuestPaysBothCurrenciesExactlyOnceAndSurvivesReload()
|
||||
{
|
||||
var data = FixedQuests();
|
||||
DailyQuests.Refresh(data.dailyQuests, Start);
|
||||
long period = data.dailyQuests.refreshAtUtcTicks;
|
||||
for (int i = 0; i < DailyQuests.Count; i++)
|
||||
{
|
||||
var kind = (DailyQuestKind)i;
|
||||
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.False);
|
||||
DailyQuests.Record(data.dailyQuests, kind, -1, Start);
|
||||
Assert.That(DailyQuests.Progress(data.dailyQuests, kind), Is.Zero);
|
||||
DailyQuests.Record(data.dailyQuests, kind, int.MaxValue, Start);
|
||||
Assert.That(DailyQuests.Progress(data.dailyQuests, kind), Is.EqualTo(DailyQuests.Target(kind)));
|
||||
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.True);
|
||||
_save.Save(data);
|
||||
data = _save.Load();
|
||||
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.False);
|
||||
}
|
||||
Assert.That(data.bandwidthBalance, Is.EqualTo(325));
|
||||
Assert.That(data.entropyBalance, Is.EqualTo(150));
|
||||
DailyQuests.Refresh(data.dailyQuests, Start.AddDays(1));
|
||||
var nextQuest = DailyQuests.Active(data.dailyQuests)[0];
|
||||
DailyQuests.Record(data.dailyQuests, nextQuest, int.MaxValue, Start.AddDays(1));
|
||||
Assert.That(DailyQuests.Claim(data, nextQuest, period, Start.AddDays(1)), Is.False,
|
||||
"An old button cannot claim a newly completed quest.");
|
||||
Assert.That(DailyQuests.Claim(data, nextQuest, data.dailyQuests.refreshAtUtcTicks, Start.AddDays(1)), Is.True);
|
||||
}
|
||||
|
||||
[TestCase(DailyQuestKind.Cards, 75, 25)]
|
||||
[TestCase(DailyQuestKind.NativeCards, 75, 25)]
|
||||
[TestCase(DailyQuestKind.Damage, 100, 50)]
|
||||
[TestCase(DailyQuestKind.BlockDamage, 100, 50)]
|
||||
[TestCase(DailyQuestKind.Waves, 150, 75)]
|
||||
[TestCase(DailyQuestKind.ShieldDamage, 150, 75)]
|
||||
[TestCase(DailyQuestKind.SurviveRounds, 150, 75)]
|
||||
[TestCase(DailyQuestKind.WaveFive, 250, 125)]
|
||||
public void DifficultyRewardsPayExactAmountsOnceAcrossReload(DailyQuestKind kind, int bandwidth, int entropy)
|
||||
{
|
||||
var data = FixedQuests();
|
||||
data.dailyQuests.selectedQuests = new[] { kind }.Concat(DailyQuests.Pool.Where(other => other != kind).Take(2)).ToArray();
|
||||
data.bandwidthBalance = 37;
|
||||
data.entropyBalance = 19;
|
||||
long period = data.dailyQuests.refreshAtUtcTicks;
|
||||
Assert.That(DailyQuests.Reward(kind), Is.EqualTo((bandwidth, entropy)));
|
||||
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.False);
|
||||
DailyQuests.Record(data.dailyQuests, kind, int.MaxValue, Start);
|
||||
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.True);
|
||||
_save.Save(data);
|
||||
data = _save.Load();
|
||||
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.False);
|
||||
Assert.That(data.bandwidthBalance, Is.EqualTo(37 + bandwidth));
|
||||
Assert.That(data.entropyBalance, Is.EqualTo(19 + entropy));
|
||||
Assert.That(data.dailyQuests.refreshAtUtcTicks, Is.EqualTo(period));
|
||||
Assert.That(DailyQuests.Progress(data.dailyQuests, kind), Is.EqualTo(DailyQuests.Target(kind)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EveryRewardChecksBothBalancesBeforeChangingEitherCurrencyOrClaimFlag()
|
||||
{
|
||||
foreach (var kind in DailyQuests.Pool)
|
||||
{
|
||||
var data = FixedQuests();
|
||||
data.dailyQuests.selectedQuests = new[] { kind }.Concat(DailyQuests.Pool.Where(other => other != kind).Take(2)).ToArray();
|
||||
DailyQuests.Record(data.dailyQuests, kind, int.MaxValue, Start);
|
||||
long period = data.dailyQuests.refreshAtUtcTicks;
|
||||
var reward = DailyQuests.Reward(kind);
|
||||
foreach (bool overflowBandwidth in new[] { true, false })
|
||||
{
|
||||
int bandwidth = int.MaxValue - reward.Bandwidth + (overflowBandwidth ? 1 : 0);
|
||||
int entropy = int.MaxValue - reward.Entropy + (overflowBandwidth ? 0 : 1);
|
||||
data.bandwidthBalance = bandwidth;
|
||||
data.entropyBalance = entropy;
|
||||
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.False, kind.ToString());
|
||||
Assert.That(data.bandwidthBalance, Is.EqualTo(bandwidth));
|
||||
Assert.That(data.entropyBalance, Is.EqualTo(entropy));
|
||||
Assert.That(DailyQuests.Claimed(data.dailyQuests, kind), Is.False);
|
||||
}
|
||||
data.bandwidthBalance = int.MaxValue - reward.Bandwidth;
|
||||
data.entropyBalance = int.MaxValue - reward.Entropy;
|
||||
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.True);
|
||||
Assert.That(data.bandwidthBalance, Is.EqualTo(int.MaxValue));
|
||||
Assert.That(data.entropyBalance, Is.EqualTo(int.MaxValue));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PreviouslyPaidFlatRewardCannotBeClaimedAgainAfterRewardChange()
|
||||
{
|
||||
var data = FixedQuests();
|
||||
data.dailyQuests.waves = 3;
|
||||
data.dailyQuests.claimedMask = 1 << (int)DailyQuestKind.Waves;
|
||||
data.bandwidthBalance = 100;
|
||||
data.entropyBalance = 50;
|
||||
_save.Save(data);
|
||||
data = _save.Load();
|
||||
Assert.That(DailyQuests.Claim(data, DailyQuestKind.Waves, data.dailyQuests.refreshAtUtcTicks, Start), Is.False);
|
||||
Assert.That(data.bandwidthBalance, Is.EqualTo(100));
|
||||
Assert.That(data.entropyBalance, Is.EqualTo(50));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GameplayPersistsAcrossTrackerRecreationAndIgnoresIneligibleAndIncomingDamage()
|
||||
{
|
||||
bool eligible = false;
|
||||
var player = new CombatantState(100, 6, 3);
|
||||
var enemy = new CombatantState(100, 6, 3);
|
||||
using (var tracker = new DailyQuestTracker(_save, () => eligible, () => player, () => Start))
|
||||
{
|
||||
GameEvents.RaiseWaveCleared(new WaveClearedEvent(1));
|
||||
GameEvents.RaiseCardPlayed(default);
|
||||
GameEvents.RaiseDamageDealt(new DamageDealtEvent(player, enemy, 20, Language.C));
|
||||
Assert.That(File.Exists(_save.SavePath), Is.False, "Tutorial or suspended runs cannot progress quests.");
|
||||
_save.Save(FixedQuests());
|
||||
eligible = true;
|
||||
GameEvents.RaiseWaveCleared(new WaveClearedEvent(1));
|
||||
GameEvents.RaiseCardPlayed(default);
|
||||
GameEvents.RaiseDamageDealt(new DamageDealtEvent(player, enemy, 20, Language.C));
|
||||
GameEvents.RaiseDamageDealt(new DamageDealtEvent(enemy, player, 50, Language.C));
|
||||
GameEvents.RaiseDamageDealt(new DamageDealtEvent(player, player, 50, Language.C));
|
||||
GameEvents.RaiseDamageDealt(new DamageDealtEvent(player, enemy, 20, Language.C, 20, 20, false, 20, 0));
|
||||
}
|
||||
var saved = _save.Load();
|
||||
Assert.That(saved.dailyQuests.waves, Is.EqualTo(1));
|
||||
Assert.That(saved.dailyQuests.cards, Is.EqualTo(1));
|
||||
Assert.That(saved.dailyQuests.damage, Is.EqualTo(20));
|
||||
saved.bandwidthBalance = 451;
|
||||
_save.Save(saved);
|
||||
using (var tracker = new DailyQuestTracker(_save, () => true, () => player, () => Start))
|
||||
GameEvents.RaiseWaveCleared(new WaveClearedEvent(2));
|
||||
GameEvents.RaiseWaveCleared(new WaveClearedEvent(3)); // Disposed subscriptions must not keep counting.
|
||||
Assert.That(_save.Load().dailyQuests.waves, Is.EqualTo(2));
|
||||
Assert.That(_save.Load().bandwidthBalance, Is.EqualTo(451));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FailedProgressSaveRetriesWithoutDroppingOrDuplicatingEvents()
|
||||
{
|
||||
_save.Save(FixedQuests());
|
||||
using var tracker = new DailyQuestTracker(_save, () => true, () => null, () => Start);
|
||||
using (var locked = new FileStream(_save.SavePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
|
||||
{
|
||||
GameEvents.RaiseCardPlayed(default);
|
||||
GameEvents.RaiseCardPlayed(default);
|
||||
Assert.That(tracker.SaveError, Is.Not.Null);
|
||||
}
|
||||
Assert.That(tracker.Flush(), Is.True);
|
||||
Assert.That(tracker.SaveError, Is.Null);
|
||||
Assert.That(_save.Load().dailyQuests.cards, Is.EqualTo(2));
|
||||
tracker.Flush();
|
||||
Assert.That(_save.Load().dailyQuests.cards, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExpiredPendingProgressCannotLeakIntoTheNewDay()
|
||||
{
|
||||
var now = Start;
|
||||
var data = FixedQuests();
|
||||
DailyQuests.Refresh(data.dailyQuests, now);
|
||||
_save.Save(data);
|
||||
using var tracker = new DailyQuestTracker(_save, () => true, () => null, () => now);
|
||||
using (var locked = new FileStream(_save.SavePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
|
||||
GameEvents.RaiseCardPlayed(default);
|
||||
now = Start.AddDays(1);
|
||||
GameEvents.RaiseCardPlayed(default);
|
||||
var state = _save.Load().dailyQuests;
|
||||
Assert.That(state.cards, Is.EqualTo(DailyQuests.IsActive(state, DailyQuestKind.Cards) ? 1 : 0));
|
||||
Assert.That(_save.Load().dailyQuests.refreshAtUtcTicks, Is.EqualTo(Start.AddDays(2).Ticks));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RandomSelectionIsDistinctPersistentVariedAndDoesNotConsumeUnityRandom()
|
||||
{
|
||||
var data = SaveData.CreateDefault();
|
||||
data.dailyQuests.selectionSeed = 731;
|
||||
var randomBefore = UnityEngine.Random.state;
|
||||
var seen = new System.Collections.Generic.HashSet<DailyQuestKind>();
|
||||
DailyQuestKind[] previous = null;
|
||||
for (int day = 0; day < 120; day++)
|
||||
{
|
||||
var now = Start.AddDays(day);
|
||||
Assert.That(DailyQuests.Refresh(data.dailyQuests, now), Is.True);
|
||||
var active = DailyQuests.Active(data.dailyQuests).ToArray();
|
||||
Assert.That(active.Length, Is.EqualTo(3));
|
||||
Assert.That(active.Distinct().Count(), Is.EqualTo(3));
|
||||
Assert.That(active.All(kind => DailyQuests.Pool.Contains(kind)), Is.True);
|
||||
if (previous != null) Assert.That(active, Is.Not.EquivalentTo(previous));
|
||||
foreach (var kind in active) seen.Add(kind);
|
||||
_save.Save(data);
|
||||
data = _save.Load();
|
||||
Assert.That(DailyQuests.Refresh(data.dailyQuests, now.AddHours(5)), Is.False);
|
||||
Assert.That(DailyQuests.Active(data.dailyQuests), Is.EqualTo(active));
|
||||
previous = active;
|
||||
}
|
||||
Assert.That(seen, Is.EquivalentTo(DailyQuests.Pool));
|
||||
Assert.That(UnityEngine.Random.state, Is.EqualTo(randomBefore));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpgradingAnActiveFixedDayPreservesProgressAndClaimsUntilReset()
|
||||
{
|
||||
var data = SaveData.CreateDefault();
|
||||
data.dailyQuests.refreshAtUtcTicks = Start.AddDays(1).Ticks;
|
||||
data.dailyQuests.waves = 3;
|
||||
data.dailyQuests.cards = 7;
|
||||
data.dailyQuests.claimedMask = 1;
|
||||
Assert.That(DailyQuests.Refresh(data.dailyQuests, Start), Is.True);
|
||||
Assert.That(DailyQuests.Active(data.dailyQuests), Is.EqualTo(new[] { DailyQuestKind.Waves, DailyQuestKind.Cards, DailyQuestKind.Damage }));
|
||||
Assert.That(data.dailyQuests.waves, Is.EqualTo(3));
|
||||
Assert.That(data.dailyQuests.cards, Is.EqualTo(7));
|
||||
Assert.That(DailyQuests.Claim(data, DailyQuestKind.Waves, data.dailyQuests.refreshAtUtcTicks, Start), Is.False);
|
||||
DailyQuests.Refresh(data.dailyQuests, Start.AddDays(1));
|
||||
Assert.That(data.dailyQuests.claimedMask, Is.Zero);
|
||||
Assert.That(data.dailyQuests.cards, Is.Zero);
|
||||
Assert.That(DailyQuests.Active(data.dailyQuests), Is.Not.EquivalentTo(new[] { DailyQuestKind.Waves, DailyQuestKind.Cards, DailyQuestKind.Damage }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InactiveQuestsCannotAccumulateProgressOrPayRewards()
|
||||
{
|
||||
var data = FixedQuests();
|
||||
foreach (var kind in DailyQuests.Pool.Where(kind => !DailyQuests.IsActive(data.dailyQuests, kind)))
|
||||
{
|
||||
Assert.That(DailyQuests.Record(data.dailyQuests, kind, int.MaxValue, Start), Is.False);
|
||||
Assert.That(DailyQuests.Progress(data.dailyQuests, kind), Is.Zero);
|
||||
Assert.That(DailyQuests.Claim(data, kind, data.dailyQuests.refreshAtUtcTicks, Start), Is.False);
|
||||
}
|
||||
Assert.That(data.bandwidthBalance, Is.Zero);
|
||||
Assert.That(data.entropyBalance, Is.Zero);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddedCombatObjectivesCountOnlyTheMatchingGameplay()
|
||||
{
|
||||
var data = FixedQuests();
|
||||
data.dailyQuests.selectedQuests = new[] { DailyQuestKind.BlockDamage, DailyQuestKind.ShieldDamage, DailyQuestKind.NativeCards };
|
||||
_save.Save(data);
|
||||
var player = new CombatantState(100, 6, 3);
|
||||
var enemy = new CombatantState(100, 6, 3);
|
||||
using var tracker = new DailyQuestTracker(_save, () => true, () => player, () => Start);
|
||||
GameEvents.RaiseCardPlayed(new CardPlayedEvent(null, ResolutionTrack.Native));
|
||||
GameEvents.RaiseCardPlayed(new CardPlayedEvent(null, ResolutionTrack.InterpreterQueue));
|
||||
GameEvents.RaiseCardPlayed(new CardPlayedEvent(null, ResolutionTrack.LazyStack));
|
||||
GameEvents.RaiseDamageDealt(new DamageDealtEvent(enemy, player, 14, Language.C, 14, 0, false, 9, 5));
|
||||
GameEvents.RaiseDamageDealt(new DamageDealtEvent(player, enemy, 20, Language.C, 20, 0, false, 7, 13));
|
||||
GameEvents.RaiseDamageDealt(new DamageDealtEvent(player, player, 20, Language.C, 20, 0, false, 20, 0));
|
||||
data = _save.Load();
|
||||
Assert.That(data.dailyQuests.nativeCards, Is.EqualTo(1));
|
||||
Assert.That(data.dailyQuests.blockedDamage, Is.EqualTo(9));
|
||||
Assert.That(data.dailyQuests.shieldDamage, Is.EqualTo(7));
|
||||
data.dailyQuests.selectedQuests = new[] { DailyQuestKind.SurviveRounds, DailyQuestKind.WaveFive, DailyQuestKind.Waves };
|
||||
_save.Save(data);
|
||||
GameEvents.RaisePhaseChanged(new PhaseChangedEvent(TurnPhase.Allocate, TurnPhase.Execute));
|
||||
GameEvents.RaisePhaseChanged(new PhaseChangedEvent(TurnPhase.EnemyProcess, TurnPhase.GarbageCollection));
|
||||
player.CurrentUptime = 0;
|
||||
GameEvents.RaisePhaseChanged(new PhaseChangedEvent(TurnPhase.EnemyProcess, TurnPhase.GarbageCollection));
|
||||
GameEvents.RaiseWaveCleared(new WaveClearedEvent(4));
|
||||
Assert.That(_save.Load().dailyQuests.waveFive, Is.Zero);
|
||||
GameEvents.RaiseWaveCleared(new WaveClearedEvent(5));
|
||||
data = _save.Load();
|
||||
Assert.That(data.dailyQuests.survivedRounds, Is.EqualTo(1));
|
||||
Assert.That(data.dailyQuests.waveFive, Is.EqualTo(1));
|
||||
Assert.That(data.dailyQuests.waves, Is.EqualTo(2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a41d2608975f4d4c99e00d5f20eeac04
|
||||
@@ -63,9 +63,55 @@ public class DamageEffectExecutionTests
|
||||
card, Player, targets, _combat, _combat.DamagePipeline, new StatusEffectController(),
|
||||
_combat.DeckController, _combat.HandController, _combat.Enemies);
|
||||
|
||||
[TestCase("lang_rs_unwrap", Language.Rust, 5)]
|
||||
[TestCase("lang_c_printf", Language.C, 4)]
|
||||
public void RebalancedNativeCardsMatchPreviewAndRetainTheirUtility(string id, Language language, int damage)
|
||||
{
|
||||
var card = Card(id, language);
|
||||
var target = Enemy();
|
||||
var broken = Card("broken_dependency", Language.Python);
|
||||
broken.IsBroken = true;
|
||||
_combat.HandController.Add(broken);
|
||||
var replacement = Card("replacement", Language.Python);
|
||||
_combat.DeckController.AddToDrawPile(replacement, false);
|
||||
var preview = CardPreviewService.Build(_combat, card, target);
|
||||
|
||||
foreach (var effect in CardEffectFactory.CreateEffects(card.Definition)) effect.Execute(Context(card, target));
|
||||
|
||||
Assert.That(100 - target.CurrentUptime, Is.EqualTo(damage));
|
||||
Assert.That(preview.MinimumDamage, Is.EqualTo(damage));
|
||||
Assert.That(preview.MaximumDamage, Is.EqualTo(damage));
|
||||
if (language == Language.C) Assert.That(broken.IsBroken, Is.False);
|
||||
else
|
||||
{
|
||||
Assert.That(_combat.HandController.Cards, Has.Member(replacement));
|
||||
Assert.That(preview.Details, Does.Contain("Draw 1 (fixed)"));
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase(0, 0, 6)]
|
||||
[TestCase(1, 0, 8)]
|
||||
[TestCase(3, 2, 14)]
|
||||
public void ListAppendPreviewMatchesFirstPlayAndRequeueGrowth(int previousPlays, int magnitude, int expected)
|
||||
{
|
||||
var card = Card("shop_py_list_append", Language.Python);
|
||||
card.ApplyMagnitudeUpgrade(magnitude);
|
||||
for (int i = 0; i < previousPlays; i++) card.MarkQueued();
|
||||
var target = Enemy();
|
||||
var preview = CardPreviewService.Build(_combat, card, target);
|
||||
card.MarkQueued();
|
||||
|
||||
foreach (var effect in CardEffectFactory.CreateEffects(card.Definition)) effect.Execute(Context(card, target));
|
||||
|
||||
Assert.That(100 - target.CurrentUptime, Is.EqualTo(expected));
|
||||
Assert.That(preview.MinimumDamage, Is.EqualTo(expected));
|
||||
Assert.That(preview.MaximumDamage, Is.EqualTo(expected));
|
||||
Assert.That(CardEffectFactory.GetRulesText(card), Does.Contain($"deal {expected}."));
|
||||
}
|
||||
|
||||
[TestCase("fedora_first_to_package", Language.Java, 18)]
|
||||
[TestCase("fedora_dnf_autoremove", Language.Rust, 18)]
|
||||
[TestCase("mint_update_manager", Language.Python, 15)]
|
||||
[TestCase("mint_update_manager", Language.Python, 12)]
|
||||
public void WrappersAndPreviewApplyFlatAndMagnitudeBonusesExactlyOnce(string id, Language language, int expected)
|
||||
{
|
||||
var card = Card(id, language);
|
||||
@@ -128,7 +174,8 @@ public class DamageEffectExecutionTests
|
||||
|
||||
Call(_combat, "ResolveDelayedEndOfTurnEffects");
|
||||
Assert.That(newcomer.CurrentUptime, Is.EqualTo(100 - repeatIncoming), "A scheduled repeat executes only once.");
|
||||
Assert.That(CardPreviewService.Build(_combat, card, target).Details, Does.Contain("captures"));
|
||||
Assert.That(CardPreviewService.Build(_combat, card, target).Details, Does.Contain("automation ran earlier"),
|
||||
"Legacy delayed effects remain executable, but the live card now uses the Python payload rule.");
|
||||
}
|
||||
|
||||
private static ICardEffect DamageEffect(string kind, Language language) => kind switch
|
||||
|
||||
@@ -236,16 +236,16 @@ public class GentooHaskellTests
|
||||
for (int i=0;i<cards.Length;i++)
|
||||
{
|
||||
stack.Enqueue(cards[i]);
|
||||
Assert.That(stack.Entries[0].MultiplierPercent, Is.EqualTo(Math.Min(250,100+i*50)));
|
||||
Assert.That(stack.Entries[0].MultiplierPercent, Is.EqualTo(new[] {150,175,200,250,250,250}[i]));
|
||||
}
|
||||
int[] expected = {250,250,250,200,150,100,100};
|
||||
int[] expected = {250,250,250,200,175,150,100};
|
||||
foreach (int percent in expected)
|
||||
{
|
||||
Assert.That(stack.TryPopEntry(out var entry), Is.True);
|
||||
Assert.That(entry.MultiplierPercent, Is.EqualTo(percent));
|
||||
}
|
||||
stack.Enqueue(cards[3].CopyForCombat());
|
||||
Assert.That(stack.Entries[0].MultiplierPercent, Is.EqualTo(100));
|
||||
Assert.That(stack.Entries[0].MultiplierPercent, Is.EqualTo(150));
|
||||
stack.Enqueue(stack.Cards[0]);
|
||||
Assert.That(stack.Count, Is.EqualTo(1), "Same pending instance cannot be pushed twice");
|
||||
}
|
||||
@@ -275,8 +275,8 @@ public class GentooHaskellTests
|
||||
CollectionAssert.AreEqual(cards, played);
|
||||
CollectionAssert.AreEqual(cards.Reverse().ToArray(), resolving);
|
||||
CollectionAssert.AreEqual(resolving, resolved);
|
||||
Assert.That(Target.CurrentUptime, Is.EqualTo(9980)); // 10 + 8 + 2
|
||||
Assert.That(Player.Shield, Is.EqualTo(4)); // 3 * 1.5, nearest-even
|
||||
Assert.That(Target.CurrentUptime, Is.EqualTo(9979)); // 10 + 8 + 3
|
||||
Assert.That(Player.Shield, Is.EqualTo(5)); // 3 * 1.75, nearest-even
|
||||
Assert.That(_combat.HandController.Cards.Count, Is.EqualTo(2)); // draw + rider, not multiplied
|
||||
foreach (var card in cards)
|
||||
{
|
||||
@@ -300,7 +300,7 @@ public class GentooHaskellTests
|
||||
{
|
||||
Drain("InterpretQueueSequenced"); Drain();
|
||||
CollectionAssert.AreEqual(new[]{"shop_py_list_append","lang_hs_thunk"},order);
|
||||
Assert.That(Target.CurrentUptime, Is.EqualTo(9990)); // round(4*1.3), twice; not wave-start 85%.
|
||||
Assert.That(Target.CurrentUptime, Is.EqualTo(9984)); // round(6*1.3) + round(4*1.5*1.3); resolution-time Compilation.
|
||||
}
|
||||
finally { GameEvents.CardResolved -= observe; }
|
||||
}
|
||||
@@ -476,7 +476,7 @@ public class GentooHaskellTests
|
||||
var dead=Target; dead.State.IsDefeated=true;
|
||||
((List<EnemyInstance>)_combat.Enemies).Remove(dead);
|
||||
Drain(); Drain();
|
||||
Assert.That(other.CurrentUptime,Is.EqualTo(9996));
|
||||
Assert.That(other.CurrentUptime,Is.EqualTo(9994)); // One 4 * 1.5 hit after retargeting.
|
||||
Assert.That(_combat.DeckController.DiscardPile.Count(c=>c==card),Is.EqualTo(1));
|
||||
}
|
||||
|
||||
@@ -540,7 +540,7 @@ public class GentooHaskellTests
|
||||
Assert.That(Player.FlatCardDamageBonus,Is.EqualTo(7));
|
||||
Assert.That(Player.FlatEffectBonus,Is.Zero,"DNF does not amplify non-damage effects");
|
||||
Drain();
|
||||
Assert.That(10000-Target.CurrentUptime,Is.EqualTo(95),"DNF is additive before stack/Compilation, not applied twice");
|
||||
Assert.That(10000-Target.CurrentUptime,Is.EqualTo(105),"DNF is additive before stack/Compilation: 20 + 24 + 27 + 34, not applied twice");
|
||||
}
|
||||
|
||||
[TestCase(0, 2)]
|
||||
@@ -609,7 +609,7 @@ public class GentooHaskellTests
|
||||
card.ClearTargetSnapshot();
|
||||
Assert.That(_combat.LazyStack.Entries[0].Targets[0],Is.SameAs(captured));
|
||||
Drain();
|
||||
Assert.That(10000-Target.CurrentUptime,Is.EqualTo(3));
|
||||
Assert.That(10000-Target.CurrentUptime,Is.EqualTo(5)); // round(4 * 1.5 * 0.85).
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
@@ -640,7 +640,7 @@ public class GentooHaskellTests
|
||||
Assert.That(text,Does.Contain("6/6"));
|
||||
Assert.That(text,Does.Contain("+50%"));
|
||||
var multipliers=root.Query<Label>(className:"execution-multiplier").ToList();
|
||||
CollectionAssert.AreEqual(new[]{"x2.5","x2.0","x1.5","x1.0"},multipliers.Select(l=>l.text));
|
||||
CollectionAssert.AreEqual(new[]{"x2.5","x2.0","x1.75","x1.5"},multipliers.Select(l=>l.text));
|
||||
foreach(var label in multipliers)
|
||||
Assert.That(label.worldBound.xMax,Is.LessThanOrEqualTo(root.worldBound.xMax+1),size.ToString());
|
||||
var end=root.Query<Button>().ToList().Single(b=>b.text=="[E] end turn");
|
||||
|
||||
@@ -249,7 +249,7 @@ public class PackageReadinessTests
|
||||
var card = Card(5, ResolutionTrack.Native, "lang_java_public_static_main", Language.Java);
|
||||
card.ApplyCostUpgrade(-1);
|
||||
card.TemporaryCostDelta = -1;
|
||||
Set(_combat, "_javaCardsPlayedThisCombat", 1);
|
||||
Set(_combat, "_javaCardsPlayedThisCombat", 2);
|
||||
string explanation = _combat.GetCardCostBreakdown(card);
|
||||
Assert.That(explanation, Does.Contain("upgrades: -1").And.Contain("temporary: -1")
|
||||
.And.Contain("Java warmup: -1").And.Contain("ccache: -1").And.Contain("Bleeding Edge: -1"));
|
||||
|
||||
@@ -99,7 +99,7 @@ public class PileCostDetailsTests
|
||||
var card = Card(5, "lang_java_public_static_main", Language.Java);
|
||||
card.ApplyCostUpgrade(-1);
|
||||
card.TemporaryCostDelta = -1;
|
||||
Set(_combat, "_javaCardsPlayedThisCombat", 1);
|
||||
Set(_combat, "_javaCardsPlayedThisCombat", 2);
|
||||
int seed = RandomRoll.CurrentSeed, draws = RandomRoll.DrawCount;
|
||||
var random = UnityEngine.Random.state;
|
||||
int cycles = _combat.PlayerState.Cycles, shield = _combat.PlayerState.Shield;
|
||||
|
||||
@@ -0,0 +1,308 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using KernelPanic.Combat;
|
||||
using KernelPanic.Core;
|
||||
using KernelPanic.Data;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class PythonPipelineTests
|
||||
{
|
||||
private const BindingFlags Private = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
private GameObject owner;
|
||||
private CombatManager combat;
|
||||
private CardDatabase database;
|
||||
private int seed, draws;
|
||||
private CombatantState Player => combat.PlayerState;
|
||||
private CombatantState Target => combat.Enemies[0].State;
|
||||
private static void Set(object obj, string name, object value) => obj.GetType().GetField(name, Private).SetValue(obj, value);
|
||||
private static object Call(object obj, string name, params object[] args) => obj.GetType().GetMethod(name, Private).Invoke(obj, args);
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
seed = RandomRoll.CurrentSeed; draws = RandomRoll.DrawCount; RandomRoll.Seed(17);
|
||||
database = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
|
||||
owner = new GameObject("Python pipeline tests");
|
||||
combat = owner.AddComponent<CombatManager>();
|
||||
Call(combat, "OnDisable"); Call(combat, "Awake");
|
||||
Set(combat, "_playerState", new CombatantState(100, 32, 100) { ForceMaxRolls = true });
|
||||
Set(combat, "_handController", new HandController(32));
|
||||
Set(combat, "currentPhase", TurnPhase.Execute);
|
||||
((List<EnemyInstance>)combat.Enemies).Add(new EnemyInstance("first", 10000, Array.Empty<EnemyIntent>()));
|
||||
((List<EnemyInstance>)combat.Enemies).Add(new EnemyInstance("second", 10000, Array.Empty<EnemyIntent>()));
|
||||
combat.SetGeneratedCardPool(database.AllCards);
|
||||
Begin(1);
|
||||
}
|
||||
[TearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
Call(combat, "OnDisable"); UnityEngine.Object.DestroyImmediate(owner);
|
||||
RandomRoll.Restore(seed, draws);
|
||||
}
|
||||
private CardInstance Card(string id) => new(database.FindById(id));
|
||||
private void Begin(int round) { Set(combat, "_turnNumberThisWave", round); combat.Python.BeginPhase(round); }
|
||||
private void Effect(CardInstance card)
|
||||
{
|
||||
var context = new CombatContext(card, Player, new[] { Target }, combat, combat.DamagePipeline,
|
||||
new StatusEffectController(), combat.DeckController, combat.HandController, combat.Enemies);
|
||||
foreach (var effect in CardEffectFactory.CreateEffects(card.Definition)) effect.Execute(context);
|
||||
}
|
||||
private CardInstance Effect(string id) { var card = Card(id); Effect(card); return card; }
|
||||
private void Play(CardInstance card)
|
||||
{
|
||||
combat.HandController.Add(card); combat.SelectEnemy(0);
|
||||
Assert.That(combat.PlayCard(card), Is.True);
|
||||
}
|
||||
private void ResolveQueue()
|
||||
{
|
||||
var routine = (IEnumerator)Call(combat, "InterpretQueueSequenced");
|
||||
int steps = 0;
|
||||
while (routine.MoveNext()) Assert.That(++steps, Is.LessThan(100));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoopSkipsZipAndRepeatsOnlyTheAreaPayloadWithMatchingPreview()
|
||||
{
|
||||
Play(Card("lang_py_for_loop")); Play(Card("shop_py_zip"));
|
||||
var payload = Card("lang_py_print"); Play(payload);
|
||||
var preview = CardPreviewService.Build(combat, payload, Target);
|
||||
Assert.That(preview.MinimumDamage, Is.EqualTo(8));
|
||||
ResolveQueue();
|
||||
Assert.That(Target.CurrentUptime, Is.EqualTo(9990)); // zip 2 + print 4 twice
|
||||
Assert.That(combat.Enemies[1].State.CurrentUptime, Is.EqualTo(9992));
|
||||
Assert.That(Player.Shield, Is.EqualTo(2));
|
||||
Assert.That(combat.Python.RepeatCount, Is.Zero);
|
||||
Assert.That(combat.Python.AreaCount, Is.Zero);
|
||||
Assert.That(combat.DeckController.DiscardPile.Count, Is.EqualTo(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtraModifiersWaitForOtherPayloadsAndNeverMultiplyEachOther()
|
||||
{
|
||||
Effect("lang_py_for_loop"); Effect("lang_py_for_loop");
|
||||
Effect("shop_py_zip"); Effect("shop_py_zip");
|
||||
Effect("lang_py_print");
|
||||
Assert.That(combat.Python.RepeatCount, Is.EqualTo(1));
|
||||
Assert.That(combat.Python.AreaCount, Is.EqualTo(1));
|
||||
Assert.That(combat.Enemies[1].State.CurrentUptime, Is.EqualTo(9992));
|
||||
Effect("lang_py_print");
|
||||
Assert.That(combat.Enemies[1].State.CurrentUptime, Is.EqualTo(9984));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ModifiersSurviveOneFollowingRoundThenExpireAndNativeCardsDoNotConsumeThem()
|
||||
{
|
||||
Effect("lang_py_for_loop"); Effect("shop_py_zip"); Effect("lang_js_console_log");
|
||||
Assert.That(combat.Python.RepeatCount, Is.EqualTo(1));
|
||||
Begin(2);
|
||||
Assert.That(combat.Python.AreaCount, Is.EqualTo(1));
|
||||
Begin(3);
|
||||
Assert.That(combat.Python.RepeatCount, Is.Zero);
|
||||
Assert.That(combat.Python.AreaCount, Is.Zero);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PreparationDrawsImmediatelyWithFixedCountAndDoesNotUseModifiers()
|
||||
{
|
||||
Effect("lang_py_for_loop");
|
||||
for (int i = 0; i < 8; i++) combat.DeckController.AddToDrawPile(Card("lang_py_print"), false);
|
||||
var prepare = Card("lang_py_import_antigravity"); prepare.ApplyMagnitudeUpgrade(10);
|
||||
Player.FlatEffectBonus = 10;
|
||||
Play(prepare);
|
||||
Assert.That(combat.HandController.Cards.Count, Is.EqualTo(2));
|
||||
Assert.That(combat.InterpreterQueue.Count, Is.Zero);
|
||||
Assert.That(combat.Python.RepeatCount, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AsyncSnapshotsUnmodifiedPayloadAndCannotReplayDrawRidersOrGrowth()
|
||||
{
|
||||
var script = Card("shop_py_async_def");
|
||||
for (int i = 0; i < 4; i++) combat.DeckController.AddToDrawPile(Card("lang_py_print"), false);
|
||||
Play(script);
|
||||
Assert.That(combat.HandController.Cards.Count, Is.EqualTo(1), "Async draws on play, before interpretation.");
|
||||
Play(Card("lang_py_for_loop")); Play(Card("shop_py_zip"));
|
||||
var list = Card("shop_py_list_append"); list.ApplyMagnitudeUpgrade(2); list.ApplyDrawRider(1);
|
||||
Play(list); ResolveQueue();
|
||||
Assert.That(Target.CurrentUptime, Is.EqualTo(9982)); // zip 2 + 8 twice
|
||||
Assert.That(combat.Enemies[1].State.CurrentUptime, Is.EqualTo(9984));
|
||||
int hand = combat.HandController.Cards.Count;
|
||||
list.ApplyMagnitudeUpgrade(20); Player.FlatEffectBonus = 20; Player.FlatCardDamageBonus = 30;
|
||||
Begin(2);
|
||||
Assert.That(Target.CurrentUptime, Is.EqualTo(9974), "Captured 8, not later upgrades or area/repeat modifiers.");
|
||||
Assert.That(combat.Enemies[1].State.CurrentUptime, Is.EqualTo(9984));
|
||||
Begin(3); Begin(4);
|
||||
Assert.That(Target.CurrentUptime, Is.EqualTo(9966));
|
||||
Assert.That(combat.HandController.Cards.Count, Is.EqualTo(hand));
|
||||
Assert.That(list.QueuePlayCount, Is.EqualTo(1));
|
||||
Assert.That(combat.Python.AutomationCount, Is.Zero);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AutomationReplacementRequiresAChoiceAndBlocksCombatInput()
|
||||
{
|
||||
Effect("ubuntu_unattended_upgrades"); Effect("shop_py_async_def"); Effect("mint_timeshift");
|
||||
Assert.That(combat.Python.HasChoice, Is.True);
|
||||
Assert.That(combat.Python.AutomationCount, Is.EqualTo(2));
|
||||
Assert.That(combat.CanSurrenderRun, Is.False);
|
||||
var card = Card("lang_py_print"); combat.HandController.Add(card);
|
||||
Assert.That(combat.PlayCard(card), Is.False);
|
||||
combat.EndPlayerTurn(); Assert.That(combat.CurrentPhase, Is.EqualTo(TurnPhase.Execute));
|
||||
Assert.That(combat.Python.Choose(-1), Is.False);
|
||||
Assert.That(combat.Python.Choose(0), Is.True);
|
||||
Assert.That(combat.Python.Choose(0), Is.False, "Cannot replay a resolved choice.");
|
||||
Assert.That(combat.Python.Readout.Any(s => s.StartsWith("timeshift snapshot")), Is.True);
|
||||
Assert.That(combat.Python.Readout.Any(s => s.StartsWith("unattended-upgrades")), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnattendedRunsTwiceAndUpdateAndCinnamonUseActualPhaseConditions()
|
||||
{
|
||||
Effect("mint_cinnamon"); Assert.That(Player.Shield, Is.EqualTo(3));
|
||||
Effect("mint_update_manager"); Assert.That(Target.CurrentUptime, Is.EqualTo(9997));
|
||||
Effect("mint_cinnamon"); Assert.That(Player.Shield, Is.EqualTo(8));
|
||||
Effect("ubuntu_unattended_upgrades"); Assert.That(Player.Shield, Is.EqualTo(11));
|
||||
Begin(2); Assert.That(Player.Shield, Is.EqualTo(14));
|
||||
Effect("mint_update_manager"); Assert.That(Target.CurrentUptime, Is.EqualTo(9992));
|
||||
Begin(3); Assert.That(Player.Shield, Is.EqualTo(17));
|
||||
Begin(4); Assert.That(Player.Shield, Is.EqualTo(17));
|
||||
Assert.That(combat.Python.AutomationRan, Is.False);
|
||||
Assert.That(combat.Python.DamageThisPhase, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TimeshiftWaitsForFutureRoundsCapsRecoveryAndCannotResurrect()
|
||||
{
|
||||
Player.CurrentUptime = 80;
|
||||
var timeshift = Card("mint_timeshift"); timeshift.ApplyMagnitudeUpgrade(30);
|
||||
Effect(timeshift); Player.CurrentUptime = 50;
|
||||
combat.Python.EndRound(); Assert.That(Player.CurrentUptime, Is.EqualTo(50));
|
||||
Begin(2); combat.Python.EndRound(); Assert.That(Player.CurrentUptime, Is.EqualTo(56));
|
||||
Begin(3); combat.Python.EndRound(); Assert.That(Player.CurrentUptime, Is.EqualTo(62));
|
||||
Begin(4); combat.Python.EndRound(); Assert.That(Player.CurrentUptime, Is.EqualTo(62));
|
||||
Effect("mint_timeshift"); Begin(5); Player.CurrentUptime = 0; Player.IsDefeated = true;
|
||||
combat.Python.EndRound(); Assert.That(Player.CurrentUptime, Is.Zero);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InspectTakesChosenCardPreservesOthersAndRejectsRamBlockedOptions()
|
||||
{
|
||||
var bottom = Card("lang_py_print"); var chosen = Card("shop_py_list_append"); var top = Card("lang_java_new_object");
|
||||
combat.DeckController.AddToDrawPile(bottom, false); combat.DeckController.AddToDrawPile(chosen, false); combat.DeckController.AddToDrawPile(top, false);
|
||||
combat.HandController.SetRamCapacity(1);
|
||||
Effect("ubuntu_ask_ubuntu");
|
||||
Assert.That(combat.Python.Choices.Count, Is.EqualTo(3));
|
||||
Assert.That(combat.Python.Choose(0), Is.False);
|
||||
Assert.That(combat.Python.Choose(1), Is.True);
|
||||
Assert.That(combat.HandController.Cards, Is.EqualTo(new[] { chosen }));
|
||||
Assert.That(combat.DeckController.DrawPile, Is.EqualTo(new[] { bottom, top }));
|
||||
}
|
||||
|
||||
[TestCase("Ubuntu", 1, 3)]
|
||||
[TestCase("Ubuntu", 2, 3)]
|
||||
[TestCase("Ubuntu", 3, 5)]
|
||||
[TestCase("Ubuntu", 5, 5)]
|
||||
[TestCase("Mint", 5, 3)]
|
||||
public void InspectDescriptionMatchesActualChoicesAtTheActiveDistroVersion(string distroName, int version, int count)
|
||||
{
|
||||
var distro = AssetDatabase.LoadAssetAtPath<DistroDefinition>($"Assets/Data/Distros/{distroName}.asset");
|
||||
var config = new KernelPanic.Run.RunConfig(distro, Language.Python, Language.C, distro.ExclusiveCards.Take(4).ToArray(), 17, version);
|
||||
Set(combat, "_runConfig", config);
|
||||
var card = Card("ubuntu_ask_ubuntu");
|
||||
card.ApplyMagnitudeUpgrade(2);
|
||||
for (int i = 0; i < 6; i++) combat.DeckController.AddToDrawPile(Card("lang_py_print"), false);
|
||||
string rules = CardEffectFactory.GetRulesText(card, config);
|
||||
Assert.That(rules, Does.Contain($"inspect the top {count} cards."));
|
||||
Assert.That(rules, Does.Not.Contain(count == 3 ? "5" : "3"));
|
||||
Assert.That(rules, Does.Not.Contain("V3"));
|
||||
Effect(card);
|
||||
Assert.That(combat.Python.Choices.Count, Is.EqualTo(count));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InspectionChoiceResolvesBeforeDrawRidersAndDiscard()
|
||||
{
|
||||
var chosen = Card("lang_py_print");
|
||||
combat.DeckController.AddToDrawPile(Card("shop_py_list_append"), false);
|
||||
combat.DeckController.AddToDrawPile(chosen, false);
|
||||
combat.HandController.SetRamCapacity(1);
|
||||
var inspect = Card("ubuntu_ask_ubuntu"); inspect.ApplyDrawRider(1);
|
||||
Play(inspect);
|
||||
Assert.That(combat.Python.HasChoice, Is.True);
|
||||
Assert.That(combat.HandController.Cards, Is.Empty);
|
||||
Assert.That(combat.DeckController.DiscardPile, Has.No.Member(inspect));
|
||||
Assert.That(combat.Python.Choose(0), Is.True);
|
||||
Assert.That(combat.HandController.Cards, Is.EqualTo(new[] { chosen }));
|
||||
Assert.That(combat.DeckController.DiscardPile, Does.Contain(inspect));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InstallOffersDistinctNonExclusivePythonCardsAndFreeCopyExpiresThenExhausts()
|
||||
{
|
||||
Effect("ubuntu_apt_install");
|
||||
Assert.That(combat.Python.Choices.Count, Is.EqualTo(3));
|
||||
Assert.That(combat.Python.Choices.Select(c => c.Label).Distinct().Count(), Is.EqualTo(3));
|
||||
combat.Python.Choose(0);
|
||||
var card = combat.HandController.Cards.Single();
|
||||
Assert.That(card.Definition.Language, Is.EqualTo(Language.Python));
|
||||
Assert.That(card.Definition.DistroExclusive || card.Definition.IsToken, Is.False);
|
||||
Assert.That(combat.GetEffectiveCardCost(card), Is.Zero);
|
||||
Assert.That(CardEffectFactory.GetRulesText(card), Does.Contain("Temporary copy: exhaust after play."));
|
||||
Begin(2); Assert.That(combat.GetEffectiveCardCost(card), Is.EqualTo(card.Definition.CycleCost));
|
||||
combat.HandController.Remove(card); combat.DeckController.Discard(card);
|
||||
Assert.That(combat.DeckController.ExhaustPile, Does.Contain(card));
|
||||
Assert.That(combat.DeckController.DiscardPile, Has.No.Member(card));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PreviewDoesNotCarryLastRoundsConditionsAndIncludesUpcomingDamageScripts()
|
||||
{
|
||||
Effect("mint_update_manager");
|
||||
Set(combat, "_turnNumberThisWave", 2);
|
||||
Assert.That(combat.Python.PreviewState(Card("mint_cinnamon")).damageBefore, Is.False);
|
||||
Begin(2); Effect("shop_py_async_def"); Effect("lang_py_print");
|
||||
Set(combat, "_turnNumberThisWave", 3);
|
||||
Assert.That(combat.Python.PreviewState(Card("mint_cinnamon")).damageBefore, Is.True);
|
||||
Assert.That(combat.Python.PreviewState(Card("mint_update_manager")).automation, Is.True);
|
||||
Begin(3); Begin(4);
|
||||
Set(combat, "_turnNumberThisWave", 5);
|
||||
Assert.That(combat.Python.PreviewState(Card("mint_update_manager")).automation, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ScriptsActivateAtMostOncePerRoundAndRetargetDefeatedEnemies()
|
||||
{
|
||||
Effect("shop_py_async_def"); Effect("lang_py_print");
|
||||
Effect("mint_timeshift"); Player.CurrentUptime = 50;
|
||||
Target.IsDefeated = true; Target.CurrentUptime = 0;
|
||||
Begin(2); combat.Python.EndRound();
|
||||
Begin(2); combat.Python.EndRound();
|
||||
Assert.That(combat.Enemies[1].State.CurrentUptime, Is.EqualTo(9996));
|
||||
Assert.That(Player.CurrentUptime, Is.EqualTo(56));
|
||||
Assert.That(combat.Python.AutomationCount, Is.EqualTo(2));
|
||||
Begin(3); combat.Python.EndRound();
|
||||
Assert.That(combat.Enemies[1].State.CurrentUptime, Is.EqualTo(9992));
|
||||
Assert.That(Player.CurrentUptime, Is.EqualTo(62));
|
||||
Assert.That(combat.Python.AutomationCount, Is.Zero);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WaveCleanupClearsScriptsChoicesModifiersAndTemporaryDiscounts()
|
||||
{
|
||||
Effect("lang_py_for_loop"); Effect("shop_py_zip"); Effect("shop_py_async_def");
|
||||
Effect("ubuntu_apt_install"); combat.Python.Choose(0);
|
||||
var generated = combat.HandController.Cards.Single();
|
||||
Effect("ubuntu_unattended_upgrades"); Effect("mint_timeshift");
|
||||
Assert.That(ExecutionPreview.Build(combat).Any(s => s.Contains("scripts 2/2")), Is.True);
|
||||
Call(combat, "ClearDeferredCards");
|
||||
Assert.That(combat.Python.HasChoice, Is.False);
|
||||
Assert.That(combat.Python.AutomationCount, Is.Zero);
|
||||
Assert.That(combat.Python.RepeatCount + combat.Python.AreaCount, Is.Zero);
|
||||
Assert.That(generated.TemporaryCostDelta, Is.Zero);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fae416900ff44939bb6075c2ecfda4c5
|
||||
@@ -132,8 +132,8 @@ public class RewardSettlementTests
|
||||
_save.Save(SaveData.CreateDefault());
|
||||
Set(_run, "_accruedBandwidth", 100);
|
||||
Set(_run, "_accruedEntropy", 3);
|
||||
Set(_run, "currentWaveNumber", 6);
|
||||
Set(_run, "_wavesCleared", 5);
|
||||
Set(_run, "currentWaveNumber", RunJourney.BossWave + 1);
|
||||
Set(_run, "_wavesCleared", RunJourney.BossWave);
|
||||
var combat = _owner.GetComponent<CombatManager>();
|
||||
Set(combat, "_runManager", _run);
|
||||
Set(combat, "_awaitingWaveContinue", true);
|
||||
@@ -147,10 +147,10 @@ public class RewardSettlementTests
|
||||
var saved = _save.Load();
|
||||
Assert.That(saved.bandwidthBalance, Is.EqualTo(100));
|
||||
Assert.That(saved.entropyBalance, Is.EqualTo(3));
|
||||
Assert.That(saved.GetBestWave("gentoo"), Is.EqualTo(5));
|
||||
Assert.That(saved.GetBestWave("gentoo"), Is.EqualTo(RunJourney.BossWave));
|
||||
Assert.That(saved.recentRuns.Count, Is.EqualTo(1));
|
||||
Assert.That(saved.recentRuns[0].victory, Is.True);
|
||||
Assert.That(saved.recentRuns[0].waveReached, Is.EqualTo(5));
|
||||
Assert.That(saved.recentRuns[0].waveReached, Is.EqualTo(RunJourney.BossWave));
|
||||
Assert.That(saved.recentRuns[0].cause, Does.Contain("campaign complete"));
|
||||
}
|
||||
private void RefreshStatus() => typeof(CombatSceneController).GetMethod("RefreshStatus", Private).Invoke(_controller, null);
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using KernelPanic.Combat;
|
||||
using KernelPanic.Core;
|
||||
using KernelPanic.Data;
|
||||
using KernelPanic.Run;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class RouteMapTests
|
||||
{
|
||||
private const BindingFlags Private = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
private GameObject _owner;
|
||||
private RunManager _run;
|
||||
private CombatManager _combat;
|
||||
private CardDatabase _cards;
|
||||
private int _seed, _draws;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_seed = RandomRoll.CurrentSeed; _draws = RandomRoll.DrawCount;
|
||||
_owner = new GameObject("route map tests"); _owner.SetActive(false);
|
||||
_run = _owner.AddComponent<RunManager>(); _combat = _owner.AddComponent<CombatManager>();
|
||||
_cards = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
|
||||
var distro = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Ubuntu.asset");
|
||||
var config = new RunConfig(distro, Language.Python, Language.JavaScript,
|
||||
new[] { _cards.FindById("lang_py_print"), _cards.FindById("lang_py_print"), _cards.FindById("mint_timeshift") }, 12345);
|
||||
_run.StartRun(config);
|
||||
Set(_combat, "_runConfig", config); Set(_combat, "_runManager", _run);
|
||||
Set(_combat, "_playerState", new CombatantState(50, 6, 3) { CurrentUptime = 20 });
|
||||
ClearWave(1);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
UnityEngine.Object.DestroyImmediate(_owner);
|
||||
RandomRoll.Restore(_seed, _draws);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SeededGraphHasEntrancesExitsCrossingsVarietyAndFinalConvergence()
|
||||
{
|
||||
int draws = RandomRoll.DrawCount;
|
||||
var kinds = new System.Collections.Generic.HashSet<WaveRoute>();
|
||||
bool crossing = false, fork = false;
|
||||
for (int seed = 0; seed < 64; seed++)
|
||||
for (int wave = 2; wave < 15; wave++)
|
||||
{
|
||||
var row = RunRouteMap.Row(seed, wave); var next = RunRouteMap.Row(seed, wave + 1);
|
||||
Assert.That(row.Select(n => n.Route), Is.EqualTo(RunRouteMap.Row(seed, wave).Select(n => n.Route)));
|
||||
foreach (var a in row)
|
||||
{
|
||||
kinds.Add(a.Route);
|
||||
Assert.That(next.Any(b => RunRouteMap.Connected(seed, a, b)), Is.True);
|
||||
fork |= next.Count(b => RunRouteMap.Connected(seed, a, b)) > 1;
|
||||
foreach (var b in next.Where(b => RunRouteMap.Connected(seed, a, b)))
|
||||
crossing |= row.Any(c => c.Lane > a.Lane && next.Any(d => d.Lane < b.Lane && RunRouteMap.Connected(seed, c, d)));
|
||||
}
|
||||
Assert.That(next.All(b => row.Any(a => RunRouteMap.Connected(seed, a, b))), Is.True);
|
||||
}
|
||||
Assert.That(kinds, Is.EquivalentTo(Enum.GetValues(typeof(WaveRoute))));
|
||||
Assert.That(crossing && fork, Is.True);
|
||||
Assert.That(RunRouteMap.Row(12345, 4).Count, Is.InRange(2, 4));
|
||||
Assert.That(RunRouteMap.Row(12345, RunJourney.BossWave).Single().Route, Is.EqualTo(WaveRoute.Encounter));
|
||||
Assert.That(RandomRoll.DrawCount, Is.EqualTo(draws));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CampaignHasEightChoiceTiersWithRecoveryBoundedElitesAndNoDeadEnds()
|
||||
{
|
||||
for (int seed = -128; seed < 128; seed++)
|
||||
{
|
||||
var reachable = RunRouteMap.Row(seed, 2).Select(n => n.Id).ToHashSet();
|
||||
for (int wave = 2; wave < RunJourney.BossWave; wave++)
|
||||
{
|
||||
var row = RunRouteMap.Row(seed, wave);
|
||||
var next = RunRouteMap.Row(seed, wave + 1);
|
||||
Assert.That(row.Count, Is.InRange(2, 4));
|
||||
Assert.That(row.All(n => reachable.Contains(n.Id)), Is.True, $"Seed {seed}, wave {wave}");
|
||||
Assert.That(row.Count(n => n.Route == WaveRoute.Repair), Is.EqualTo(1));
|
||||
Assert.That(row.Count(n => n.Route == WaveRoute.Challenge), Is.LessThanOrEqualTo(1));
|
||||
if (wave >= 7) Assert.That(row.Any(n => n.Route == WaveRoute.Challenge), Is.True);
|
||||
Assert.That(row.All(a => next.Any(b => RunRouteMap.Connected(seed, a, b))), Is.True);
|
||||
if (wave + 1 < RunJourney.BossWave)
|
||||
foreach (var node in row)
|
||||
Assert.That(next.Count(n => RunRouteMap.Connected(seed, node, n)), Is.InRange(2, 3));
|
||||
reachable = next.Where(b => row.Any(a => RunRouteMap.Connected(seed, a, b))).Select(n => n.Id).ToHashSet();
|
||||
}
|
||||
Assert.That(reachable, Does.Contain(RunJourney.BossWave * 10 + 1));
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase(1, 5)]
|
||||
[TestCase(2, 10)]
|
||||
public void CompleteRouteSurvivesEveryCheckpointAndEntersEndlessOnlyAfterItsBoss(int revision, int boss)
|
||||
{
|
||||
_run.Journey.mapRevision = revision;
|
||||
_run.Journey.encounterRevision = revision;
|
||||
int rewards = 0;
|
||||
for (int wave = 2; wave <= boss; wave++)
|
||||
{
|
||||
Assert.That(_run.CampaignChoicePending, Is.False, "Must not finish an extended campaign at wave five.");
|
||||
if (_run.BuildRewardPending) { _run.ClaimBuildReward(null, CardUpgradeKind.MagnitudeUp, true); rewards++; }
|
||||
Assert.That(_run.SelectRouteNode(_run.AvailableRouteNodes[0].Id), Is.True);
|
||||
if (_run.RouteEventPending) _run.ResolveRouteEvent(skip: true);
|
||||
var snapshot = JsonUtility.FromJson<RunCheckpoint>(JsonUtility.ToJson(_run.CaptureCheckpoint(_combat)));
|
||||
var restored = snapshot.Resolve(
|
||||
AssetDatabase.LoadAssetAtPath<DistroDatabase>("Assets/Data/Distros/DistroDatabase.asset"), _cards,
|
||||
AssetDatabase.LoadAssetAtPath<LanguageDeckDatabase>("Assets/Data/Cards/Languages/LanguageDeckDatabase.asset"),
|
||||
AssetDatabase.LoadAssetAtPath<PackageDatabase>("Assets/Data/Packages/PackageDatabase.asset"));
|
||||
_run.RestoreCheckpoint(restored);
|
||||
Assert.That(_run.Journey.FinalWave, Is.EqualTo(boss));
|
||||
_run.PrepareNextEncounter(_combat.PlayerState); ClearWave(wave);
|
||||
}
|
||||
Assert.That(rewards, Is.EqualTo(revision == 2 ? 4 : 2));
|
||||
Assert.That(_run.Journey.visits.Count, Is.EqualTo(boss - 1));
|
||||
Assert.That(_run.CampaignChoicePending, Is.True);
|
||||
_run.Journey.Validate(boss + 1); _run.Journey.ValidateMap(12345, boss + 1);
|
||||
Assert.That(_run.SelectRouteNode(_run.AvailableRouteNodes[0].Id), Is.False);
|
||||
Assert.That(_run.EnterEndless(), Is.True);
|
||||
Assert.That(_run.CampaignChoicePending, Is.False);
|
||||
_run.Journey.Validate(boss + 1); _run.Journey.ValidateMap(12345, boss + 1);
|
||||
Assert.That(_run.SelectRouteNode(_run.AvailableRouteNodes[0].Id), Is.True);
|
||||
if (_run.RouteEventPending) _run.ResolveRouteEvent(skip: true);
|
||||
_run.PrepareNextEncounter(_combat.PlayerState); ClearWave(boss + 1);
|
||||
Assert.That(_run.CurrentWaveNumber, Is.EqualTo(boss + 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SacrificeRequiresDifferentEligibleCardsAndCommitsExactlyOnce()
|
||||
{
|
||||
var donor = _run.RunDeck[0]; var target = _run.RunDeck[1];
|
||||
int count = _run.RunDeck.Count, bits = _run.Bits;
|
||||
Assert.That(_run.SelectRoute(WaveRoute.Sacrifice), Is.True);
|
||||
Assert.That(_run.RunDeck.Count, Is.EqualTo(count));
|
||||
_run.PrepareNextEncounter(_combat.PlayerState);
|
||||
Assert.That(_run.RepositoryVisitActive, Is.True);
|
||||
Assert.That(_run.ResolveRouteEvent(donor, donor), Is.False);
|
||||
Assert.That(_run.ResolveRouteEvent(donor, _run.RunDeck[2]), Is.False, "Timeshift is not magnitude-scaled.");
|
||||
Assert.That(_run.ResolveRouteEvent(new CardInstance(donor.Definition), target), Is.False);
|
||||
Assert.That(_run.ResolveRouteEvent(donor, target), Is.True);
|
||||
Assert.That(_run.RunDeck.Count, Is.EqualTo(count - 1));
|
||||
Assert.That(_run.RunDeck.Contains(donor), Is.False);
|
||||
Assert.That(target.MagnitudeBonus, Is.EqualTo(4));
|
||||
Assert.That(_run.Bits, Is.EqualTo(bits));
|
||||
Assert.That(_run.ResolveRouteEvent(target, target), Is.False);
|
||||
Assert.That(_run.ResolveRouteEvent(skip: true), Is.False);
|
||||
Assert.That(_run.SelectRoute(WaveRoute.Repair), Is.False, "Claiming an event locks the path.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PassingLocksStopWithoutChangingDeckAndHistoryConstrainsNextChoice()
|
||||
{
|
||||
_run.SelectRoute(WaveRoute.Sacrifice);
|
||||
var before = _run.RunDeck.ToArray();
|
||||
Assert.That(_run.ResolveRouteEvent(skip: true), Is.True);
|
||||
Assert.That(_run.RunDeck, Is.EqualTo(before));
|
||||
_run.PrepareNextEncounter(_combat.PlayerState); ClearWave(2);
|
||||
var previous = RunRouteMap.Row(12345, 2).Single(n => n.Route == WaveRoute.Sacrifice);
|
||||
Assert.That(_run.AvailableRouteNodes.Select(n => n.Id), Is.EquivalentTo(
|
||||
RunRouteMap.Row(12345, 3).Where(n => RunRouteMap.Connected(12345, previous, n)).Select(n => n.Id)));
|
||||
Assert.That(_run.SelectRouteNode(999), Is.False);
|
||||
Assert.That(_run.Journey.visits.Single().outcome, Does.Contain("Passed"));
|
||||
Assert.That(_run.Journey.visits.Single().cleared, Is.True);
|
||||
_run.Journey.Validate(3); _run.Journey.ValidateMap(12345, 3);
|
||||
var copy = _run.Journey.Copy(); copy.visits[0].nodeId = 999;
|
||||
Assert.That(_run.Journey.visits[0].nodeId, Is.EqualTo(previous.Id));
|
||||
Assert.Throws<InvalidDataException>(() => copy.ValidateMap(12345, 3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResolvedSacrificeRoundTripsWithoutDuplicatingUpgradeOrRemoval()
|
||||
{
|
||||
var donor = _run.RunDeck[0]; var target = _run.RunDeck[1]; string id = target.InstanceId;
|
||||
_run.SelectRoute(WaveRoute.Sacrifice); _run.ResolveRouteEvent(donor, target);
|
||||
var snapshot = JsonUtility.FromJson<RunCheckpoint>(JsonUtility.ToJson(_run.CaptureCheckpoint(_combat)));
|
||||
var resolved = snapshot.Resolve(
|
||||
AssetDatabase.LoadAssetAtPath<DistroDatabase>("Assets/Data/Distros/DistroDatabase.asset"), _cards,
|
||||
AssetDatabase.LoadAssetAtPath<LanguageDeckDatabase>("Assets/Data/Cards/Languages/LanguageDeckDatabase.asset"),
|
||||
AssetDatabase.LoadAssetAtPath<PackageDatabase>("Assets/Data/Packages/PackageDatabase.asset"));
|
||||
_run.RestoreCheckpoint(resolved);
|
||||
Assert.That(_run.RunDeck.Count, Is.EqualTo(2));
|
||||
Assert.That(_run.RunDeck.Single(c => c.InstanceId == id).MagnitudeBonus, Is.EqualTo(4));
|
||||
Assert.That(_run.RouteEventPending, Is.False);
|
||||
Assert.That(_run.ResolveRouteEvent(skip: true), Is.False);
|
||||
_run.PrepareNextEncounter(_combat.PlayerState); ClearWave(2);
|
||||
Assert.That(_run.Journey.visits.Single().outcome, Does.Contain("Sacrificed"));
|
||||
_run.Journey.Validate(3); _run.Journey.ValidateMap(12345, 3);
|
||||
}
|
||||
|
||||
[TestCase(WaveRoute.Forge, 2, 0, 0)]
|
||||
[TestCase(WaveRoute.Recycle, 0, 4, 1)]
|
||||
[TestCase(WaveRoute.Cache, 0, 6, 0)]
|
||||
public void OtherStopsApplyTheirAdvertisedEffectsOnlyOnce(WaveRoute route, int magnitude, int bits, int removed)
|
||||
{
|
||||
// A seeded third row containing the desired event, with its actual connected entrance.
|
||||
int seed = Enumerable.Range(0, 100).First(s => RunRouteMap.Row(s, 3).Any(n => n.Route == route));
|
||||
var config = new RunConfig(_run.CurrentConfig.Distro, Language.Python, Language.JavaScript, _run.CurrentConfig.StartingDeck, seed);
|
||||
_run.StartRun(config); ClearWave(1);
|
||||
var desired = RunRouteMap.Row(seed, 3).Single(n => n.Route == route);
|
||||
var entrance = RunRouteMap.Row(seed, 2).First(n => RunRouteMap.Connected(seed, n, desired));
|
||||
_run.SelectRouteNode(entrance.Id);
|
||||
if (_run.RouteEventPending) _run.ResolveRouteEvent(skip: true);
|
||||
_run.PrepareNextEncounter(_combat.PlayerState); ClearWave(2);
|
||||
_run.ClaimBuildReward(null, CardUpgradeKind.MagnitudeUp, true);
|
||||
Assert.That(_run.SelectRouteNode(desired.Id), Is.True);
|
||||
int before = _run.Bits, count = _run.RunDeck.Count;
|
||||
var donor = _run.RunDeck[0]; var target = _run.RunDeck[1];
|
||||
if (_run.RouteEventPending) Assert.That(_run.ResolveRouteEvent(donor, target), Is.True);
|
||||
_run.PrepareNextEncounter(_combat.PlayerState); _run.PrepareNextEncounter(_combat.PlayerState);
|
||||
Assert.That(target.MagnitudeBonus, Is.EqualTo(magnitude));
|
||||
Assert.That(_run.RunDeck.Count, Is.EqualTo(count - removed));
|
||||
Assert.That(_run.Bits, Is.EqualTo(before + bits));
|
||||
}
|
||||
|
||||
private void ClearWave(int wave)
|
||||
{
|
||||
typeof(RunManager).GetMethod("HandleWaveCleared", Private).Invoke(_run, new object[] { new WaveClearedEvent(wave) });
|
||||
Set(_combat, "_awaitingWaveContinue", true);
|
||||
_run.GenerateRepositoryOffers(_cards, null);
|
||||
}
|
||||
private static void Set(object obj, string name, object value) => obj.GetType().GetField(name, Private).SetValue(obj, value);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a703072a87444cc89b2c215bb3e8fa1a
|
||||
@@ -54,6 +54,7 @@ public class RunCheckpointTests
|
||||
var config = new RunConfig(distro, Language.Python, Language.JavaScript, starting,
|
||||
new[] { new PackageInstance(_packages.FindById("pkg_fedora_dnf"), 3) }, -7712, 2);
|
||||
_run.StartRun(config); // No bound CombatManager: do not start Play-mode coroutines.
|
||||
_run.Journey.mapRevision = 0; // This fixture jumps directly to an older repository boundary.
|
||||
Set(_combat, "_runManager", _run);
|
||||
Set(_combat, "_runConfig", config);
|
||||
Set(_combat, "_playerState", new CombatantState(_run.EffectiveMaxUptime(), _run.EffectiveRam(), _run.EffectiveMaxCycles())
|
||||
@@ -141,7 +142,7 @@ public class RunCheckpointTests
|
||||
var resume = Prepare();
|
||||
_run.RestoreCheckpoint(resume);
|
||||
Assert.That(_run.BuildRewardPending, Is.True);
|
||||
Assert.That(_run.Journey.encounterRevision, Is.EqualTo(1));
|
||||
Assert.That(_run.Journey.encounterRevision, Is.EqualTo(2));
|
||||
int bits = _run.Bits;
|
||||
Assert.That(_run.ClaimBuildReward(null, CardUpgradeKind.MagnitudeUp, true), Is.True);
|
||||
RunCheckpointService.SaveAndSuspend(_saves, _run, _combat);
|
||||
@@ -200,6 +201,22 @@ public class RunCheckpointTests
|
||||
Assert.That(_combat.RunConfig.RunSeed, Is.EqualTo(-7712));
|
||||
}
|
||||
|
||||
[TestCase(0, 0, 0)]
|
||||
[TestCase(1, 1, 0)]
|
||||
[TestCase(3, 3, 1)]
|
||||
[TestCase(5, 5, 3)]
|
||||
[TestCase(6, 6, 4)]
|
||||
[TestCase(int.MaxValue, 6, 4)]
|
||||
public void JavaWarmupRestoresPartialProgressClampsLegacyExcessAndCools(int saved, int restored, int cooled)
|
||||
{
|
||||
var snapshot = _combat.CaptureBoundaryState();
|
||||
snapshot.javaCardsPlayed = saved;
|
||||
_combat.RestoreBoundaryState(_combat.RunConfig, snapshot);
|
||||
Assert.That(_combat.CaptureBoundaryState().javaCardsPlayed, Is.EqualTo(restored));
|
||||
typeof(CombatManager).GetMethod("DecayJavaWarmupForNextWave", Private).Invoke(_combat, null);
|
||||
Assert.That(_combat.CaptureBoundaryState().javaCardsPlayed, Is.EqualTo(cooled));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FailedCheckpointWriteKeepsRunActiveAndExistingSaveUnchanged()
|
||||
{
|
||||
@@ -306,7 +323,7 @@ public class RunCheckpointTests
|
||||
Assert.That(_run.SelectRoute(WaveRoute.Challenge), Is.True);
|
||||
RunCheckpointService.SaveAndSuspend(_saves, _run, _combat);
|
||||
var restored = Prepare();
|
||||
Assert.That(restored.Snapshot.version, Is.EqualTo(3));
|
||||
Assert.That(restored.Snapshot.version, Is.EqualTo(4));
|
||||
_run.RestoreCheckpoint(restored);
|
||||
_combat.RestoreBoundaryState(restored.Config, restored.Snapshot.combat);
|
||||
Assert.That(_run.Journey.campaign, Is.True);
|
||||
@@ -331,8 +348,8 @@ public class RunCheckpointTests
|
||||
[Test]
|
||||
public void BossMilestoneSurvivesSaveAndResumeWithoutStartingEndless()
|
||||
{
|
||||
Set(_run, "currentWaveNumber", 6);
|
||||
Set(_run, "_wavesCleared", 5);
|
||||
Set(_run, "currentWaveNumber", RunJourney.BossWave + 1);
|
||||
Set(_run, "_wavesCleared", RunJourney.BossWave);
|
||||
RunCheckpointService.SaveAndSuspend(_saves, _run, _combat);
|
||||
var restored = Prepare();
|
||||
_run.RestoreCheckpoint(restored);
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SerializedEffectTargetingTests
|
||||
}
|
||||
|
||||
[TestCase("lang_c_malloc", true, false)]
|
||||
[TestCase("lang_py_for_loop", false, true)]
|
||||
[TestCase("lang_py_for_loop", false, false)]
|
||||
[TestCase("lang_rs_borrow", false, false)]
|
||||
[TestCase("external_card", false, false)]
|
||||
public void EmptyAndNullOnlyOverridesUseCatalogTargeting(string id, bool single, bool all)
|
||||
|
||||
@@ -438,7 +438,7 @@ public class TerminalUiTests
|
||||
var instance = new CardInstance(card) { IsBroken = true };
|
||||
instance.ApplyDrawRider(2);
|
||||
var face = new VisualElement();
|
||||
Runtime.GetType("KernelPanic.UI.SoftwareCardView").GetMethod("Populate").Invoke(null, new object[] { face, instance, 3 });
|
||||
Runtime.GetType("KernelPanic.UI.SoftwareCardView").GetMethod("Populate", new[] { typeof(VisualElement), typeof(CardInstance), typeof(int) }).Invoke(null, new object[] { face, instance, 3 });
|
||||
Assert.That(face.ClassListContains("software-c"), Is.True);
|
||||
Assert.That(face.ClassListContains("software-corrupted"), Is.True);
|
||||
Assert.That(face.Q<Label>(className: "software-cost").text, Is.EqualTo("3c"));
|
||||
@@ -450,7 +450,7 @@ public class TerminalUiTests
|
||||
[Test]
|
||||
public void EveryCardRetainsItsCompleteRulesInTheManifest()
|
||||
{
|
||||
var populate = Runtime.GetType("KernelPanic.UI.SoftwareCardView").GetMethod("Populate");
|
||||
var populate = Runtime.GetType("KernelPanic.UI.SoftwareCardView").GetMethod("Populate", new[] { typeof(VisualElement), typeof(CardInstance), typeof(int) });
|
||||
var guids = AssetDatabase.FindAssets("t:CardDefinition", new[] { "Assets/Data/Cards" });
|
||||
Assert.That(guids.Length, Is.GreaterThan(0));
|
||||
foreach (string guid in guids)
|
||||
|
||||
@@ -180,6 +180,28 @@ public class TutorialTests
|
||||
Assert.That(restored.Offers.Any(o => o.Sold), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RebalancedUnwrapStillCompletesTheGuidedFirstKillWithoutACrit()
|
||||
{
|
||||
Call(_combat, "SpawnEncounter");
|
||||
var zombie = _combat.Enemies.Single(enemy => enemy.ArchetypeId == "zombie_process");
|
||||
_combat.PlayerState.ForceMaxRolls = true; // Disables critical hits and Rust's rare overflow.
|
||||
var card = _run.RunDeck.Single(item => item.Definition.Id == "lang_rs_unwrap");
|
||||
var context = new CombatContext(card, _combat.PlayerState, new[] { zombie.State },
|
||||
_combat, _combat.DamagePipeline, new StatusEffectController(), _combat.DeckController,
|
||||
_combat.HandController, _combat.Enemies);
|
||||
|
||||
Call(_combat, "OnEnable");
|
||||
try
|
||||
{
|
||||
foreach (var effect in CardEffectFactory.CreateEffects(card.Definition)) effect.Execute(context);
|
||||
|
||||
Assert.That(zombie.State.IsDefeated, Is.True);
|
||||
Assert.That(zombie.PendingRevive, Is.True, "The guide requires an actual first kill and pending revival.");
|
||||
}
|
||||
finally { Call(_combat, "OnDisable"); }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TargetingRequiresSelectingTheExpectedCardAndActualZombieRevival()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user