add C++, Typescript and more stuff
This commit is contained in:
@@ -11,7 +11,7 @@ namespace KernelPanic.Run
|
||||
public static class LanguageTraining
|
||||
{
|
||||
public static readonly IReadOnlyList<Language> Supported = Array.AsReadOnly(new[]
|
||||
{ Language.C, Language.Rust, Language.Python, Language.JavaScript, Language.Haskell, Language.Java, Language.Go });
|
||||
{ Language.C, Language.CPlusPlus, Language.Rust, Language.Python, Language.JavaScript, Language.TypeScript, Language.Haskell, Language.Java, Language.Go });
|
||||
|
||||
public static bool IsSupported(Language language) => Supported.Contains(language);
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace KernelPanic.Run
|
||||
Language.Python => new[] { "lang_py_import_antigravity", "shop_py_async_def", "lang_py_for_loop", "mint_cinnamon", "lang_py_print", "lang_py_print" },
|
||||
Language.Haskell => new[] { "lang_hs_map", "lang_hs_thunk", "lang_hs_foldr" },
|
||||
Language.C => new[] { "lang_c_malloc", "lang_c_pointer", "lang_c_printf" },
|
||||
Language.CPlusPlus => new[] { "lang_cpp_malloc", "lang_cpp_pointer", "lang_cpp_printf" },
|
||||
Language.TypeScript => new[] { "lang_ts_console_log", "lang_ts_fetch", "lang_ts_typeof" },
|
||||
Language.Rust => new[] { "lang_rs_fn_main", "lang_rs_unwrap", "lang_rs_borrow" },
|
||||
Language.JavaScript => new[] { "lang_js_console_log", "lang_js_fetch", "lang_js_typeof" },
|
||||
Language.Java => new[] { "lang_java_new_object", "lang_java_system_out_println", "lang_java_public_static_main" },
|
||||
@@ -56,6 +58,8 @@ namespace KernelPanic.Run
|
||||
string name = LanguageCatalog.Get(language).DisplayName;
|
||||
string objective = language switch
|
||||
{
|
||||
Language.CPlusPlus => "Learn C's evolved cards: stronger hits, full overkill spill and combos without segfault recoil.",
|
||||
Language.TypeScript => "Learn to plan reliable attacks using JavaScript's evolved cards, with fixed damage and no failed typeof rolls.",
|
||||
Language.Python => "You'll learn to build a combo that attacks this turn and repeats on later turns. First, we'll draw the cards we need. Then we'll put them in order.",
|
||||
Language.Haskell => "You'll learn to make a stronger attack by playing your cards in the right order. We'll build a stack together, then work through why it resolves backward.",
|
||||
Language.Rust => "You'll learn to turn an attack into protection. We'll defeat the weaker enemy first, use the leftover damage as Shield, then attack the stronger one.",
|
||||
@@ -68,6 +72,16 @@ namespace KernelPanic.Run
|
||||
Read("welcome", "Learn to use " + name, objective, "enemies");
|
||||
switch (language)
|
||||
{
|
||||
case Language.CPlusPlus:
|
||||
Read("evolution", "C without the segfault", "C++ keeps C's immediate attacks and elevated critical chance. Damage is stronger, all overkill spills, and playing C++ never causes segfault recoil.", "enemies");
|
||||
Play("burst", "lang_cpp_malloc", "Start with upgraded malloc", "Play malloc to begin your C++ chain. Your hand stays safe from segfault corruption.");
|
||||
Read("combo", "Follow with pointer", "Pointer deals 20 base damage after a C++ card instead of 12. Use printf to repair corruption from other sources. Full excess damage spills to the next living enemy.", "enemies");
|
||||
break;
|
||||
case Language.TypeScript:
|
||||
Read("evolution", "Plan around fixed values", "TypeScript upgrades JavaScript's cards. Damage has a fixed value and no critical roll. Buffs and enemy defenses still apply.", "enemies");
|
||||
Play("fixed", "lang_ts_console_log", "Deal a reliable 9", "Play console.log(). Its base damage is always 9 instead of a random 3 to 9.");
|
||||
Read("guarantee", "No failed typeof", "Fetch deals 13 base damage. Typeof always deals 16 instead of risking a failed roll. Check enemy defenses, then choose your follow-up.", "enemies");
|
||||
break;
|
||||
case Language.Go:
|
||||
Read("go-slots", "Start a worker for future turns", "Go has 3 active slots, separate from hand RAM. A deployed worker leaves your hand and starts attacking next round. Its card returns to the discard pile when it stops.", "GoroutineScheduler");
|
||||
Play("go-worker", "lang_go_worker", "Deploy your first worker", "Select go worker(). It will deal 3 base damage on each of its next 3 eligible rounds. Its first tick is next round, so you still need to plan for this turn's enemies.",
|
||||
@@ -149,6 +163,8 @@ namespace KernelPanic.Run
|
||||
}
|
||||
string practice = language switch
|
||||
{
|
||||
Language.CPlusPlus => "Finish the fight. Chain C++ cards for pointer's bonus, use full overkill spill, and repair corruption with printf. Your C++ attacks never cause segfaults.",
|
||||
Language.TypeScript => "Finish the fight. Use fixed damage to plan each kill, accounting for Shield and other modifiers. Typeof always succeeds.",
|
||||
Language.Python => "Finish the fight yourself. Draw before committing to a combo, put setup before payloads, and check your active script. End your turn when the queue is ready.",
|
||||
Language.Haskell => "Finish the fight yourself. Start with a smaller card, save a bigger effect for a higher multiplier, then check the stack from top to bottom before ending your turn.",
|
||||
Language.Rust => "Finish the fight yourself. Compare the enemy's intent with your Shield. Use overkill for protection when you can, and borrow() when you need Shield without a kill.",
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace KernelPanic.Run
|
||||
fixture.starterChosen = true;
|
||||
fixture.tutorialRequired = false;
|
||||
fixture.tutorialRewardClaimed = true;
|
||||
fixture.campaignClearLanguages.AddRange(new[] { Language.C, Language.JavaScript });
|
||||
foreach (string id in new[] { "ubuntu", "arch", "gentoo", "fedora", "nixos" })
|
||||
fixture.ownedUnits.Add(new OwnedUnitSaveEntry { id = id, version = id == "nixos" ? 5 : 1 });
|
||||
new SaveService().Save(fixture);
|
||||
@@ -555,6 +556,7 @@ namespace KernelPanic.Run
|
||||
var flow = Field<TutorialFlow>(view, "_tutorial");
|
||||
Require(combat.RunConfig.TrainingLanguage == language, "Collection launched the wrong lesson.");
|
||||
int actions = 0;
|
||||
bool capturedResolution = false;
|
||||
while (!combat.AwaitingWaveContinue && !combat.RunLost)
|
||||
{
|
||||
if (!combat.TutorialInputReady) { yield return null; continue; }
|
||||
@@ -582,6 +584,21 @@ namespace KernelPanic.Run
|
||||
else if (combat.CanSurrenderRun)
|
||||
{
|
||||
_stage = language + " / free practice";
|
||||
if (!capturedResolution)
|
||||
{
|
||||
capturedResolution = true;
|
||||
var trace = Field<CombatExecutionTrace>(view, "_executionTrace");
|
||||
Require(trace.Actions.Count > 0 && trace.Actions.Any(a => a.Complete), "Practice has no observed resolution results.");
|
||||
var resolution = root.Q<Foldout>("TurnResolution");
|
||||
Require(resolution != null, "Turn-resolution view is missing.");
|
||||
resolution.value = true;
|
||||
var workspace = resolution.GetFirstAncestorOfType<ScrollView>();
|
||||
for (int frame = 0; frame < 4; frame++) yield return null;
|
||||
workspace?.ScrollTo(resolution);
|
||||
for (int frame = 0; frame < 4; frame++) yield return null;
|
||||
var capture = CapturePanel(document, "training-" + language + "-resolution");
|
||||
while (capture.MoveNext()) yield return capture.Current;
|
||||
}
|
||||
if (combat.PendingGoroutineCard != null)
|
||||
{
|
||||
var work = combat.Go.Active.FirstOrDefault(g => combat.IsEligibleGoSelection(g, combat.PendingGoroutineCard));
|
||||
|
||||
@@ -39,11 +39,12 @@ namespace KernelPanic.Run
|
||||
public int shopRandomDraws;
|
||||
public CheckpointCombat combat;
|
||||
public RunJourney journey;
|
||||
public RunPerformanceSnapshot performance;
|
||||
|
||||
public ResolvedRunCheckpoint Resolve(DistroDatabase distros, CardDatabase cards,
|
||||
LanguageDeckDatabase languages, PackageDatabase packageDatabase)
|
||||
{
|
||||
Require(version >= 1 && version <= 4, "This checkpoint needs a different game version.");
|
||||
Require(version >= 1 && version <= 5, "This checkpoint needs a different game version.");
|
||||
Require(version < 2 || journey != null, "Missing saved route decisions.");
|
||||
journey?.Validate(wave);
|
||||
journey?.ValidateMap(seed, wave);
|
||||
@@ -201,6 +202,7 @@ namespace KernelPanic.Run
|
||||
RunCheckpoint snapshot = run.CaptureCheckpoint(combat);
|
||||
SaveData data = saves.Load();
|
||||
data.activeRun = snapshot;
|
||||
LanguageUnlock.RecordCampaignClear(data, run.CurrentConfig, run.Journey, run.WavesCleared);
|
||||
saves.Save(data);
|
||||
run.MarkSuspended(); // Never suppress settlement or leave the scene on a failed save.
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace KernelPanic.Run
|
||||
public int FinalWave => encounterRevision >= 2 ? BossWave : LegacyBossWave;
|
||||
public bool IsRewardWave(int wave) => encounterRevision > 0 && wave >= 2 && wave < FinalWave && wave % 2 == 0;
|
||||
public bool AtMilestone(int wavesCleared) => campaign && !endless && wavesCleared >= FinalWave;
|
||||
public static RunJourney NewCampaign() => new() { campaign = true, encounterRevision = 2, mapRevision = 2 };
|
||||
public static RunJourney NewCampaign() => new() { campaign = true, encounterRevision = 3, mapRevision = 2 };
|
||||
public RunJourney Copy()
|
||||
{
|
||||
var copy = (RunJourney)MemberwiseClone();
|
||||
@@ -43,7 +43,7 @@ namespace KernelPanic.Run
|
||||
|
||||
public void Validate(int wave)
|
||||
{
|
||||
RunCheckpoint.Require(encounterRevision >= 0 && encounterRevision <= 2, "Unsupported encounter revision.");
|
||||
RunCheckpoint.Require(encounterRevision >= 0 && encounterRevision <= 3, "Unsupported encounter revision.");
|
||||
RunCheckpoint.Require((pendingRewardWave == 0 || IsRewardWave(pendingRewardWave))
|
||||
&& (claimedRewardWave == 0 || IsRewardWave(claimedRewardWave))
|
||||
&& claimedRewardWave < wave
|
||||
|
||||
@@ -56,6 +56,8 @@ namespace KernelPanic.Run
|
||||
public string RunId { get; private set; }
|
||||
public bool IsSuspended { get; private set; }
|
||||
public RunJourney Journey { get; private set; } = new();
|
||||
public Meta.RunPerformanceSnapshot Performance { get; private set; } = new();
|
||||
public List<CheckpointCard> FinalDeck { get; private set; }
|
||||
public bool CampaignChoicePending => Journey.AtMilestone(_wavesCleared);
|
||||
public bool BuildRewardPending => Journey.pendingRewardWave > 0;
|
||||
public const int BuildRewardBits = 8;
|
||||
@@ -216,6 +218,8 @@ namespace KernelPanic.Run
|
||||
public void StartRun(RunConfig config)
|
||||
{
|
||||
CurrentConfig = config;
|
||||
Performance = new();
|
||||
FinalDeck = null;
|
||||
Journey = RunJourney.NewCampaign();
|
||||
if (config?.IsTutorial == true) Journey = new RunJourney();
|
||||
RunId = Guid.NewGuid().ToString("N");
|
||||
@@ -265,7 +269,7 @@ namespace KernelPanic.Run
|
||||
bandwidth = _accruedBandwidth, entropy = _accruedEntropy,
|
||||
maxUptimeBonus = _maxUptimeBonus, maxCyclesBonus = _maxCyclesBonus, ramBonus = _ramBonus,
|
||||
rerolls = _rerollsThisVisit, shopRandomDraws = _repositoryRandom.Draws,
|
||||
version = 4, journey = Journey.Copy(),
|
||||
version = 5, journey = Journey.Copy(), performance = Performance.Copy(),
|
||||
combat = combat.CaptureBoundaryState()
|
||||
};
|
||||
foreach (PackageInstance package in CurrentConfig.EquippedPackages)
|
||||
@@ -288,6 +292,8 @@ namespace KernelPanic.Run
|
||||
if (resume == null) throw new ArgumentNullException(nameof(resume));
|
||||
RunCheckpoint snapshot = resume.Snapshot;
|
||||
CurrentConfig = resume.Config;
|
||||
Performance = snapshot.performance?.schemaVersion == 1 ? snapshot.performance.Copy() : new Meta.RunPerformanceSnapshot { complete = false };
|
||||
FinalDeck = null;
|
||||
Journey = snapshot.journey?.Copy() ?? new RunJourney();
|
||||
RunId = snapshot.runId;
|
||||
IsSuspended = false;
|
||||
@@ -540,6 +546,7 @@ namespace KernelPanic.Run
|
||||
|
||||
private void HandleRunEnded(RunEndedEvent payload)
|
||||
{
|
||||
FinalDeck = _runDeck.Select(CheckpointCard.Capture).ToList();
|
||||
isRunActive = false;
|
||||
isPlayerDead = payload.PlayerDied;
|
||||
_bits = 0;
|
||||
|
||||
Reference in New Issue
Block a user