89 lines
5.0 KiB
C#
89 lines
5.0 KiB
C#
using System;
|
|
using System.Linq;
|
|
using KernelPanic.Combat;
|
|
using KernelPanic.Run;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace KernelPanic.UI
|
|
{
|
|
/// <summary>Repository decisions; all rewards and transitions remain in the run/combat model.</summary>
|
|
internal static class RunRouteView
|
|
{
|
|
public static VisualElement Build(RunManager run, CombatManager combat)
|
|
{
|
|
var section = TerminalLayout.Section(run.CampaignChoicePending ? "KERNEL SECURED" : "Route", "RunRouteChoices");
|
|
section.AddToClassList("run-route-section");
|
|
if (!string.IsNullOrEmpty(run.Journey.lastReward)) section.Add(TerminalLayout.BodyText(run.Journey.lastReward));
|
|
if (run.BuildRewardPending)
|
|
{
|
|
section.Add(TerminalLayout.BodyText("Build reward / choose one before departure. Upgrade a card for this run, or take Bits to spend freely."));
|
|
var cards = run.RunDeck.Where(card => card.Definition != null && !card.Definition.IsToken && !card.Definition.IsJunk).ToList();
|
|
if (cards.Count > 0)
|
|
{
|
|
int selected = 0;
|
|
var target = TerminalLayout.BodyText("", "BuildRewardTarget");
|
|
section.Add(target);
|
|
var navigation = new VisualElement();
|
|
navigation.AddToClassList("reward-target-navigation");
|
|
section.Add(navigation);
|
|
section.Add(Action($"Upgrade effect +{CombatTuning.UpgradeMagnitudeBonus}", "RewardMagnitude",
|
|
() => run.ClaimBuildReward(cards[selected], CardUpgradeKind.MagnitudeUp)));
|
|
var draw = Action("Add draw 1 on resolution", "RewardDraw",
|
|
() => run.ClaimBuildReward(cards[selected], CardUpgradeKind.DrawRider));
|
|
void Select(int offset)
|
|
{
|
|
selected = (selected + offset + cards.Count) % cards.Count;
|
|
var card = cards[selected];
|
|
target.text = $"Target {selected + 1}/{cards.Count}: {card.Definition.DisplayName}\n+{card.MagnitudeBonus} effect / +{card.DrawRider} draw";
|
|
draw.SetEnabled(card.DrawRider == 0);
|
|
}
|
|
navigation.Add(Action("Previous card", "RewardPrevious", () => Select(-1)));
|
|
navigation.Add(Action("Next card", "RewardNext", () => Select(1)));
|
|
Select(0);
|
|
section.Add(draw);
|
|
}
|
|
section.Add(Action($"Take {RunManager.BuildRewardBits} Bits", "RewardBits",
|
|
() => run.ClaimBuildReward(null, CardUpgradeKind.MagnitudeUp, true)));
|
|
}
|
|
if (run.CampaignChoicePending)
|
|
{
|
|
section.Add(TerminalLayout.BodyText("Five waves cleared. Finish this campaign and bank your rewards, or keep this build running in endless mode. Rewards are saved when the run ends."));
|
|
section.Add(Action("Finish campaign", "FinishCampaignButton", () => combat.CompleteCampaign()));
|
|
section.Add(Action("Continue into endless", "ContinueEndlessButton", () => combat.ContinueEndless()));
|
|
return section;
|
|
}
|
|
var plan = EncounterDirector.Plan(run.CurrentWaveNumber, run.Journey.selectedRoute,
|
|
run.CurrentConfig.RunSeed, run.Journey.encounterRevision);
|
|
var choices = new VisualElement();
|
|
choices.AddToClassList("route-choices");
|
|
AddChoice(choices, run, WaveRoute.Repair, "Repair stop",
|
|
$"Restore up to {RunJourney.RepairUptime} Uptime on departure. Fight the standard encounter.");
|
|
AddChoice(choices, run, WaveRoute.Challenge, "Elite detour",
|
|
$"Extra Daemon. On clear: +{RunJourney.ChallengeBits} Bits and +1 draw on the first card without a draw rider (or +{RunJourney.ChallengeBits} Bits if none)."
|
|
+ (run.Journey.selectedRoute == WaveRoute.Challenge
|
|
? $"\nElite: {(plan.EscortShield > 0 ? $"+{plan.EscortShield} Shield" : plan.EscortUptime > 0 ? $"+{plan.EscortUptime} Uptime" : "hidden intent")}." : ""));
|
|
section.Add(choices);
|
|
return section;
|
|
}
|
|
|
|
private static void AddChoice(VisualElement parent, RunManager run, WaveRoute route, string title, string detail)
|
|
{
|
|
var card = new VisualElement();
|
|
card.AddToClassList("route-choice");
|
|
bool selected = run.Journey.selectedRoute == route;
|
|
card.EnableInClassList("route-selected", selected);
|
|
card.Add(Action((selected ? "[selected] " : "") + title, "Route" + route,
|
|
() => run.SelectRoute(route)));
|
|
card.Add(TerminalLayout.BodyText(detail));
|
|
parent.Add(card);
|
|
}
|
|
|
|
private static Button Action(string title, string name, Action action)
|
|
{
|
|
var button = new Button(action) { text = title, name = name };
|
|
button.AddToClassList("primary-action");
|
|
return button;
|
|
}
|
|
}
|
|
}
|