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
+151
View File
@@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.Linq;
using KernelPanic.Combat;
using KernelPanic.Core;
namespace KernelPanic.Run
{
public enum TutorialAction { Read, SelectCard, TargetEnemy, EndTurn, PlayShield, Free }
public sealed class TutorialStep
{
public readonly string Id, Title, Copy, Anchor;
public readonly TutorialAction Action;
public TutorialStep(string id, string title, string copy, string anchor, TutorialAction action = TutorialAction.Read)
{ Id = id; Title = title; Copy = copy; Anchor = anchor; Action = action; }
}
/// <summary>Advances from observed combat state, never from fabricated damage or a Next button on action steps.</summary>
public sealed class TutorialGuide
{
private readonly int _lesson;
private readonly IReadOnlyList<TutorialStep> _steps;
private bool _played, _resolved, _ended;
public int Index { get; private set; }
public int Count => _steps.Count;
public TutorialStep Step => Active ? _steps[Index] : null;
public bool Active => Index < _steps.Count;
public bool Reading => Active && Step.Action == TutorialAction.Read;
public CardInstance Card { get; private set; }
public EnemyInstance Enemy { get; private set; }
public bool CanEndTurn => !Active || Step.Action == TutorialAction.EndTurn;
private ResolutionTrack ExpectedTrack => _lesson == 1 ? ResolutionTrack.Native
: Step?.Id.Contains("haskell") == true ? ResolutionTrack.LazyStack : ResolutionTrack.InterpreterQueue;
public TutorialGuide(int lesson) { _lesson = lesson; _steps = Build(lesson); }
public bool AllowsCard(CardInstance card) => !Active || !Reading && ReferenceEquals(card, Card)
&& Step.Action is TutorialAction.SelectCard or TutorialAction.TargetEnemy or TutorialAction.PlayShield;
public bool AllowsEnemy(EnemyInstance enemy) => !Active || Step.Action == TutorialAction.TargetEnemy && ReferenceEquals(enemy, Enemy);
public void Acknowledge(CombatManager combat)
{
if (!Reading || !combat.TutorialInputReady) return;
Advance(combat);
}
public void CardPlayed(ResolutionTrack track)
{ if (Active && !Reading && track == ExpectedTrack) _played = true; }
public void CardResolved(ResolutionTrack track)
{ if (Active && !Reading && track == ExpectedTrack) _resolved = true; }
public void PhaseChanged(TurnPhase phase) { if (Active && Step.Action == TutorialAction.EndTurn && phase == TurnPhase.Interpret) _ended = true; }
public void Update(CombatManager combat)
{
if (!Active || combat.PlayerState == null) return;
PickReferences(combat);
switch (Step.Action)
{
case TutorialAction.SelectCard:
if (Card != null && combat.PendingTargetCard == Card) Advance(combat);
else if (_played && (Queued(combat) || _resolved))
{ Advance(combat); if (Step?.Action == TutorialAction.TargetEnemy) Advance(combat); }
break;
case TutorialAction.TargetEnemy:
if (_lesson == 1)
{
if (Step.Id == "target-zombie" && Enemy?.PendingRevive == true) Advance(combat);
else if (Step.Id == "finish-zombie" && Enemy?.HasRevived == true && Enemy.State.IsDefeated) Advance(combat);
}
else if (_played && (Queued(combat) || _resolved)) Advance(combat);
break;
case TutorialAction.PlayShield:
if (_resolved && Card != null && !combat.HandController.Cards.Contains(Card)) Advance(combat);
break;
case TutorialAction.EndTurn:
if (_ended && combat.TutorialInputReady
&& (_lesson != 1 || Enemy?.HasRevived == true)) Advance(combat);
break;
}
combat.TutorialReading = Reading;
}
private bool Queued(CombatManager combat) => Card != null && (combat.InterpreterQueue.Cards.Contains(Card)
|| combat.LazyStack.Entries.Any(entry => entry.Card == Card));
private void Advance(CombatManager combat)
{
Index++;
if (Active && Step.Action is TutorialAction.SelectCard or TutorialAction.PlayShield)
{
Card = null; _played = _resolved = false;
combat.ClearTutorialSelection();
}
if (Active && Step.Action == TutorialAction.EndTurn) _ended = false;
PickReferences(combat);
combat.TutorialReading = Reading;
}
private void PickReferences(CombatManager combat)
{
if (!Active) return;
if (Enemy == null)
Enemy = combat.Enemies.FirstOrDefault(enemy => _lesson != 1 || enemy.ArchetypeId == "zombie_process");
if (Card != null || combat.HandController == null) return;
string id = _lesson == 1 ? Step.Id is "shield-card" or "shield-result" ? "lang_rs_borrow"
: Index >= 13 ? "lang_rs_fn_main" : "lang_rs_unwrap" : null;
Card = combat.HandController.Cards.FirstOrDefault(card => !card.IsBroken && !card.IsLocked
&& (id != null ? card.Definition.Id == id : card.Definition.ResolutionTrack == ExpectedTrack)
&& combat.GetDisplayedPlayCost(card) <= combat.PlayerState.Cycles);
}
public static IReadOnlyList<TutorialStep> Build(int lesson)
{
if (lesson == 1) return new[] {
new TutorialStep("uptime", "This is your Uptime", "Uptime is your health. At 0, a normal run ends. This practice uses loan cards, full health and no distro passive procs; your collection is safe.", "TutorialUptime"),
new TutorialStep("shield", "Shield protects Uptime", "Shield absorbs ordinary incoming damage first. This number shows how much protection you currently have.", "TutorialShield"),
new TutorialStep("cycles", "Cycles pay for cards", "This is your remaining card budget. The cost in a card's upper-right corner is paid when you play it. Cycles refresh each round.", "TutorialCycles"),
new TutorialStep("ram", "RAM is hand capacity", "This shows used RAM / capacity. Most cards use 1 RAM; Java uses 2. More Cycles do not let extra cards fit in a full hand.", "TutorialRam"),
new TutorialStep("attack-card", "Read your attack card", "unwrap() costs Cycles and deals damage immediately: it is Native. Its rules and current estimate are printed here. Rust overkill can also grant Shield.", "card"),
new TutorialStep("intent", "Read the enemy's intent", "This is what Zombie Process plans to do when enemies act. Check the attack range before ending your turn.", "zombie-intent"),
new TutorialStep("select-attack", "1 / Select the attack", "Click the highlighted unwrap() card first. Selecting a targeted card asks for an enemy; it does not spend Cycles yet.", "card", TutorialAction.SelectCard),
new TutorialStep("target-zombie", "2 / Choose the zombie", "Now click Zombie Process to dispatch your selected card. Other targets and End turn are locked for this demonstration.", "zombie", TutorialAction.TargetEnemy),
new TutorialStep("pending-revival", "Zero Uptime, but not gone", "Your attack reduced the zombie to 0. RESTART PENDING means it will revive next round. A fresh zombie can do this once; finishing it from 30% Uptime or less reaps it instead.", "zombie"),
new TutorialStep("end-turn", "3 / End your turn", "Click End turn (or press E). The remaining enemy acts, then the next round begins and the zombie revives. Watch its Uptime.", "TutorialEndTurn", TutorialAction.EndTurn),
new TutorialStep("revived", "The zombie has respawned", "It has returned at half Uptime. RESTART USED means it cannot revive again. Your Cycles also refreshed for this round.", "zombie"),
new TutorialStep("shield-card", "4 / Add protection", "Click borrow() to gain Shield now. It needs no enemy target. Any Shield you already have from Rust overkill is kept.", "card", TutorialAction.PlayShield),
new TutorialStep("shield-result", "Your Shield increased", "That card added protection to this number. Shield is not healing: it absorbs damage before your Uptime is reduced.", "TutorialShield"),
new TutorialStep("select-finisher", "5 / Select a finisher", "Select the highlighted fn main() card. Then you will choose the revived zombie as its target.", "card", TutorialAction.SelectCard),
new TutorialStep("finish-zombie", "6 / Finish the revived zombie", "Click the zombie again. Its revival is already spent, so this attack can terminate it permanently.", "zombie", TutorialAction.TargetEnemy),
new TutorialStep("piles", "Track your cards", "Played cards go to discard; an empty draw pile reshuffles discard. Exhausted cards stay out for this wave. These counters open pile inspectors.", "TutorialPiles"),
new TutorialStep("practice", "Finish the encounter", "You have practiced targeting, revival and Shield. Clear the remaining orphan processes on your own. Use card → enemy, and End turn when needed. A zombie can leave an orphan when permanently defeated.", "enemies")
};
return new[] {
new TutorialStep("leak", "A new threat: Memory Leak", "This enemy grows stronger each round and applies damage-over-time stacks. Your health and purchased upgrade carried over from wave one.", "enemy:memory_leak"),
new TutorialStep("firewall", "A protector: firewalld", "firewalld shields itself and adjacent processes. Read its intent before choosing which enemy to remove first.", "enemy:firewalld"),
new TutorialStep("queue-intro", "Python uses the queue", "Python waits until End turn. Its cards resolve oldest first (FIFO). Let's put a real card into this queue.", "TutorialQueue"),
new TutorialStep("select-python", "Select the Python card", "Click the highlighted Python card. print() chooses its target when it resolves, so it does not ask you to click an enemy.", "card", TutorialAction.SelectCard),
new TutorialStep("target-python", "Select a target", "Click the highlighted enemy to complete this play.", "enemy", TutorialAction.TargetEnemy),
new TutorialStep("queued-python", "Python is waiting here", "Your card is now queued, not resolved. With multiple entries, the oldest would execute first.", "TutorialQueue"),
new TutorialStep("stack-intro", "Haskell uses the stack", "Haskell waits until after Python and resolves newest first (LIFO). Each entry captures a multiplier for damage and explicit Shield.", "TutorialStack"),
new TutorialStep("select-haskell", "Select the Haskell card", "Click the highlighted thunk() card, then select the highlighted enemy.", "card", TutorialAction.SelectCard),
new TutorialStep("target-haskell", "Choose its target", "Click this enemy. The attack will wait on the stack rather than dealing damage immediately.", "enemy", TutorialAction.TargetEnemy),
new TutorialStep("queued-haskell", "Both tracks are ready", "Python will resolve first, then Haskell, then surviving enemies. A defeated target can cause deferred damage to retarget.", "TutorialStack"),
new TutorialStep("end-round", "Run the queued actions", "Click End turn (or press E). Watch the queue resolve before the stack. We will continue when the exchange finishes.", "TutorialEndTurn", TutorialAction.EndTurn),
new TutorialStep("resolved", "The waiting cards resolved", "The scheduler has executed the deferred cards. Check enemy Uptime, Shield and intents before choosing your next move.", "enemies"),
new TutorialStep("practice", "Clear wave two", "Finish every remaining enemy on your own. Clearing this wave completes training and unlocks 1,000 Bandwidth plus 1,000 Entropy: enough for a standard 10-pull.", "enemies")
};
}
}
}