55 lines
2.5 KiB
C#
55 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using KernelPanic.Combat;
|
|
using KernelPanic.Data;
|
|
using KernelPanic.Meta;
|
|
|
|
namespace KernelPanic.Run
|
|
{
|
|
public static class TutorialCampaign
|
|
{
|
|
public const int LessonCount = 2;
|
|
public const int BandwidthReward = 1000;
|
|
public const int EntropyReward = GachaService.StandardTenPullCost * GachaService.EntropyPerCommit;
|
|
public static bool Required(SaveData save) => save != null && save.starterChosen && save.tutorialRequired;
|
|
public static int Lesson(SaveData save) => save?.tutorialCheckpoint != null ? 2 : 1;
|
|
|
|
public static void Enroll(SaveData save, string distroId)
|
|
{
|
|
save.tutorialRequired = true; save.tutorialLesson = 1;
|
|
save.tutorialDistroId = distroId; save.tutorialCheckpoint = null;
|
|
}
|
|
|
|
// Commit balances and the claimed flag together. Re-enrollment never grants a second payout.
|
|
public static void Complete(SaveData save)
|
|
{
|
|
if (!Required(save) || save.tutorialLesson != 2)
|
|
throw new InvalidOperationException("Complete both training waves before claiming the reward.");
|
|
if (!save.tutorialRewardClaimed)
|
|
{
|
|
save.bandwidthBalance = checked(Math.Max(0, save.bandwidthBalance) + BandwidthReward);
|
|
save.entropyBalance = checked(Math.Max(0, save.entropyBalance) + EntropyReward);
|
|
save.tutorialRewardClaimed = true;
|
|
}
|
|
save.tutorialRequired = false; save.tutorialCheckpoint = null;
|
|
}
|
|
|
|
public static EncounterPlan Plan(int wave) => wave switch
|
|
{
|
|
1 => new("Targeting and revival", "", 0, "zombie_process", "orphan_process"),
|
|
2 => new("Queue, stack and finish", "", 0, "memory_leak", "firewalld"),
|
|
_ => throw new ArgumentOutOfRangeException(nameof(wave))
|
|
};
|
|
|
|
public static RunConfig CreateConfig(DistroDefinition distro, CardDatabase cards, int lesson)
|
|
{
|
|
if (distro == null || cards == null) throw new InvalidOperationException("Tutorial content is unavailable.");
|
|
_ = Plan(lesson);
|
|
var deck = new List<CardDefinition>();
|
|
foreach (string id in new[] { "lang_rs_unwrap", "lang_rs_fn_main", "lang_rs_borrow", "lang_py_print", "lang_hs_thunk" })
|
|
deck.Add(cards.FindById(id) ?? throw new InvalidOperationException("Missing tutorial card: " + id));
|
|
return RunConfig.ForTutorial(distro, deck, lesson);
|
|
}
|
|
}
|
|
}
|