Revamp UI a whole lot

This commit is contained in:
2026-11-18 19:42:44 +01:00
parent 260abc2c98
commit fdde7f9d80
57 changed files with 2667 additions and 935 deletions
+11
View File
@@ -370,6 +370,17 @@ public class CampaignTests
Assert.That(_run.RewardsSettled, Is.False);
}
[Test]
public void CommitMilestonesPayAtFiveBossAndEndlessIntervals()
{
var method=typeof(RunManager).GetMethod("CalculateCommitReward",BindingFlags.Static|BindingFlags.NonPublic);
Assert.That(method,Is.Not.Null);
Assert.That(method.Invoke(null,new object[]{4}),Is.EqualTo(0));
Assert.That(method.Invoke(null,new object[]{5}),Is.EqualTo(1));
Assert.That(method.Invoke(null,new object[]{RunJourney.BossWave}),Is.EqualTo(2));
Assert.That(method.Invoke(null,new object[]{15}),Is.EqualTo(1));
}
[Test]
public void PreviewUsesFifoThenLifoCapturedTargetsAndDoesNotConsumeAnything()
{
+49 -17
View File
@@ -49,6 +49,17 @@ public class CollectionLayoutTests
screen.Bind(root, null, null, null, owned);
var scroll = root.Q<ScrollView>("CollectionDetail");
window.position = new Rect(32, 32, 1280, 720);
root.style.width = 1280;
root.style.height = 720;
screen.RefreshUnits(database.AllDistros);
for (int frame = 0; frame < 5; frame++) yield return null;
var columns = scroll.Q<Label>(className: "unit-ls-header");
var firstUnit = scroll.Q<Button>(className: "unit-overview-row");
Assert.That(firstUnit.worldBound.yMin, Is.GreaterThanOrEqualTo(columns.worldBound.yMax - 1));
Assert.That(firstUnit.worldBound.yMin - columns.worldBound.yMax, Is.LessThan(12),
"The distro roster should start immediately below its ls header, not at the bottom of the pane.");
foreach (var size in Viewports)
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
foreach (var density in new[] { UILayoutDensity.Compact, UILayoutDensity.Comfortable })
@@ -68,23 +79,40 @@ public class CollectionLayoutTests
var passive = scroll.Q(className: "unit-passive-section");
Assert.That(identity, Is.Not.Null, context);
Assert.That(passive, Is.Not.Null, context);
var identityTitle = identity.Q<Label>(className: "detail-section-title");
var languages = identity.Q(className: "kv-row");
var description = identity.Q<Label>(className: "collection-detail-description");
var passiveTitle = passive.Q<Label>(className: "detail-section-title");
var rules = passive.Q<Label>(className: "collection-detail-description");
var identityTitle = identity.Q<Label>(className: "unit-overview-section-label");
var facts = identity.Q(className: "unit-overview-facts");
var languages = identity.Q("UnitOverview_languages");
var uptime = identity.Q("UnitOverview_uptime");
var ram = identity.Q("UnitOverview_ram");
var cycles = identity.Q("UnitOverview_cycles");
var description = identity.Q<Label>("UnitOverview_description");
var passiveTitle = passive.Q<Label>(className: "unit-overview-section-label");
var passiveName = passive.Q<Label>("UnitPassive_name");
var rules = passive.Q<Label>("UnitPassive_rules");
Assert.That(identityTitle.text, Is.EqualTo("[host]"), context);
Assert.That(passiveTitle.text, Is.EqualTo("[passive]"), context);
Assert.That(description.text, Is.EqualTo(unit.Description), context);
Assert.That(passiveTitle.text, Is.EqualTo(unit.Passive.Name), context);
Assert.That(passiveName.text, Is.EqualTo(unit.Passive.Name), context);
Assert.That(languages.Q<Label>(className: "unit-overview-fact-value").text,
Is.EqualTo(DistroPresentation.FormatLanguages(unit)), context);
Assert.That(uptime.Q<Label>(className: "unit-overview-fact-value").text,
Is.EqualTo(unit.BaseUptime.ToString()), context);
Assert.That(ram.Q<Label>(className: "unit-overview-fact-value").text,
Is.EqualTo(unit.BaseRam.ToString()), context);
Assert.That(cycles.Q<Label>(className: "unit-overview-fact-value").text,
Is.EqualTo(unit.BaseCyclesPerTurn.ToString()), context);
if (unit.Id == "nixos")
Assert.That(rules.text, Does.Contain("performance: +20% card damage").And.Contain("powersave: -20% card damage").And.Contain("schedutil: +5% card damage"), context);
Assert.That(rules.text, Does.Contain("performance +20% damage").And.Contain("powersave -20% damage").And.Contain("schedutil +5% damage"), context);
else
Assert.That(rules.text, Is.EqualTo(unit.Passive.RulesText), context);
float copyGap = density == UILayoutDensity.Comfortable ? 14 : 10;
float sectionGap = density == UILayoutDensity.Comfortable ? 31.5f : 23.5f;
AssertVerticalGap(identityTitle, languages, copyGap, context + ": identity heading");
AssertVerticalGap(languages, description, copyGap, context + ": language row");
AssertVerticalGap(description, passiveTitle, sectionGap, context + ": passive section");
AssertVerticalGap(passiveTitle, rules, copyGap, context + ": passive heading");
Assert.That(identity.Q("UnitConfig_name"), Is.Null, context + ": duplicate name");
Assert.That(identity.Q("UnitConfig_release"), Is.Null, context + ": duplicate release");
Assert.That(identity.Q("UnitConfig_version"), Is.Null, context + ": duplicate version");
Assert.That(identity.Q("UnitConfig_rarity"), Is.Null, context + ": duplicate rarity");
Assert.That(languages.worldBound.yMin, Is.GreaterThan(identityTitle.worldBound.yMin), context);
Assert.That(description.worldBound.yMin, Is.GreaterThanOrEqualTo(facts.worldBound.yMax - 1), context);
Assert.That(passiveTitle.worldBound.yMin, Is.GreaterThan(description.worldBound.yMin), context);
Assert.That(rules.worldBound.yMin, Is.GreaterThan(passiveTitle.worldBound.yMin), context);
Assert.That(rules.resolvedStyle.fontSize, Is.EqualTo(textSize == UITextSize.Large ? 17 : 15), context);
foreach (var section in new[] { identity, passive })
@@ -98,11 +126,15 @@ public class CollectionLayoutTests
Assert.That(label.worldBound.yMax, Is.LessThanOrEqualTo(section.worldBound.yMax + 1), context);
}
}
var flavor = passive.Q<Label>(className: "flavor-text");
if (flavor != null) AssertVerticalGap(rules, flavor, copyGap, context + ": flavor text");
var flavor = passive.Q<Label>("UnitPassive_flavor");
if (flavor != null)
{
Assert.That(flavor.text, Is.EqualTo("# " + unit.Passive.FlavorText), context);
Assert.That(flavor.worldBound.yMin, Is.GreaterThan(rules.worldBound.yMin), context + ": comment");
}
// On a short viewport the document must scroll, retaining the same gaps and text height.
if (size.y == 400)
if (size.y == 400 && scroll.contentContainer.layout.height > scroll.contentViewport.layout.height + 1)
{
Assert.That(scroll.contentContainer.layout.height,
Is.GreaterThan(scroll.contentViewport.layout.height), context + ": scrollable content");
@@ -110,7 +142,7 @@ public class CollectionLayoutTests
scroll.ScrollTo(passive);
for (int frame = 0; frame < 2; frame++) yield return null;
Assert.That(scroll.scrollOffset.y, Is.GreaterThan(0), context);
AssertVerticalGap(passiveTitle, rules, copyGap, context + ": scrolled passive heading");
Assert.That(rules.worldBound.yMin, Is.GreaterThan(passiveTitle.worldBound.yMin), context + ": scrolled passive heading");
AssertTextFits(rules, context);
}
}
+199 -114
View File
@@ -359,6 +359,142 @@ public class CombatLayoutTests
_root.style.height = size.y;
}
[UnityTest]
public IEnumerator CombatUsesProcessRowsCommandTokensAndNarrowPaneSwitching()
{
Resize(new Vector2(1280, 720));
Call(_view, "RefreshEnemies");
Call(_view, "RefreshCommandPrompt");
for (int frame = 0; frame < 4; frame++) yield return null;
var prompt = _root.Q("CombatCommandPrompt");
Assert.That(prompt, Is.Not.Null);
Assert.That(prompt.Q<Label>(className: "syntax-prompt").text, Does.StartWith("player@gentoo"));
Assert.That(prompt.Q<Label>(className: "syntax-command").text, Is.EqualTo("exec"));
Assert.That(prompt.Q<Label>(className: "syntax-argument").text, Does.Contain("--target pid"));
var header = _root.Q("ProcessTableHeader");
CollectionAssert.AreEqual(new[] { "PID", "STATE", "PROCESS", "UPTIME", "SHIELD", "NEXT", "RESULT" },
header.Query<Label>(className: "process-column").ToList().Select(label => label.text).ToArray());
var stateColumn = header.Q<Label>(className: "process-col-state");
var processColumn = header.Q<Label>(className: "process-col-name");
Assert.That(processColumn.worldBound.xMin - stateColumn.worldBound.xMin, Is.GreaterThanOrEqualTo(125));
Assert.That(processColumn.worldBound.width, Is.InRange(230, 250));
var processes = _root.Query<Button>(className: "enemy-card").ToList();
Assert.That(processes.Count, Is.EqualTo(2));
Assert.That(processes.Select(row => row.Q<Label>(className: "process-pid").text).Distinct().Count(), Is.EqualTo(2));
foreach (var process in processes)
{
Assert.That(process.Q<Label>(className: "process-state").text, Is.Not.Empty);
Assert.That(process.Q<Label>(className: "enemy-name").text, Is.Not.Empty);
Assert.That(process.Q(className: "process-col-uptime"), Is.Not.Null);
Assert.That(process.Q("ProcessIntent"), Is.Not.Null);
Assert.That(process.Q<Label>("ProcessResult"), Is.Not.Null);
Assert.That(process.Q<Label>(className: "process-behavior"), Is.Null,
"Lifecycle and intent columns replace the old expanding explanation line.");
}
Resize(new Vector2(390, 844));
for (int frame = 0; frame < 5; frame++) yield return null;
Assert.That(_root.ClassListContains("narrow"), Is.True);
var hand = _root.Q<Button>("CombatPane_hand");
using (var submit = NavigationSubmitEvent.GetPooled())
{
submit.target = hand;
hand.SendEvent(submit);
}
Assert.That(_root.ClassListContains("combat-pane-hand"), Is.True);
Assert.That(hand.ClassListContains("selected"), Is.True);
Assert.That(_root.Q<Button>("CombatPane_processes").ClassListContains("selected"), Is.False);
LogAssert.NoUnexpectedReceived();
}
[UnityTest]
public IEnumerator RestartingZombieCannotWrapLivingTargetsOutOfTheProcessList()
{
var database = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
var enemies = (List<EnemyInstance>)_combat.Enemies;
enemies.Clear();
var zombie = new EnemyInstance(EnemyArchetypeCatalog.Get("zombie_process"), 7);
zombie.MarkPendingRevive();
enemies.Add(zombie);
enemies.Add(new EnemyInstance(EnemyArchetypeCatalog.Get("cron_job"), 8));
var fetch = new CardInstance(database.FindById("lang_js_fetch"));
_combat.HandController.Add(fetch);
Assert.That(_combat.PlayCard(fetch), Is.False, "The first play should enter enemy targeting.");
Assert.That(_combat.PendingTargetCard, Is.SameAs(fetch));
Call(_view, "RefreshEnemies");
Resize(new Vector2(1280, 720));
for (int frame = 0; frame < 6; frame++) yield return null;
var rows = _root.Query<Button>(className: "enemy-card").ToList();
Assert.That(rows.Count, Is.EqualTo(2));
var zombieRow = rows.Single(row => row.Q<Label>(className: "enemy-name").text.Contains("Zombie"));
var cronRow = rows.Single(row => row.Q<Label>(className: "enemy-name").text.Contains("Cron"));
Assert.That(zombieRow.parent.resolvedStyle.flexWrap, Is.EqualTo(Wrap.NoWrap));
Assert.That(cronRow.worldBound.xMin, Is.EqualTo(zombieRow.worldBound.xMin).Within(1),
"A taller restarting process must not wrap the next target into an off-screen column.");
Assert.That(cronRow.worldBound.yMin, Is.GreaterThanOrEqualTo(zombieRow.worldBound.yMax - 1));
Assert.That(cronRow.enabledInHierarchy, Is.True);
Assert.That(cronRow.worldBound.width, Is.GreaterThan(100));
using (var submit = NavigationSubmitEvent.GetPooled())
{
submit.target = cronRow;
cronRow.SendEvent(submit);
}
Assert.That(_combat.PendingTargetCard, Is.Null);
Assert.That(_combat.HandController.Cards.Contains(fetch), Is.False,
"The living process below a restarting Zombie must remain selectable.");
LogAssert.NoUnexpectedReceived();
}
[UnityTest]
public IEnumerator DefaultCombatViewCollapsesSecondaryTelemetryUntilRequested()
{
Resize(new Vector2(1280, 720));
Call(_view, "RefreshTracks");
Call(_view, "RefreshHand");
for (int frame = 0; frame < 6; frame++) yield return null;
var scheduler = _root.Q(className: "scheduler");
Assert.That(scheduler.ClassListContains("scheduler-idle"), Is.True);
foreach (var zone in scheduler.Query(className: "track-zone").ToList())
Assert.That(zone.resolvedStyle.display, Is.EqualTo(DisplayStyle.None));
var journal = _root.Q<Foldout>(className: "combat-journal");
Assert.That(journal.value, Is.False, "The full log should be opt-in; its title still reports the latest event.");
for (int i = 0; i < 12; i++)
Call(_view, "AppendCombatLog", $"layout event {i}", "journal-operation");
for (int frame = 0; frame < 3; frame++) yield return null;
var handPanel = _root.Q(className: "hand-panel");
var handViewport = _root.Q<ScrollView>(className: "hand-scroll").contentViewport;
Assert.That(handViewport.worldBound.height, Is.GreaterThanOrEqualTo(210),
"The collapsed journal should leave enough vertical room to inspect a standard card.");
float collapsedHandTop = handPanel.worldBound.yMin;
journal.value = true;
for (int frame = 0; frame < 4; frame++) yield return null;
Assert.That(handPanel.worldBound.yMin, Is.LessThan(collapsedHandTop - 40),
"Opening the journal should lift the hand instead of permanently reserving log space.");
journal.value = false;
for (int frame = 0; frame < 4; frame++) yield return null;
Assert.That(handPanel.worldBound.yMin, Is.EqualTo(collapsedHandTop).Within(2),
"Closing the journal should return the hand to its lower resting position.");
var face = _root.Query<Button>(className: "hand-card").First();
Assert.That(face.Query<Label>(className: "software-line-number").ToList()
.All(label => label.resolvedStyle.display == DisplayStyle.None), Is.True);
var preview = face.Q<Label>(className: "software-live-preview");
Assert.That(preview, Is.Not.Null);
Assert.That(preview.resolvedStyle.display, Is.EqualTo(DisplayStyle.None));
face.Focus();
yield return null;
Assert.That(preview.resolvedStyle.display, Is.EqualTo(DisplayStyle.Flex),
"Calculated detail should appear for the card the player is actively inspecting.");
LogAssert.NoUnexpectedReceived();
}
[UnityTest]
public IEnumerator TutorialSpotlightKeepsTargetAndControlsReachableAtEveryViewport()
{
@@ -578,6 +714,22 @@ public class CombatLayoutTests
}
var footer = repository.Q(className: "repository-footer");
Assert.That(footer.worldBound.yMax, Is.LessThanOrEqualTo(_root.worldBound.yMax + 1), context);
var timeshiftToggle = repository.Q<Button>("RepositoryRulesToggle_mint_timeshift");
Assert.That(timeshiftToggle, Is.Not.Null, context);
var timeshiftCard = timeshiftToggle.parent.Q(className: "repository-card-preview");
var timeshiftDetails = timeshiftCard.Query<Label>(className: "software-conditions").ToList();
Assert.That(timeshiftDetails.Count, Is.GreaterThan(0), context);
Assert.That(timeshiftDetails.All(label => label.resolvedStyle.display == DisplayStyle.None), Is.True, context);
using (var submit = NavigationSubmitEvent.GetPooled())
{
submit.target = timeshiftToggle;
timeshiftToggle.SendEvent(submit);
}
for (int frame = 0; frame < 2; frame++) yield return null;
Assert.That(timeshiftCard.ClassListContains("repository-card-expanded"), Is.True, context);
Assert.That(timeshiftDetails.All(label => label.resolvedStyle.display == DisplayStyle.Flex), Is.True, context);
Assert.That(timeshiftToggle.text, Does.Contain("hide full rules"), context);
LogAssert.NoUnexpectedReceived();
}
}
@@ -905,87 +1057,44 @@ public class CombatLayoutTests
}
[UnityTest]
public IEnumerator PlanningActionsAndResultsDialogFitEveryViewport()
public IEnumerator JournalOwnsOptionalActionDetailsWithoutCombatPopups()
{
var view = typeof(CombatSceneController).GetField("_turnResolution", Private).GetValue(_view);
foreach (var size in Viewports)
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
{
UIPreferences.TextSize = textSize;
Resize(size);
Call(_view, "RefreshTurnPanel");
for (int frame = 0; frame < 4; frame++) yield return null;
foreach (string name in new[] { "SaveCombatButton", "OpenTurnResolution" })
{
var control = _root.Q<Button>(name);
Assert.That(control.worldBound.height, Is.GreaterThan(20), name);
AssertContainedHorizontally(control, _root, name);
Assert.That(control.worldBound.yMin, Is.GreaterThanOrEqualTo(_root.worldBound.yMin - 1), name);
Assert.That(control.worldBound.yMax, Is.LessThanOrEqualTo(_root.worldBound.yMax + 1), name);
}
view.GetType().GetMethod("Open").Invoke(view, new object[] { _root });
for (int frame = 0; frame < 4; frame++) yield return null;
var popup = _root.Q("TurnResolutionPopup");
var dialog = popup.Q("TurnResolutionDialog");
AssertContainedHorizontally(dialog, _root, $"{size}/{textSize}");
Assert.That(dialog.worldBound.yMin, Is.GreaterThanOrEqualTo(_root.worldBound.yMin - 1));
Assert.That(dialog.worldBound.yMax, Is.LessThanOrEqualTo(_root.worldBound.yMax + 1));
Assert.That(popup.Q<ScrollView>().contentViewport.worldBound.height, Is.GreaterThan(80));
var close = popup.Q<Button>("CloseTurnResolution");
using (var endTurn = KeyDownEvent.GetPooled('e', KeyCode.E, EventModifiers.None))
{ endTurn.target = close; close.SendEvent(endTurn); }
Assert.That(_combat.CurrentPhase, Is.EqualTo(TurnPhase.Execute));
using (var escape = KeyDownEvent.GetPooled('\0', KeyCode.Escape, EventModifiers.None))
{ escape.target = close; close.SendEvent(escape); }
Assert.That(_root.Q("TurnResolutionPopup"), Is.Null);
Assert.That(_root.Q("ResolutionActions"), Is.Null, "Results must not occupy the battlefield after closing.");
Assert.That(_root.focusController.focusedElement, Is.SameAs(_root.Q<Button>("OpenTurnResolution")));
}
}
Resize(new Vector2(1280, 720));
Assert.That(_root.Q<Button>("OpenExecutionPreview"), Is.Null);
Assert.That(_root.Q<Button>("OpenTurnResolution"), Is.Null);
Assert.That(_root.Q("ExecutionPreviewPopup"), Is.Null);
Assert.That(_root.Q("TurnResolutionPopup"), Is.Null);
[UnityTest]
public IEnumerator ExecutionPreviewWrapsAndDoesNotDisplaceDispatchControls()
{
var preview = _root.Q<Button>("OpenExecutionPreview");
var view = typeof(CombatSceneController).GetField("_executionPreview", Private).GetValue(_view);
view.GetType().GetMethod("Refresh").Invoke(view, new object[] { _combat });
foreach (var size in Viewports)
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
{
UIPreferences.TextSize = textSize;
Resize(size);
Call(_view, "RefreshTurnPanel");
for (int frame = 0; frame < 3; frame++) yield return null;
var before = _root.Q<ScrollView>(className: "combat-workspace").worldBound;
using (var submit = NavigationSubmitEvent.GetPooled()) { submit.target = preview; preview.SendEvent(submit); }
for (int frame = 0; frame < 5; frame++) yield return null;
var popup = _root.Q("ExecutionPreviewPopup");
Assert.That(popup, Is.Not.Null, "Preview must always open as a dialog.");
var scroll = popup.Q<ScrollView>();
Assert.That(popup.Query(className: "execution-step").ToList().Count, Is.EqualTo(6));
var workspace = _root.Q<ScrollView>(className: "combat-workspace");
Assert.That(workspace.worldBound, Is.EqualTo(before), "Opening the preview must not shift the battlefield.");
var visiblePreview = popup.Q("ExecutionPreviewDialog");
var availableArea = _root;
Assert.That(visiblePreview.worldBound.yMin, Is.GreaterThanOrEqualTo(availableArea.worldBound.yMin - 1));
Assert.That(visiblePreview.worldBound.yMax, Is.LessThanOrEqualTo(availableArea.worldBound.yMax + 1));
foreach (var label in scroll.Query<Label>(className: "terminal-body").ToList())
AssertContainedHorizontally(label, scroll.contentViewport, $"{size}/{textSize}");
Assert.That(_root.Q<Button>(className: "primary-action").worldBound.yMax,
Is.LessThanOrEqualTo(_root.worldBound.yMax + 1));
if (popup != null)
{
var close = popup.Q<Button>("CloseExecutionPreview");
using (var endTurn = KeyDownEvent.GetPooled('e', KeyCode.E, EventModifiers.None))
{ endTurn.target = close; close.SendEvent(endTurn); }
Assert.That(_combat.CurrentPhase, Is.EqualTo(TurnPhase.Execute), "Preview must consume combat shortcuts.");
using (var escape = KeyDownEvent.GetPooled('\0', KeyCode.Escape, EventModifiers.None))
{ escape.target = close; close.SendEvent(escape); }
Assert.That(_root.Q("ExecutionPreviewPopup"), Is.Null);
Assert.That(_root.Q("ExecutionPreviewSteps"), Is.Null);
Assert.That(_root.focusController.focusedElement, Is.SameAs(preview));
}
}
var trace = (CombatExecutionTrace)typeof(CombatSceneController)
.GetField("_executionTrace", Private).GetValue(_view);
Assert.That(trace, Is.Not.Null);
var action = new ExecutionAction();
typeof(ExecutionAction).GetProperty("Stage").SetValue(action, "FIFO");
typeof(ExecutionAction).GetProperty("Label").SetValue(action, "print()");
typeof(ExecutionAction).GetProperty("Complete").SetValue(action, true);
typeof(ExecutionAction).GetProperty("UptimeDamage").SetValue(action, 12L);
action.Details.Add("print() resolved / queue / FIFO");
action.DamageBreakdowns.Add("Zombie Process / base 12 - Shield 0 = 12 Uptime");
var actions = (List<ExecutionAction>)typeof(CombatExecutionTrace)
.GetField("_actions", Private).GetValue(trace);
actions.Add(action);
Call(_view, "RefreshJournalActionResults");
var journal = _root.Q<Foldout>(className: "combat-journal");
journal.value = true;
for (int frame = 0; frame < 5; frame++) yield return null;
var result = _root.Q<Foldout>(className: "journal-action-result");
Assert.That(result, Is.Not.Null);
Assert.That(result.text, Does.Contain("[FIFO] print() · done · 12 damage"));
Assert.That(result.value, Is.False, "Detailed calculations should remain opt-in.");
result.value = true;
for (int frame = 0; frame < 2; frame++) yield return null;
var damage = result.Q<Label>(className: "journal-action-damage");
Assert.That(damage, Is.Not.Null);
Assert.That(damage.resolvedStyle.display, Is.EqualTo(DisplayStyle.Flex));
Assert.That(damage.text, Does.Contain("base 12"));
Assert.That(_root.Q<Button>("SaveCombatButton"), Is.Not.Null);
LogAssert.NoUnexpectedReceived();
}
[UnityTest]
@@ -1239,7 +1348,7 @@ public class CombatLayoutTests
}
[UnityTest]
public IEnumerator MintPackageStatusAndNotificationsStayInsideCompactRows()
public IEnumerator PackagesDoNotReserveHostSpaceAndActivationFeedbackStaysTransient()
{
var packages = AssetDatabase.LoadAssetAtPath<PackageDatabase>("Assets/Data/Packages/PackageDatabase.asset");
var mint = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Mint.asset");
@@ -1248,39 +1357,29 @@ public class CombatLayoutTests
.Select(id => new PackageInstance(packages.FindById(id), 5)).ToArray(), 17, 5));
var activation = _root.Q<Label>("PackageActivation");
Assert.That(activation.style.display.value, Is.EqualTo(DisplayStyle.None));
Assert.That(_root.Q("CombatPackages"), Is.Null);
Assert.That(_root.Q("PackageReadiness"), Is.Null);
foreach (var size in Viewports)
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
{
UIPreferences.TextSize = textSize;
Resize(size);
Call(_view, "RefreshPackageReadiness");
Call(_view, "RefreshPlayer");
for (int frame = 0; frame < 5; frame++) yield return null;
string context = $"{size}/{textSize}";
var strip = _root.Q("PackageReadiness");
Assert.That(_root.Q(className: "player-panel").Contains(strip), Is.True, "Packages belong with the host.");
foreach (var chip in strip.Query(className: "package-readiness-chip").ToList())
{
AssertContainedHorizontally(chip, strip, context);
Assert.That(chip.worldBound.height, Is.LessThan(70), context);
foreach (var label in chip.Query<Label>().ToList())
{
AssertContainedHorizontally(label, chip, context);
Assert.That(label.worldBound.yMin, Is.GreaterThanOrEqualTo(chip.worldBound.yMin), context);
Assert.That(label.worldBound.yMax, Is.LessThanOrEqualTo(chip.worldBound.yMax), context);
}
Assert.That(chip.tooltip, Does.Contain(chip.Q<Label>(className: "package-readiness-state").text));
}
Assert.That(_root.Q("CombatPackages"), Is.Null, context);
Assert.That(_root.Q("PackageReadiness"), Is.Null, context);
Call(_view, "HandlePackageActivated", new PackageActivation("pkg_mint_timeshift", "Timeshift", "Full recovery notification with enough detail to overflow a narrow screen if it wraps"));
Call(_view, "HandlePackageActivated", new PackageActivation("pkg_mint_cinnamon", "Cinnamon", "JavaScript damage increased for this round"));
for (int frame = 0; frame < 3; frame++) yield return null;
AssertContainedHorizontally(activation, strip.parent, context);
AssertContainedHorizontally(activation, _root.Q(className: "player-panel"), context);
Assert.That(activation.worldBound.height, Is.LessThan(30), context);
Assert.That(activation.tooltip, Is.EqualTo(activation.text));
}
}
[UnityTest]
public IEnumerator LivePreviewsAndPackageReadinessWrapAndRetainKeyboardFocus()
public IEnumerator LivePreviewsRemainReadableWithoutPersistentPackageRows()
{
var packages = AssetDatabase.LoadAssetAtPath<PackageDatabase>("Assets/Data/Packages/PackageDatabase.asset");
var config = new RunConfig(_gentoo, Language.Haskell, Language.C, _gentoo.ExclusiveCards.Take(4).ToArray(),
@@ -1295,27 +1394,13 @@ public class CombatLayoutTests
UIPreferences.TextSize = textSize;
UIPreferences.Density = density;
Resize(size);
Call(_view, "RefreshPackageReadiness");
Call(_view, "RefreshHand");
for (int frame = 0; frame < 6; frame++) yield return null;
string context = $"{size}, {textSize}, {density}";
var strip = _root.Q("PackageReadiness");
var chips = strip.Query(className: "package-readiness-chip").ToList();
Assert.That(chips.Count, Is.EqualTo(3), context);
foreach (var chip in chips)
{
AssertContainedHorizontally(chip, strip, context);
Assert.That(chip.worldBound.height, Is.GreaterThan(16), context);
Assert.That(chip.tooltip, Does.Contain("\n"), context);
foreach (var label in chip.Query<Label>().ToList())
AssertContainedHorizontally(label, chip, context);
}
var ccache = _root.Q("Readiness_pkg_gentoo_ccache");
ccache.Focus();
Call(_view, "RefreshPackageReadiness");
Assert.That(_root.focusController.focusedElement, Is.SameAs(ccache), context);
Assert.That(_root.Q("CombatPackages"), Is.Null, context);
Assert.That(_root.Q("PackageReadiness"), Is.Null, context);
Call(_view, "RefreshPlayer");
Assert.That(_root.Q("PackageReadiness"), Is.SameAs(strip), "Refreshing host stats must retain installed packages.");
Assert.That(_root.Q("CombatPackages"), Is.Null, context);
foreach (var face in _root.Query(className: "hand-card").ToList())
{
var preview = face.Q<Label>(className: "software-live-preview");
+30 -12
View File
@@ -18,13 +18,18 @@ public class DailyQuestLayoutTests
{
var state = new DailyQuestState
{
selectedQuests = new[] { DailyQuestKind.Cards, DailyQuestKind.Damage, DailyQuestKind.Waves },
selectedQuests = new[]
{
DailyQuestKind.Cards, DailyQuestKind.Damage, DailyQuestKind.Waves,
DailyQuestKind.BlockDamage, DailyQuestKind.NativeCards
},
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.tooltip, Is.Empty, "The terminal widget must not spawn a native floating tooltip over the menu.");
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>("DailyQuestCompleted").text, Is.EqualTo("2/5 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.");
@@ -35,6 +40,14 @@ public class DailyQuestLayoutTests
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<Label>("DailyQuestCompletionBonusStatus").text, Does.Contain("waiting for all five jobs to exit 0"));
Assert.That(overlay.Q<Label>(className: "daily-service-title").text, Is.EqualTo("[ crontab -l ]"));
Assert.That(overlay.Q("DailyQuestCards").Q<Label>(className: "daily-cron-entry").text,
Is.EqualTo("0 0 * * * /etc/cron.daily/play-cards"));
Assert.That(overlay.Q("DailyQuestDamage").Q<Label>(className: "daily-exit-status").text,
Does.Contain("exit=0").And.Contain("reward=pending"));
Assert.That(overlay.Q("DailyQuestCompletionBonus").Query<Label>().ToList().Select(label => label.text),
Does.Contain($"+{DailyQuests.CompletionBonusBandwidth} Bandwidth / +{DailyQuests.CompletionBonusEntropy} Entropy / +{DailyQuests.CompletionBonusCommits} Commits"));
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));
@@ -69,6 +82,8 @@ public class DailyQuestLayoutTests
var featured = new FeaturedUnitPanel();
featured.Bind(root, null);
featured.Refresh(new[] { AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Ubuntu.asset") });
Assert.That(root.Q("FeaturedUnitPanel").tooltip, Is.Empty,
"The neofetch preview must not spawn a native floating tooltip over the menu.");
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) })
@@ -82,8 +97,8 @@ public class DailyQuestLayoutTests
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] };
data.dailyQuests.selectedQuests = Enumerable.Range(0, DailyQuests.Count)
.Select(offset => DailyQuests.Pool[(group + offset) % DailyQuests.Pool.Count]).ToArray();
foreach (var kind in DailyQuests.Active(data.dailyQuests))
DailyQuests.Record(data.dailyQuests, kind, int.MaxValue, now);
var host = root.Q("DailyQuestsHost");
@@ -106,7 +121,7 @@ public class DailyQuestLayoutTests
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.Query(className: "daily-service-entry").ToList().Count, Is.EqualTo(DailyQuests.Count), 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);
@@ -138,15 +153,16 @@ public class DailyQuestLayoutTests
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);
Assert.That(dialog.worldBound.center.x, Is.EqualTo(overlay.worldBound.center.x).Within(1),
context + ": dialog is horizontally centered");
Assert.That(dialog.worldBound.center.y, Is.EqualTo(overlay.worldBound.center.y).Within(1),
context + ": dialog is vertically centered");
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;
@@ -154,7 +170,7 @@ public class DailyQuestLayoutTests
{
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"));
Has.Some.StartsWith($"+{reward.Bandwidth} Bandwidth / +{reward.Entropy} Entropy"));
}
foreach (var label in details.Query<Label>().ToList())
{
@@ -174,9 +190,11 @@ public class DailyQuestLayoutTests
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(data.bandwidthBalance, Is.EqualTo(DailyQuests.Active(data.dailyQuests).Sum(kind => DailyQuests.Reward(kind).Bandwidth)
+ DailyQuests.CompletionBonusBandwidth));
Assert.That(data.entropyBalance, Is.EqualTo(DailyQuests.Active(data.dailyQuests).Sum(kind => DailyQuests.Reward(kind).Entropy)
+ DailyQuests.CompletionBonusEntropy));
Assert.That(host.Q<Label>("DailyQuestCompleted").text, Is.EqualTo("5/5 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 }))
{
+88 -11
View File
@@ -34,7 +34,7 @@ public class DailyQuestTests
public void TearDown() => Directory.Delete(_directory, true);
[Test]
public void LegacyDataStartsWithThreeEmptyQuestsWithoutChangingBalances()
public void LegacyDataStartsWithFiveEmptyQuestsWithoutChangingBalances()
{
var data = JsonUtility.FromJson<SaveData>("{\"entropyBalance\":73,\"bandwidthBalance\":129}");
data.EnsureLists();
@@ -96,8 +96,10 @@ public class DailyQuestTests
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));
Assert.That(data.bandwidthBalance, Is.EqualTo(750));
Assert.That(data.entropyBalance, Is.EqualTo(350));
Assert.That(data.commitsBalance, Is.EqualTo(3));
Assert.That(DailyQuests.CompletionBonusClaimed(data.dailyQuests), Is.True);
DailyQuests.Refresh(data.dailyQuests, Start.AddDays(1));
var nextQuest = DailyQuests.Active(data.dailyQuests)[0];
DailyQuests.Record(data.dailyQuests, nextQuest, int.MaxValue, Start.AddDays(1));
@@ -117,7 +119,7 @@ public class DailyQuestTests
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.dailyQuests.selectedQuests = new[] { kind }.Concat(DailyQuests.Pool.Where(other => other != kind).Take(DailyQuests.Count - 1)).ToArray();
data.bandwidthBalance = 37;
data.entropyBalance = 19;
long period = data.dailyQuests.refreshAtUtcTicks;
@@ -130,6 +132,7 @@ public class DailyQuestTests
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.commitsBalance, Is.EqualTo(DailyQuests.CommitReward(kind)));
Assert.That(data.dailyQuests.refreshAtUtcTicks, Is.EqualTo(period));
Assert.That(DailyQuests.Progress(data.dailyQuests, kind), Is.EqualTo(DailyQuests.Target(kind)));
}
@@ -140,7 +143,7 @@ public class DailyQuestTests
foreach (var kind in DailyQuests.Pool)
{
var data = FixedQuests();
data.dailyQuests.selectedQuests = new[] { kind }.Concat(DailyQuests.Pool.Where(other => other != kind).Take(2)).ToArray();
data.dailyQuests.selectedQuests = new[] { kind }.Concat(DailyQuests.Pool.Where(other => other != kind).Take(DailyQuests.Count - 1)).ToArray();
DailyQuests.Record(data.dailyQuests, kind, int.MaxValue, Start);
long period = data.dailyQuests.refreshAtUtcTicks;
var reward = DailyQuests.Reward(kind);
@@ -155,11 +158,21 @@ public class DailyQuestTests
Assert.That(data.entropyBalance, Is.EqualTo(entropy));
Assert.That(DailyQuests.Claimed(data.dailyQuests, kind), Is.False);
}
if (DailyQuests.CommitReward(kind) > 0)
{
data.bandwidthBalance = int.MaxValue - reward.Bandwidth;
data.entropyBalance = int.MaxValue - reward.Entropy;
data.commitsBalance = int.MaxValue;
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.False, kind + " Commit overflow");
Assert.That(DailyQuests.Claimed(data.dailyQuests, kind), Is.False);
}
data.bandwidthBalance = int.MaxValue - reward.Bandwidth;
data.entropyBalance = int.MaxValue - reward.Entropy;
data.commitsBalance = int.MaxValue - DailyQuests.CommitReward(kind);
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));
Assert.That(data.commitsBalance, Is.EqualTo(int.MaxValue));
}
}
@@ -260,8 +273,8 @@ public class DailyQuestTests
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.Length, Is.EqualTo(DailyQuests.Count));
Assert.That(active.Distinct().Count(), Is.EqualTo(DailyQuests.Count));
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);
@@ -284,14 +297,70 @@ public class DailyQuestTests
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(DailyQuests.Active(data.dailyQuests), Is.EqualTo(new[]
{
DailyQuestKind.Waves, DailyQuestKind.Cards, DailyQuestKind.Damage,
DailyQuestKind.BlockDamage, DailyQuestKind.NativeCards
}));
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 }));
Assert.That(DailyQuests.Active(data.dailyQuests), Is.Not.EquivalentTo(new[]
{
DailyQuestKind.Waves, DailyQuestKind.Cards, DailyQuestKind.Damage,
DailyQuestKind.BlockDamage, DailyQuestKind.NativeCards
}));
}
[Test]
public void FifthClaimPaysAllClearBonusExactlyOnceAcrossReload()
{
var data = FixedQuests();
long period = data.dailyQuests.refreshAtUtcTicks;
foreach (var kind in DailyQuests.Active(data.dailyQuests))
DailyQuests.Record(data.dailyQuests, kind, int.MaxValue, Start);
var finalKind = DailyQuests.Active(data.dailyQuests).Last();
foreach (var kind in DailyQuests.Active(data.dailyQuests).Where(kind => kind != finalKind))
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.True);
int bandwidthBefore = data.bandwidthBalance;
int entropyBefore = data.entropyBalance;
int commitsBefore = data.commitsBalance;
Assert.That(DailyQuests.CompletionBonusClaimed(data.dailyQuests), Is.False);
Assert.That(DailyQuests.Claim(data, finalKind, period, Start), Is.True);
Assert.That(data.bandwidthBalance, Is.EqualTo(bandwidthBefore + DailyQuests.Reward(finalKind).Bandwidth + DailyQuests.CompletionBonusBandwidth));
Assert.That(data.entropyBalance, Is.EqualTo(entropyBefore + DailyQuests.Reward(finalKind).Entropy + DailyQuests.CompletionBonusEntropy));
Assert.That(data.commitsBalance, Is.EqualTo(commitsBefore + DailyQuests.CommitReward(finalKind) + DailyQuests.CompletionBonusCommits));
Assert.That(DailyQuests.AllClaimed(data.dailyQuests), Is.True);
Assert.That(DailyQuests.CompletionBonusClaimed(data.dailyQuests), Is.True);
_save.Save(data);
data = _save.Load();
Assert.That(DailyQuests.Claim(data, finalKind, period, Start), Is.False);
Assert.That(DailyQuests.CompletionBonusClaimed(data.dailyQuests), Is.True);
}
[Test]
public void AllClearOverflowLeavesFinalClaimAndEveryBalanceUnchanged()
{
var data = FixedQuests();
long period = data.dailyQuests.refreshAtUtcTicks;
foreach (var kind in DailyQuests.Active(data.dailyQuests))
DailyQuests.Record(data.dailyQuests, kind, int.MaxValue, Start);
var finalKind = DailyQuests.Active(data.dailyQuests).Last();
foreach (var kind in DailyQuests.Active(data.dailyQuests).Where(kind => kind != finalKind))
Assert.That(DailyQuests.Claim(data, kind, period, Start), Is.True);
data.bandwidthBalance = int.MaxValue - DailyQuests.Reward(finalKind).Bandwidth - DailyQuests.CompletionBonusBandwidth + 1;
int bandwidth = data.bandwidthBalance;
int entropy = data.entropyBalance;
int commits = data.commitsBalance;
Assert.That(DailyQuests.Claim(data, finalKind, period, Start), Is.False);
Assert.That(data.bandwidthBalance, Is.EqualTo(bandwidth));
Assert.That(data.entropyBalance, Is.EqualTo(entropy));
Assert.That(data.commitsBalance, Is.EqualTo(commits));
Assert.That(DailyQuests.Claimed(data.dailyQuests, finalKind), Is.False);
Assert.That(DailyQuests.CompletionBonusClaimed(data.dailyQuests), Is.False);
}
[Test]
@@ -312,7 +381,11 @@ public class DailyQuestTests
public void AddedCombatObjectivesCountOnlyTheMatchingGameplay()
{
var data = FixedQuests();
data.dailyQuests.selectedQuests = new[] { DailyQuestKind.BlockDamage, DailyQuestKind.ShieldDamage, DailyQuestKind.NativeCards };
data.dailyQuests.selectedQuests = new[]
{
DailyQuestKind.BlockDamage, DailyQuestKind.ShieldDamage, DailyQuestKind.NativeCards,
DailyQuestKind.SurviveRounds, DailyQuestKind.WaveFive
};
_save.Save(data);
var player = new CombatantState(100, 6, 3);
var enemy = new CombatantState(100, 6, 3);
@@ -327,7 +400,11 @@ public class DailyQuestTests
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 };
data.dailyQuests.selectedQuests = new[]
{
DailyQuestKind.SurviveRounds, DailyQuestKind.WaveFive, DailyQuestKind.Waves,
DailyQuestKind.BlockDamage, DailyQuestKind.ShieldDamage
};
_save.Save(data);
GameEvents.RaisePhaseChanged(new PhaseChangedEvent(TurnPhase.Allocate, TurnPhase.Execute));
GameEvents.RaisePhaseChanged(new PhaseChangedEvent(TurnPhase.EnemyProcess, TurnPhase.GarbageCollection));
@@ -102,6 +102,53 @@ public class GentooProgressionTests
Assert.That(DistroRarity.Stars(Asset<DistroDefinition>("Assets/Data/Distros/Ubuntu.asset")),Is.EqualTo(4));
}
[Test]
public void FeatureBranchHasIndependentPityAndGuaranteesNixOsAfterAnOffBannerDistro()
{
var service=Service();
var standard=service.PerformStandardPull(1,null,PullPaymentSource.Commits);
Assert.That(standard.Success,Is.True);
Assert.That(service.StandardState.totalPulls,Is.EqualTo(1));
Assert.That(service.LimitedState.totalPulls,Is.Zero);
var offBanner=service.PerformLimitedPull(1,null,PullPaymentSource.Commits);
Assert.That(offBanner.Success,Is.True);
Assert.That(offBanner.Rewards.Single().Distro?.Id,Is.Not.EqualTo(GachaService.LimitedFeaturedFiveStarDistroId));
Assert.That(service.LimitedState.featuredFiveStarGuaranteed,Is.True);
Assert.That(service.StandardState.totalPulls,Is.EqualTo(1));
var guaranteed=service.PerformLimitedPull(1,null,PullPaymentSource.Commits);
Assert.That(guaranteed.Rewards.Single().Distro?.Id,Is.EqualTo(GachaService.LimitedFeaturedFiveStarDistroId));
Assert.That(guaranteed.Rewards.Single().Guaranteed,Is.True);
Assert.That(service.LimitedState.featuredFiveStarGuaranteed,Is.False);
}
[Test]
public void PullHistoryIsNewestFirstBoundedAndRoundTripsWithBannerState()
{
var service=Service();
for(int i=0;i<GachaService.MaxPullHistoryEntries+3;i++)
{
var pull=service.PerformLimitedPull(1,null,PullPaymentSource.Commits);
if(!pull.Success)
{
service.AddCurrency(GachaCurrencyType.StandardPull,100);
pull=service.PerformLimitedPull(1,null,PullPaymentSource.Commits);
}
var reward=pull.Rewards[0];
var completed=new CompletedGachaReward(1,reward.StarRating,$"reward-{i}",reward.RewardType,
PullOutcomeKind.Granted,0,null,reward.Guaranteed,reward.PityTriggered);
service.RecordPullHistory(pull,new[]{completed},new DateTime(2026,1,1,0,i%60,0,DateTimeKind.Utc).AddHours(i/60));
}
Assert.That(service.PullHistory.Count,Is.EqualTo(GachaService.MaxPullHistoryEntries));
Assert.That(service.PullHistory[0].rewards[0].displayName,Is.EqualTo("reward-102"));
var save=SaveData.CreateDefault(); service.WriteProgress(save);
var restored=new GachaService(); restored.LoadProgress(save);
Assert.That(restored.PullHistory.Count,Is.EqualTo(GachaService.MaxPullHistoryEntries));
Assert.That(restored.PullHistory[0].bannerId,Is.EqualTo(GachaService.LimitedBannerId));
Assert.That(restored.LimitedState.totalPulls,Is.EqualTo(service.LimitedState.totalPulls));
}
[Test]
public void BeginnerGuaranteedFifthTenPullRemainsFiveStarDistribution()
{
@@ -479,6 +479,7 @@ public class MenuPersistenceTests
var saved = _save.Load();
Assert.That(saved.entropyBalance, Is.EqualTo(DailyQuests.Reward(DailyQuestKind.Waves).Entropy));
Assert.That(saved.bandwidthBalance, Is.EqualTo(DailyQuests.Reward(DailyQuestKind.Waves).Bandwidth));
Assert.That(saved.commitsBalance, Is.EqualTo(DailyQuests.CommitReward(DailyQuestKind.Waves)));
Assert.That(DailyQuests.Claimed(saved.dailyQuests, DailyQuestKind.Waves), Is.True);
Assert.That(((EntropyWallet)Get("_wallet")).Balance, Is.EqualTo(saved.entropyBalance));
}
@@ -512,7 +513,7 @@ public class MenuPersistenceTests
Call("LoadMetaState");
for (int frame = 0; frame < 4; frame++) yield return null;
var widget = _root.Q<Button>("DailyQuestWidget");
Assert.That(_root.Q<Label>("DailyQuestCompleted").text, Is.EqualTo("2/3 completed"));
Assert.That(_root.Q<Label>("DailyQuestCompleted").text, Is.EqualTo("2/5 completed"));
Assert.That(_root.Q<Label>("DailyQuestRewardReady").text, Is.EqualTo("2 rewards ready"));
Assert.That(_root.Q<Label>("DailyQuestInspect").text, Is.EqualTo("> claim available rewards"));
var position = widget.worldBound.center;
@@ -527,7 +528,7 @@ public class MenuPersistenceTests
Assert.That(claim.text, Is.EqualTo("> CLAIM REWARD"));
Assert.That(_root.Q<Button>("ClaimDailyQuestCards").text, Is.EqualTo("[ in progress ]"));
Assert.That(_root.Q<Button>("ClaimDailyQuestCards").enabledSelf, Is.False);
Assert.That(_root.Q<Label>("DailyQuestDetailSummary").text, Is.EqualTo("3 tasks / 2 completed"));
Assert.That(_root.Q<Label>("DailyQuestDetailSummary").text, Is.EqualTo("5 tasks / 2 completed"));
Assert.That(_root.Q("DailyQuestFeedback").style.display.value, Is.EqualTo(DisplayStyle.None));
claim.Focus();
using (var tab = NavigationMoveEvent.GetPooled(NavigationMoveEvent.Direction.Next))
@@ -546,7 +547,7 @@ public class MenuPersistenceTests
Assert.That(_root.Q<Label>("DailyQuestClaimed").text, Is.EqualTo("1 claimed"));
var reward = DailyQuests.Reward(DailyQuestKind.Waves);
Assert.That(_root.Q<Label>("DailyQuestFeedback").text,
Is.EqualTo($"[ OK ] Daily task completed.\n[ OK ] +{reward.Bandwidth} Bandwidth, +{reward.Entropy} Entropy deposited."));
Is.EqualTo($"[ OK ] Daily task completed.\n[ OK ] +{reward.Bandwidth} Bandwidth, +{reward.Entropy} Entropy deposited. +1 Commit deposited."));
Assert.That(_root.Q("DailyQuestFeedback").style.display.value, Is.EqualTo(DisplayStyle.Flex));
Assert.That(_root.focusController.focusedElement, Is.SameAs(_root.Q<Button>("CloseDailyQuests")),
"Repeated Enter must not automatically activate the next reward.");
@@ -582,10 +583,10 @@ public class MenuPersistenceTests
Assert.That(_root.Q<Label>("DailyQuestCountdown").text, Does.StartWith("refresh in 00:04:"));
current.dailyQuests.refreshAtUtcTicks = DateTime.UtcNow.AddSeconds(-1).Ticks;
Call("TickDailyQuests");
Assert.That(_root.Q<Label>("DailyQuestCompleted").text, Is.EqualTo("0/3 completed"));
Assert.That(_root.Q<Label>("DailyQuestCompleted").text, Is.EqualTo("0/5 completed"));
Assert.That(_root.Q("DailyQuestRewardReady").style.display.value, Is.EqualTo(DisplayStyle.None));
Assert.That(_root.Q("DailyQuestOverlay"), Is.Not.Null, "Rollover refreshes the open details.");
Assert.That(_root.Q<Label>("DailyQuestDetailSummary").text, Is.EqualTo("3 tasks / 0 completed"));
Assert.That(_root.Q<Label>("DailyQuestDetailSummary").text, Is.EqualTo("5 tasks / 0 completed"));
Assert.That(_root.Q("DailyQuestFeedback").style.display.value, Is.EqualTo(DisplayStyle.None));
Assert.That(_save.Load().bandwidthBalance, Is.EqualTo(DailyQuests.Reward(DailyQuestKind.Waves).Bandwidth));
Call("CloseDailyQuestDetails");
+7 -34
View File
@@ -179,7 +179,7 @@ public class ReadabilityTests
}
Assert.That(settings.Q<Label>(className: "settings-description").resolvedStyle.fontSize,
Is.EqualTo(size == UITextSize.Large ? 17 : 15), context);
foreach (var control in new VisualElement[] { settings.Q<Toggle>("ReducedMotionToggle"), settings.Q<Button>("TextSizeButton"), settings.Q<Button>("DensityButton"), settings.Q<Button>("SoundVolumeButton") })
foreach (var control in new VisualElement[] { settings.Q<Toggle>("ReducedMotionToggle"), settings.Q<Button>("TextSizeButton"), settings.Q<Button>("DensityButton"), settings.Q<SliderInt>("SoundVolumeSlider") })
{
Assert.That(control.focusable, Is.True, context);
control.Focus();
@@ -254,7 +254,7 @@ public class ReadabilityTests
}
[UnityTest]
public IEnumerator LongRuntimeHintsStayOnscreenScrollWithoutTakingFocusAndRefreshRetainedOwners()
public IEnumerator TooltipsNeverCreateAnAutomaticBottomPanel()
{
RequireGraphics();
var window = ScriptableObject.CreateInstance<TerminalFocusTestWindow>();
@@ -269,42 +269,15 @@ public class ReadabilityTests
UIPreferences.TextSize = UITextSize.Large;
Attach(root);
var owner = new Button { text = "Inspect live card" };
var lines = new string[24];
for (int i = 0; i < lines.Length; i++) lines[i] = "Compilation and equipment modify this card.";
owner.tooltip = string.Join("\n", lines);
owner.tooltip = "Compilation and equipment modify this card.";
root.Add(owner);
owner.Focus();
double waitUntil = EditorApplication.timeSinceStartup + 0.7;
double waitUntil = EditorApplication.timeSinceStartup + 0.35;
while (EditorApplication.timeSinceStartup < waitUntil) yield return null;
var hint = root.Q<ScrollView>(className: "runtime-hint");
Assert.That(hint, Is.Not.Null);
Assert.That(hint.resolvedStyle.display, Is.EqualTo(DisplayStyle.Flex));
Assert.That(hint.worldBound.xMin, Is.GreaterThanOrEqualTo(root.worldBound.xMin));
Assert.That(hint.worldBound.xMax, Is.LessThanOrEqualTo(root.worldBound.xMax));
Assert.That(hint.worldBound.yMin, Is.GreaterThanOrEqualTo(root.worldBound.yMin));
Assert.That(hint.worldBound.yMax, Is.LessThanOrEqualTo(root.worldBound.yMax));
Assert.That(hint.verticalScroller.highValue, Is.GreaterThan(0));
Assert.That(hint.focusable, Is.False);
Assert.That(hint.verticalScroller.slider.focusable, Is.False);
using (var pageDown = KeyDownEvent.GetPooled('\0', KeyCode.PageDown, EventModifiers.None)) owner.SendEvent(pageDown);
yield return null;
Assert.That(hint.scrollOffset.y, Is.GreaterThan(0));
Assert.That(root.Q(className: "runtime-hint"), Is.Null);
Assert.That(root.childCount, Is.EqualTo(1));
Assert.That(owner.tooltip, Is.EqualTo("Compilation and equipment modify this card."));
Assert.That(root.focusController.focusedElement, Is.SameAs(owner));
owner.tooltip = "Updated preview: 24 damage; 7 Shield; cost 1 Cycle.";
waitUntil = EditorApplication.timeSinceStartup + 0.3;
while (EditorApplication.timeSinceStartup < waitUntil) yield return null;
Assert.That(hint.Q<Label>("RuntimeHintText").text, Is.EqualTo(owner.tooltip));
Assert.That(hint.resolvedStyle.display, Is.EqualTo(DisplayStyle.Flex));
root.Clear();
var replacement = new Button { text = "Inspect another card", tooltip = "Current package readiness" };
root.Add(replacement);
replacement.Focus();
waitUntil = EditorApplication.timeSinceStartup + 0.7;
while (EditorApplication.timeSinceStartup < waitUntil) yield return null;
Assert.That(root.Q<ScrollView>(className: "runtime-hint"), Is.SameAs(hint));
Assert.That(hint.Q<Label>("RuntimeHintText").text, Is.EqualTo(replacement.tooltip));
LogAssert.NoUnexpectedReceived();
}
finally { window.Close(); }
@@ -57,6 +57,7 @@ public class RewardSettlementTests
Directory.CreateDirectory(_save.BackupPath);
Set(_run, "_accruedBandwidth", 7);
Set(_run, "_accruedEntropy", 3);
Set(_run, "_accruedCommits", 2);
Set(_run, "currentWaveNumber", 4);
Settle();
@@ -72,6 +73,7 @@ public class RewardSettlementTests
SaveData settled = _save.Load();
Assert.That(settled.bandwidthBalance, Is.EqualTo(27));
Assert.That(settled.entropyBalance, Is.EqualTo(12));
Assert.That(settled.commitsBalance, Is.EqualTo(2));
Assert.That(settled.GetBestWave("gentoo"), Is.EqualTo(4));
string once = File.ReadAllText(_save.SavePath);
@@ -79,6 +81,7 @@ public class RewardSettlementTests
Assert.That(File.ReadAllText(_save.SavePath), Is.EqualTo(once));
Assert.That(_save.Load().bandwidthBalance, Is.EqualTo(27));
Assert.That(_save.Load().entropyBalance, Is.EqualTo(12));
Assert.That(_save.Load().commitsBalance, Is.EqualTo(2));
}
[Test]
@@ -82,6 +82,7 @@ public class RunCheckpointTests
Set(_run, "_wavesCleared", 2);
Set(_run, "_accruedBandwidth", 9);
Set(_run, "_accruedEntropy", 2);
Set(_run, "_accruedCommits", 3);
_run.AddBits(1000);
_run.GenerateRepositoryOffers(_cards, _languages);
RandomRoll.Seed(config.RunSeed);
@@ -148,6 +149,7 @@ public class RunCheckpointTests
Assert.That(_run.WavesCleared, Is.EqualTo(2));
Assert.That(_run.Bits, Is.EqualTo(1000));
Assert.That(_run.AccruedBandwidth, Is.EqualTo(9));
Assert.That(_run.AccruedCommits, Is.EqualTo(3));
Assert.That(_run.RepositoryVisitActive, Is.True);
Assert.That(_run.IsSuspended, Is.False);
}
+67 -2
View File
@@ -178,6 +178,40 @@ public class TerminalUiTests
}
}
[Test]
public void PullHistoryIsAToolbarModalAndNotABanner()
{
var root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/MainMenu.uxml").CloneTree();
var screen = new GachaScreenController();
screen.Bind(root, null, null, null, new GachaService(), new PlayerCollection(), new EntropyWallet(),
null, null, () => { }, () => { }, null);
screen.Open();
var bannerList = root.Q("GachaBannerList");
var branches = bannerList.Query<Button>(className: "gacha-banner-row").ToList();
Assert.That(branches.Count, Is.EqualTo(3));
Assert.That(bannerList.Q<Label>(className: "gacha-branch-command").text, Is.EqualTo("$ git branch --list"));
Assert.That(branches[0].Q<Label>(className: "command-cursor").text, Is.EqualTo("*"));
Assert.That(branches[0].Q<Label>(className: "command-text").text, Is.EqualTo("beginner"));
Assert.That(branches[1].Q<Label>(className: "command-text").text, Is.EqualTo("stable"));
Assert.That(branches[2].Q<Label>(className: "command-text").text, Is.EqualTo("feature/nixos"));
Assert.That(bannerList.Q("GachaPullHistoryButton"), Is.Null);
Assert.That(root.Q<Button>("GachaPullHistoryButton"), Is.Not.Null);
Assert.That(root.Q("GachaBannerDetail").Query<Label>(className: "gacha-detail-title").ToList(), Is.Empty,
"The selected branch already identifies the banner; the detail pane should not repeat its title.");
screen.OpenPullHistory();
var overlay = root.Q("GachaPullHistoryOverlay");
Assert.That(overlay, Is.Not.Null);
Assert.That(overlay.ClassListContains("modal-open"), Is.True);
Assert.That(overlay.ClassListContains("hidden"), Is.False);
Assert.That(overlay.Q<Label>(className: "gacha-detail-title").text, Is.EqualTo("[ git log --pulls ]"));
Assert.That(overlay.Q<Label>(className: "gacha-history-empty").text, Does.StartWith("fatal: no committed pulls found"));
Assert.That(overlay.Q<Button>("ClosePullHistory"), Is.Not.Null);
Assert.That(bannerList.Query<Button>(className: "selected").ToList().Count, Is.EqualTo(1),
"Opening history must not replace the selected banner.");
}
[Test]
public void UnitIdentityAndTabsSurviveAllFourDetailViews()
{
@@ -206,6 +240,31 @@ public class TerminalUiTests
Assert.That(root.Q("CollectionContextHeader").ClassListContains("hidden"), Is.True);
}
[Test]
public void UnitOverviewListsEquippedPackageLoadout()
{
var root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/MainMenu.uxml").CloneTree();
var unit = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Ubuntu.asset");
var package = AssetDatabase.LoadAssetAtPath<PackageDefinition>("Assets/Data/Packages/AptFast.asset");
var database = AssetDatabase.LoadAssetAtPath<PackageDatabase>("Assets/Data/Packages/PackageDatabase.asset");
var owned = new PlayerCollection();
owned.Add(unit);
owned.AddPackage(package);
var loadout = new PackageLoadout(owned, database);
Assert.That(loadout.TryEquip(unit.Id, package.Slot, package.Id, out _), Is.True);
var screen = new CollectionScreenController();
screen.Bind(root, null, null, null, owned, packageDatabase: database, packageLoadout: loadout);
screen.RefreshUnits(owned.OwnedUnits);
var row = root.Q<Button>(className: "unit-overview-row");
var packages = row.Q<Label>(className: "unit-loadout-line");
Assert.That(packages, Is.Not.Null);
Assert.That(packages.text, Does.Contain(package.DisplayName));
Assert.That(packages.text, Does.Contain("system=").And.Contain("tools=").And.Contain("services="));
Assert.That(row.tooltip, Does.Contain(package.DisplayName));
}
[Test]
public void InventoryRowsUseCompactMetadataAndKeepEffectsInDetails()
{
@@ -338,7 +397,7 @@ public class TerminalUiTests
var commands = (string[])type.GetField("Commands", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
Assert.That(commands, Is.EqualTo(new[]
{
"./start_run", "ls ~/collection", "curl gacha.sh | sh", "dpkg-reconfigure", "history --runs", "shutdown -h now", "cat /etc/cron.daily/quests"
"./start_run", "ls ~/collection", "curl gacha.sh | sh", "dpkg-reconfigure", "history --runs", "shutdown -h now", "cat /etc/cron.daily/quests", "git log --pulls"
}));
for (int i = 0; i < commands.Length; i++)
{
@@ -349,13 +408,14 @@ public class TerminalUiTests
}
input.value = "./start_run; shutdown";
type.GetMethod("Submit", Private).Invoke(line, null);
Assert.That(activated, Is.EqualTo(6));
Assert.That(activated, Is.EqualTo(7));
Assert.That(root.Q<Label>("CommandOutput").text, Does.Contain("command not found"));
}
[TestCase("his", "history --runs", 4)]
[TestCase("shut", "shutdown -h now", 5)]
[TestCase("cat /etc/cron", "cat /etc/cron.daily/quests", 6)]
[TestCase("git log", "git log --pulls", 7)]
public void ArchiveAndQuitCommandsCompleteAndKeepTheirOwnActionIndices(string prefix, string command, int index)
{
var root = new VisualElement();
@@ -494,7 +554,12 @@ public class TerminalUiTests
Assert.That(root.Q(id), Is.Not.Null, id);
Assert.That(root.Q<TextField>("CommandInput"), Is.Not.Null);
Assert.That(root.Q<Toggle>("ReducedMotionToggle"), Is.Not.Null);
Assert.That(root.Q<SliderInt>("SoundVolumeSlider"), Is.Not.Null);
Assert.That(root.Q<Button>("SoundVolumeButton"), Is.Null);
Assert.That(AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Resources/KernelTheme.uss"), Is.Not.Null);
Assert.That(AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Resources/TerminalProgram.uss"), Is.Not.Null);
Assert.That(AssetDatabase.LoadAssetAtPath<Font>("Assets/Resources/Fonts/JetBrainsMono-Regular.ttf"), Is.Not.Null,
"The terminal must ship one deterministic monospace font instead of depending on the host OS.");
}
}