Refactor alot of stuff
This commit is contained in:
@@ -13,11 +13,11 @@ namespace KernelPanic.Data
|
||||
private static readonly LanguageCatalogEntry[] Entries =
|
||||
{
|
||||
new(Language.C, "C", "bare metal", ResolutionTrack.Native, $"C is immediate, high-risk burst damage. C damage rolls a {CombatTuning.CCriticalChancePercent}% crit chance instead of the normal 25%, spills {CombatTuning.COverkillSpillPercent}% of remaining overkill into other enemies per jump (rounded down), and C cards can segfault: hurting you and corrupting a hand card. Segfault corruption recovers automatically after 3 rounds. C repair cards restore corrupted cards sooner.", null, Distro("arch", "Arch"), Distro("gentoo", "Gentoo"), Distro("templeos", "TempleOS")),
|
||||
new(Language.CPlusPlus, "C++", "compiled evolution", ResolutionTrack.Native, "Upgraded C cards: stronger immediate attacks, full overkill spill, the same elevated critical chance, and no segfault recoil. Chain C++ cards for pointer's combo. sizeof counts both C and C++ cards in hand.", "unlock: clear all 10 campaign waves with C selected"),
|
||||
new(Language.CPlusPlus, "C++", "compiled evolution", ResolutionTrack.Native, "Upgraded C cards: the same base attack damage, full overkill spill, the same elevated critical chance, and no segfault recoil. Chain C++ cards for pointer's combo. sizeof counts both C and C++ cards in hand.", "unlock: clear all 10 campaign waves with C selected"),
|
||||
new(Language.Rust, "Rust", "safe systems", ResolutionTrack.Native, "Rust is immediate, reliable damage with defensive payoff. Rust overkill becomes Shield, and Rust damage has a tiny 0.001% chance to overflow into the unsigned 64-bit limit.", null, Distro("arch", "Arch"), Distro("fedora", "Fedora")),
|
||||
new(Language.Python, "Python", "pipelines and automation", ResolutionTrack.InterpreterQueue, "Preparation acts immediately. Payloads and modifiers resolve FIFO before enemies: for loop repeats the next payload, zip spreads a single-target payload to all enemies. Unused modifiers expire after the following round. Two automation slots run captured operations for two future rounds. Replays copy damage and Shield only, never draw, growth or installation. Scripts and modifiers clear each wave.", null, Distro("ubuntu", "Ubuntu"), Distro("kali", "Kali"), Distro("mint", "Mint")),
|
||||
new(Language.JavaScript, "JavaScript", "runtime chaos", ResolutionTrack.Native, "JavaScript resolves immediately and is intentionally swingy: wide damage ranges, chance-based outcomes, and conditional repeat effects. It rewards embracing variance.", null, Distro("ubuntu", "Ubuntu"), Distro("endeavouros", "EndeavourOS"), Distro("mint", "Mint")),
|
||||
new(Language.TypeScript, "TypeScript", "typed evolution", ResolutionTrack.Native, "Upgraded JavaScript cards with fixed damage, guaranteed typeof, and stronger utility. TypeScript damage never rolls critical hits. Current buffs, Shield and enemy defenses still apply.", "unlock: clear all 10 campaign waves with JavaScript selected"),
|
||||
new(Language.TypeScript, "TypeScript", "typed evolution", ResolutionTrack.Native, "Upgraded JavaScript cards with fixed average damage (halves rounded up), guaranteed typeof, and stronger utility. TypeScript damage cannot crit. typeof averages in its failure chance. Current buffs, Shield and enemy defenses still apply.", "unlock: clear all 10 campaign waves with JavaScript selected"),
|
||||
new(Language.Haskell, "Haskell", "lazy proofs", ResolutionTrack.LazyStack, "Lazy proofs. Build a stack of delayed operations. Later cards gain stronger effects when evaluated. Snapshot x1.5 / x1.75 / x2.0 / x2.5 at play; LIFO after Python. Only damage and explicit Shield multiply.", null, Distro("gentoo", "Gentoo"), Distro("nixos", "NixOS")),
|
||||
new(Language.Assembly, "Assembly", "raw opcodes", ResolutionTrack.Native, "Assembly is planned as the most direct Native language: low-level, high-commitment effects that should trade flexibility for extreme precision or shield-bypass pressure.", null, Distro("templeos", "TempleOS")),
|
||||
new(Language.Java, "Java", "warming vm", ResolutionTrack.Native, "Each Java card uses 2 RAM and spills overkill into other enemies. JIT gives -1 Cycle per 2 Java plays, capped at -3. Store at most 6 warmup plays; lose 2 after each wave, cooling the discount by 1.", null, Distro("debian", "Debian"), Distro("fedora", "Fedora")),
|
||||
|
||||
@@ -6,9 +6,21 @@ namespace KernelPanic.Data
|
||||
{
|
||||
public enum PackageSlot
|
||||
{
|
||||
Kernel,
|
||||
Runtime,
|
||||
Daemon
|
||||
// Keep serialized identities stable for existing assets and saves.
|
||||
[InspectorName("System")] Kernel = 0,
|
||||
[InspectorName("Tools")] Runtime = 1,
|
||||
[InspectorName("Services")] Daemon = 2
|
||||
}
|
||||
|
||||
public static class PackageSlotPresentation
|
||||
{
|
||||
public static string DisplayName(this PackageSlot slot) => slot switch
|
||||
{
|
||||
PackageSlot.Kernel => "System",
|
||||
PackageSlot.Runtime => "Tools",
|
||||
PackageSlot.Daemon => "Services",
|
||||
_ => "Unknown"
|
||||
};
|
||||
}
|
||||
|
||||
public enum PackageEffectKind
|
||||
@@ -80,7 +92,7 @@ namespace KernelPanic.Data
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines persistent meta packages equipped into distro Kernel/Runtime/Daemon slots.
|
||||
/// Defines persistent meta packages equipped into System/Tools/Services slots.
|
||||
/// Package loadouts are meta progression and carry into every run for that distro.
|
||||
/// Card loadouts remain run setup only.
|
||||
/// </summary>
|
||||
@@ -89,7 +101,9 @@ namespace KernelPanic.Data
|
||||
[SerializeField] private string id;
|
||||
[SerializeField] private string displayName;
|
||||
[SerializeField] private PackageSlot slot;
|
||||
[SerializeField] private int legacySlot = -1;
|
||||
[SerializeField, Range(1, 5)] private int rarity = 1;
|
||||
[SerializeField, Range(0, KernelPanic.Meta.PackageTuning.MaxPackageLevel)] private int maxUpgradeLevel = 5;
|
||||
[SerializeField, TextArea] private string description;
|
||||
[SerializeField] private string flavourText;
|
||||
[SerializeField, TextArea] private string designNotes;
|
||||
@@ -103,7 +117,10 @@ namespace KernelPanic.Data
|
||||
public string Id => id;
|
||||
public string DisplayName => displayName;
|
||||
public PackageSlot Slot => slot;
|
||||
public bool AcceptsSavedSlot(PackageSlot savedSlot) => savedSlot == slot
|
||||
|| (legacySlot >= 0 && (int)savedSlot == legacySlot);
|
||||
public int Rarity => Mathf.Clamp(rarity, 1, 5);
|
||||
public int MaxUpgradeLevel => Mathf.Clamp(maxUpgradeLevel, 0, KernelPanic.Meta.PackageTuning.MaxPackageLevel);
|
||||
public string Description => description;
|
||||
public string FlavourText => flavourText;
|
||||
public string FlavorText => flavourText;
|
||||
@@ -140,10 +157,13 @@ namespace KernelPanic.Data
|
||||
public PackageInstance(PackageDefinition definition, int upgradeLevel)
|
||||
{
|
||||
Definition = definition;
|
||||
UpgradeLevel = Mathf.Clamp(upgradeLevel, 0, KernelPanic.Meta.PackageTuning.MaxPackageLevel);
|
||||
SavedSlot = definition == null ? default : definition.Slot;
|
||||
UpgradeLevel = Mathf.Clamp(upgradeLevel, 0, definition == null ? 0 : definition.MaxUpgradeLevel);
|
||||
}
|
||||
|
||||
public PackageDefinition Definition { get; }
|
||||
// Preserve the original allocation when resuming pre-taxonomy runs.
|
||||
public PackageSlot SavedSlot { get; set; }
|
||||
public int UpgradeLevel { get; }
|
||||
|
||||
public IEnumerable<PackageEffectData> EffectsFor(string distroId)
|
||||
@@ -170,30 +190,71 @@ namespace KernelPanic.Data
|
||||
return effect;
|
||||
}
|
||||
|
||||
int amount = effect.Amount + GetAmountPerLevel(effect.Kind, effect.Amount) * level;
|
||||
return new PackageEffectData(effect.Kind, amount, effect.Threshold, effect.RefundCycle, effect.CleanseDebuffs, effect.EnableFedoraSecondCardPassive, effect.PersistArchBtw);
|
||||
}
|
||||
|
||||
private static int GetAmountPerLevel(PackageEffectKind kind, int baseAmount)
|
||||
{
|
||||
return kind switch
|
||||
int amount = effect.Amount;
|
||||
int threshold = effect.Threshold;
|
||||
// Counts, trigger intervals, percentages and flags are different units.
|
||||
// Explicit cases prevent new effects from accidentally inheriting +1 to everything.
|
||||
switch (effect.Kind)
|
||||
{
|
||||
PackageEffectKind.MaxUptime => Mathf.Max(1, Mathf.CeilToInt(Mathf.Max(1, baseAmount) * 0.5f)),
|
||||
PackageEffectKind.MaxCycles => 1,
|
||||
PackageEffectKind.MaxRam => 1,
|
||||
PackageEffectKind.WaveDraw => 1,
|
||||
PackageEffectKind.FirstTurnFirstWaveDraw => 1,
|
||||
PackageEffectKind.FirstTurnEachWaveCycle => 1,
|
||||
PackageEffectKind.FirstCardsEachTurnCostReduction => 1,
|
||||
PackageEffectKind.FirstCardEachWaveCostReduction => 1,
|
||||
PackageEffectKind.FirstNativeCardEachWaveFlatDamage => 1,
|
||||
PackageEffectKind.JavaScriptFlatDamage => 1,
|
||||
PackageEffectKind.TurnStartGenerateLanguageCard => 0,
|
||||
PackageEffectKind.PortageWaveStartShield => 2,
|
||||
PackageEffectKind.CompilationAdvancedPreviousRoundCycle => 0,
|
||||
PackageEffectKind.AfterFirstRoundCompilation => 0,
|
||||
_ => 1
|
||||
};
|
||||
case PackageEffectKind.MaxUptime:
|
||||
amount += Mathf.Clamp(Mathf.CeilToInt(effect.Amount * .5f), 1, 2) * level;
|
||||
break;
|
||||
case PackageEffectKind.PortageWaveStartShield:
|
||||
amount += 2 * level;
|
||||
break;
|
||||
case PackageEffectKind.WaveStartShield:
|
||||
case PackageEffectKind.FirstTurnEachWaveShield:
|
||||
case PackageEffectKind.EveryNthTurnShield:
|
||||
case PackageEffectKind.ExhaustShield:
|
||||
case PackageEffectKind.FirstInterpreterQueueCardEachWaveShield:
|
||||
case PackageEffectKind.FirstShieldEachTurnBonus:
|
||||
case PackageEffectKind.StartTurnNoDebuffShield:
|
||||
case PackageEffectKind.FirstCardEachRoundDiscountAndShield:
|
||||
case PackageEffectKind.AfterFirstRoundShield:
|
||||
case PackageEffectKind.FirstNativeCardEachWaveFlatDamage:
|
||||
case PackageEffectKind.JavaScriptFlatDamage:
|
||||
case PackageEffectKind.DnfFedoraPassive:
|
||||
amount += level;
|
||||
break;
|
||||
case PackageEffectKind.MaxCycles:
|
||||
case PackageEffectKind.FirstTurnEachWaveCycle:
|
||||
case PackageEffectKind.EveryNthCardEachWaveCycle:
|
||||
case PackageEffectKind.WaveDraw:
|
||||
case PackageEffectKind.WaveGenerateBasicCard:
|
||||
case PackageEffectKind.ThirdCardEachTurnGenerate:
|
||||
case PackageEffectKind.FirstCardEachWaveCostReduction:
|
||||
amount += Math.Min(level, 1);
|
||||
break;
|
||||
case PackageEffectKind.MaxRam:
|
||||
case PackageEffectKind.FirstTurnFirstWaveDraw:
|
||||
amount += Math.Min(level, 2);
|
||||
break;
|
||||
case PackageEffectKind.EveryNthTurnDraw:
|
||||
threshold = Math.Max(2, threshold - 1);
|
||||
amount += level >= 2 ? 1 : 0;
|
||||
break;
|
||||
case PackageEffectKind.FirstCardsEachTurnCostReduction:
|
||||
// Extend the one-Cycle discount to one more card, never make it six Cycles.
|
||||
threshold += Math.Min(level, 1);
|
||||
break;
|
||||
case PackageEffectKind.EveryNthCardEachWaveFree:
|
||||
threshold = Math.Max(2, threshold - level);
|
||||
break;
|
||||
case PackageEffectKind.FirstCThisTurnDamageMultiplier:
|
||||
amount += 10 * level;
|
||||
break;
|
||||
case PackageEffectKind.WaveThresholdRestore:
|
||||
threshold = Math.Min(75, threshold + 5 * level);
|
||||
break;
|
||||
// AUR's amount is a mode flag. Compilation and its Cycle reward stay fixed.
|
||||
case PackageEffectKind.TurnStartGenerateLanguageCard:
|
||||
case PackageEffectKind.CompilationAdvancedPreviousRoundCycle:
|
||||
case PackageEffectKind.AfterFirstRoundCompilation:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return new PackageEffectData(effect.Kind, amount, threshold, effect.RefundCycle, effect.CleanseDebuffs,
|
||||
effect.EnableFedoraSecondCardPassive, effect.PersistArchBtw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user