add missing files

This commit is contained in:
2026-10-24 00:54:13 +02:00
parent ec3e784683
commit ce564c10a3
237 changed files with 5733 additions and 0 deletions
+148
View File
@@ -0,0 +1,148 @@
using System;
using KernelPanic.Core;
using KernelPanic.Run;
using UnityEngine;
using UnityEngine.UIElements;
namespace KernelPanic.UI
{
/// <summary>Observes a real battle; never changes cards, targeting or turn timing.</summary>
public sealed class FirstBattleGuide
{
private const string PreferenceKey = "KernelPanic.FirstBattleGuide.v1";
private readonly Action _remember;
private readonly Label _title = new();
private readonly Label _instruction = new();
private readonly Label _receipt = new();
private readonly Button _action;
private readonly Button _skip;
private RunConfig _config;
private bool _played;
private bool _endedTurn;
private bool _completed;
private bool _started;
public VisualElement Element { get; } = new() { name = "FirstBattleGuide" };
public bool Visible => Element.style.display.value != DisplayStyle.None;
public string Instruction => _instruction.text;
public FirstBattleGuide(Action remember = null)
{
_remember = remember ?? Remember;
Element.AddToClassList("first-battle-guide");
_title.AddToClassList("guide-title");
_instruction.AddToClassList("guide-copy");
_receipt.AddToClassList("guide-copy");
var header = new VisualElement();
header.AddToClassList("guide-header");
header.Add(_title);
Element.Add(header);
Element.Add(_instruction);
Element.Add(_receipt);
var actions = new VisualElement();
actions.AddToClassList("guide-actions");
_action = new Button(Advance) { text = "Ready: play a card" };
_skip = new Button(Dismiss) { text = "Skip guide" };
actions.Add(_action);
actions.Add(_skip);
header.Add(actions);
Element.style.display = DisplayStyle.None;
}
public void Begin(RunConfig config, bool replay = false)
{
_config = config;
if (!replay && PlayerPrefs.GetInt(PreferenceKey, 0) != 0) return;
_played = _endedTurn = _completed = _started = false;
_receipt.text = "";
Element.style.display = DisplayStyle.Flex;
_action.style.display = DisplayStyle.Flex;
_skip.style.display = DisplayStyle.Flex;
_action.text = "Ready: play a card";
_title.text = "First battle / 1 of 4 / read the process table";
_instruction.text = "Uptime = health; Cycles = card budget; RAM = hand capacity. Read enemy intents, then select a card and its target. " + TrackLesson(config);
}
public void Advance()
{
if (!Visible) return;
if (_completed) { Dismiss(); return; }
_started = true;
_action.style.display = DisplayStyle.None;
_title.text = "First battle / 2 of 4 / dispatch a card";
_instruction.text = "Play any affordable card. Targeted cards need a living process selected. The preview explains its current effect. " + TrackLesson(_config);
}
public void CardPlayed(ResolutionTrack track, string name)
{
if (!Visible || _completed) return;
_played = _started = true;
_action.style.display = DisplayStyle.None;
_title.text = "First battle / 3 of 4 / finish your turn";
_receipt.text = track switch
{
ResolutionTrack.InterpreterQueue => name + " entered the queue. It waits until end turn; the oldest queued card resolves first.",
ResolutionTrack.LazyStack => name + " entered the stack. It waits until after the queue; the newest stacked card resolves first.",
_ => name + " executes immediately on the Native track."
};
_instruction.text = "Play more cards if you have Cycles, then choose [E] end turn. Watch the scheduler: queue first, stack second, then enemies act. Shield helps absorb incoming damage.";
}
public void CardResolved(string name, ResolutionTrack track)
{
if (!Visible || _completed) return;
_receipt.text = name + " resolved" + (track == ResolutionTrack.Native ? " immediately." : track == ResolutionTrack.InterpreterQueue ? " from the front of the queue." : " from the top of the stack.");
}
public void PhaseChanged(TurnPhase phase)
{
if (!Visible || _completed) return;
if (phase == TurnPhase.Interpret)
{
_endedTurn = true;
_instruction.text = "Resolving: queued cards execute oldest first, then stacked cards execute newest first. Enemy actions follow. You can inspect the journal for the result of each operation.";
}
if (phase == TurnPhase.Execute && _endedTurn) Complete(false);
}
public void Refresh(bool waveCleared, bool runLost)
{
if (!Visible || _completed) return;
if (waveCleared || runLost) Complete(waveCleared);
}
private void Complete(bool waveCleared)
{
_completed = true;
_title.text = "First battle / 4 of 4 / plan the next round";
_instruction.text = waveCleared
? "Wave cleared! Spend Bits in the repository on cards, upgrades or healing, then continue. Cleared waves earn rewards that are banked when the run ends."
: "Check Uptime, Shield and the next enemy intents before your next move. Each completed round refreshes your turn resources. " + (_config?.Distro?.Id == "gentoo" ? "Gentoo's Compilation advances after a completed round, improving damage (and Shield at higher versions), and resets each wave. " : "") + "You can reopen this with '? guide' in dispatch.";
if (!_played && _started) _receipt.text = "You can also end a turn without playing a card; the same execution order applies.";
_action.text = "Got it";
_action.style.display = DisplayStyle.Flex;
_skip.style.display = DisplayStyle.None;
}
public void Dismiss()
{
Element.style.display = DisplayStyle.None;
_remember();
}
public static string TrackLesson(RunConfig config)
{
string lesson = "Native cards execute now.";
if (config?.PrimaryLanguage == Language.Python || config?.SecondaryLanguage == Language.Python)
lesson += " Your Python cards queue until end turn (first in, first out).";
if (config?.PrimaryLanguage == Language.Haskell || config?.SecondaryLanguage == Language.Haskell)
lesson += " Your Haskell cards stack until end turn (last in, first out); the multiplier shown on entry scales damage and explicit Shield.";
return lesson;
}
private static void Remember()
{
PlayerPrefs.SetInt(PreferenceKey, 1);
PlayerPrefs.Save();
}
}
}