Implement more QoL features and rebalances
This commit is contained in:
@@ -167,7 +167,7 @@ namespace KernelPanic.Combat
|
||||
private const CardTargeting None = CardTargeting.None;
|
||||
private const CardTargeting Single = CardTargeting.SingleEnemy;
|
||||
private const CardTargeting All = CardTargeting.AllEnemies;
|
||||
private const string CRecoil = " overkill spills. 25%: segfault, uptime -3 and corrupt a hand card.";
|
||||
private const string CRecoil = " 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3 and corrupt a hand card.";
|
||||
private const string Jit = " overkill spills. JIT applies; discount decays by 1 after each wave.";
|
||||
private static readonly IReadOnlyDictionary<string, CardCatalogEntry> ById;
|
||||
public static IReadOnlyList<CardCatalogEntry> Entries { get; }
|
||||
@@ -182,7 +182,7 @@ namespace KernelPanic.Combat
|
||||
Add("gentoo_ebuild", Single, false, "stack: deal {amount:0}.", Damage(4, Language.Haskell));
|
||||
Add("gentoo_use_flags", None, false, "gain {shield:0} Shield. if Compilation >= {rawSecondary:1}, draw {amount:1}.",
|
||||
Shield(4), Fx(CardEffectKind.CompilationDraw, CompilationDrawEffect.DrawCount, secondary: CompilationDrawEffect.RequiredCompilation));
|
||||
Add("gentoo_make_j4", Single, true, "deal {amount:0}; {secondary:0} if Compilation >= {rawMax:0}. one C hit; overkill spills; 25%: segfault, uptime -3 and corrupt a hand card.",
|
||||
Add("gentoo_make_j4", Single, true, "deal {amount:0}; {secondary:0} if Compilation >= {rawMax:0}. one C hit; 50% of overkill spills per jump (rounded down); 25%: segfault, uptime -3 and corrupt a hand card.",
|
||||
Fx(CardEffectKind.MakeJ4, MakeJ4Effect.BaseDamage, MakeJ4Effect.RequiredCompilation, MakeJ4Effect.CompiledDamage, Language.C));
|
||||
Add("gentoo_emerge_world", All, false, "stack: deal {amount:0} to all living enemies. gain {shield:1} Shield.", Damage(3, Language.Haskell, all: true), Shield(2));
|
||||
Add("lang_hs_map", Single, false, "stack: deal {amount:0}.", Damage(2, Language.Haskell));
|
||||
@@ -250,10 +250,10 @@ namespace KernelPanic.Combat
|
||||
Add("arch_aur_helper", None, false, "add a random C/Rust common card to hand; it costs 0 this turn.", Fx(CardEffectKind.RandomCommonLanguageCard));
|
||||
Add("arch_minimal_install", None, false, "exhaust up to {raw:0} hand cards. per card: gain {rawSecondary:0} Shield and {rawMax:0} Cycle.",
|
||||
Fx(CardEffectKind.MinimalInstall, MinimalInstallEffect.MaxExhaust, MinimalInstallEffect.CyclesPerCard, MinimalInstallEffect.ShieldPerCard));
|
||||
Add("shop_c_free", Single, true, "deal {amount:0}. overkill spills. 25%: segfault, uptime -3, corrupt a hand card, and draw 2. then repair up to {amount:1} corrupted card{plural:1} in your active deck.",
|
||||
Add("shop_c_free", Single, true, "deal {amount:0}. 50% of overkill spills per jump (rounded down). 25%: segfault, uptime -3, corrupt a hand card, and draw 2. then repair up to {amount:1} corrupted card{plural:1} in your active deck.",
|
||||
Damage(18, Language.C), Fx(CardEffectKind.RepairCorruptedCards, 1));
|
||||
Add("shop_c_sizeof", Single, true, "deal {raw:0} x C cards in hand." + CRecoil, Fx(CardEffectKind.SizeofDamage, SizeofDamageEffect.DamagePerCard, language: Language.C));
|
||||
Add("shop_c_kernel_exploit", Single, true, "deal {amount:0} ignoring Shield. overkill spills. 50%: segfault, uptime -8 and corrupt a hand card.", Damage(36, Language.C, trueDamage: true));
|
||||
Add("shop_c_kernel_exploit", Single, true, "deal {amount:0} ignoring Shield. 50% of overkill spills per jump (rounded down). 50%: segfault, uptime -8 and corrupt a hand card.", Damage(36, Language.C, trueDamage: true));
|
||||
Add("shop_c_gdb", None, false, "repair up to {amount:0} corrupted cards in your active deck. draw {amount:1}.",
|
||||
Fx(CardEffectKind.RepairCorruptedCards, 2), Draw(1));
|
||||
Add("shop_c_valgrind", None, false, "repair up to {amount:0} corrupted cards in your active deck. gain {shield:1} Shield.",
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace KernelPanic.Combat
|
||||
int remaining, Language language, bool trueDamage)
|
||||
{
|
||||
bool dealtDamage = false;
|
||||
bool attenuate = language == Language.C || context.Card?.Definition?.Language == Language.C;
|
||||
// Keep the original target excluded even if a lethal-hit save left it alive.
|
||||
CombatantState originalTarget = firstTarget;
|
||||
for (int i = 0; i < context.Enemies.Count && remaining > 0; i++)
|
||||
@@ -64,6 +65,10 @@ namespace KernelPanic.Combat
|
||||
if (target == null || target == originalTarget || target == firstTarget || target.IsDefeated)
|
||||
continue;
|
||||
|
||||
// C loses half its excess on every actual jump, after the previous target's defenses.
|
||||
// Integer division rounds down; one excess damage cannot create another hit.
|
||||
if (attenuate) remaining = (int)((long)remaining * CombatTuning.COverkillSpillPercent / 100);
|
||||
if (remaining == 0) break;
|
||||
int capacity = GetDamageCapacity(target, trueDamage);
|
||||
GameEvents.RaiseOverflowDamageTravel(new OverflowDamageTravelEvent(context.Source, firstTarget, target, remaining, language));
|
||||
DamageResult result = CardDamageExecutor.ApplyHit(context,
|
||||
|
||||
@@ -271,7 +271,9 @@ namespace KernelPanic.Combat
|
||||
if (hitCount > 1) notes.Add($"{hitCount} hits in total; later hits can stop when a target dies or combat ends.");
|
||||
if (trueDamage) notes.Add("True damage bypasses Shield.");
|
||||
if (random) notes.Add("Random amounts show the full normal range.");
|
||||
if (critical) notes.Add("Critical chance: C 50%, other languages 25%; each hit rolls independently.");
|
||||
if (critical) notes.Add($"Critical chance: C {CombatTuning.CCriticalChancePercent}%, other languages 25%; each hit rolls independently.");
|
||||
if (card.Definition.Language == Language.C)
|
||||
notes.Add($"C spills {CombatTuning.COverkillSpillPercent}% of remaining overkill per jump, rounded down; spill cannot crit or reapply source bonuses.");
|
||||
if (rust) notes.Add(source.ForceMaxRolls
|
||||
? "Rust overkill can grant Shield; max-roll mode prevents unsigned overflow."
|
||||
: "Rare Rust unsigned overflow is not included in the normal range. Overkill can grant additional Shield.");
|
||||
|
||||
@@ -46,6 +46,23 @@ namespace KernelPanic.Combat
|
||||
private int _fedoraCardsDiscountedThisTurn;
|
||||
private float _fedoraCrashChance = CombatTuning.FedoraBleedingEdgeBaseCrashChance;
|
||||
private int _cardsPlayedThisTurn;
|
||||
private bool _prefetchUsed;
|
||||
public const int PrefetchCost = 2;
|
||||
public bool CanPrefetch => CanSurrenderRun && _runConfig?.IsTutorial != true && !_prefetchUsed
|
||||
&& _playerState.Cycles >= PrefetchCost && _handController != null
|
||||
&& _handController.RemainingRam >= 2 && _deckController.AvailableToDrawCount > 0;
|
||||
|
||||
public bool TryPrefetch()
|
||||
{
|
||||
// Reserve two RAM so every possible top card fits, without revealing its identity or
|
||||
// consuming a shuffle on a rejected action. Java occupies two RAM; other cards use one.
|
||||
if (!CanPrefetch || !_deckController.TryDrawToHand(_handController, out _)) return false;
|
||||
_prefetchUsed = true;
|
||||
_playerState.Cycles -= PrefetchCost;
|
||||
Log("prefetch: spent 2 Cycles, drew 1 card (once per turn)");
|
||||
StateChanged?.Invoke();
|
||||
return true;
|
||||
}
|
||||
private int _cardsPlayedThisWave;
|
||||
private int _cCardsPlayedThisTurn;
|
||||
private int _turnNumberThisWave;
|
||||
@@ -280,7 +297,7 @@ namespace KernelPanic.Combat
|
||||
{
|
||||
if (_runConfig?.IsTutorial == true) return;
|
||||
if (!_awaitingWaveContinue || RunFinished || _waveTransitionActive
|
||||
|| _runManager?.IsSuspended == true || _runManager?.CampaignChoicePending == true)
|
||||
|| _runManager?.IsSuspended == true || _runManager?.CampaignChoicePending == true || _runManager?.BuildRewardPending == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -308,8 +325,11 @@ namespace KernelPanic.Combat
|
||||
public bool ContinueTutorialWave()
|
||||
{
|
||||
if (_runConfig?.IsTutorial != true || !_awaitingWaveContinue || RunFinished || _waveTransitionActive
|
||||
|| _runManager.WavesCleared != 1 || !_runManager.RepositoryOffers.Any(offer => offer.Sold)) return false;
|
||||
_runConfig.TutorialLesson = 2;
|
||||
|| _runManager.WavesCleared < 1 || _runManager.WavesCleared >= TutorialCampaign.LessonCount
|
||||
|| (_runManager.WavesCleared == 1 && !_runManager.RepositoryOffers.Any(offer => offer.Sold))) return false;
|
||||
_runConfig.TutorialLesson = _runManager.WavesCleared + 1;
|
||||
// The countdown lesson requires two enemy turns. A low-health checkpoint must remain playable.
|
||||
if (_runConfig.TutorialLesson == 3) _playerState.CurrentUptime = _playerState.MaxUptime;
|
||||
_waveTransitionActive = true;
|
||||
_runManager.PrepareNextEncounter(_playerState);
|
||||
_awaitingWaveContinue = false;
|
||||
@@ -1232,6 +1252,7 @@ namespace KernelPanic.Combat
|
||||
RevivePendingEnemies();
|
||||
UnlockHandCards("license check expired");
|
||||
_playerState.Cycles = _playerState.MaxCycles;
|
||||
_prefetchUsed = false;
|
||||
_fedoraCardsDiscountedThisTurn = 0;
|
||||
_cardsPlayedThisTurn = 0;
|
||||
_cCardsPlayedThisTurn = 0;
|
||||
@@ -1384,7 +1405,8 @@ namespace KernelPanic.Combat
|
||||
continue;
|
||||
}
|
||||
|
||||
Log($"{enemy.Name} executes {enemy.DisplayIntent.DisplayText}");
|
||||
// The action is public once execution starts, even if it was not probed beforehand.
|
||||
Log($"{enemy.Name} executes {enemy.CurrentIntent.DisplayText}");
|
||||
GameEvents.RaiseEnemyWouldAct(new EnemyWouldActEvent(enemy));
|
||||
StateChanged?.Invoke();
|
||||
yield return Wait(CombatTuning.EnemyTelegraphDelaySeconds);
|
||||
@@ -2073,6 +2095,7 @@ namespace KernelPanic.Combat
|
||||
}
|
||||
|
||||
enemy.ReviveAtHalfUptime();
|
||||
GameEvents.RaiseEnemyRevived(enemy);
|
||||
Log($"{enemy.Name} revived at {enemy.CurrentUptime} uptime");
|
||||
}
|
||||
}
|
||||
@@ -2728,14 +2751,20 @@ namespace KernelPanic.Combat
|
||||
if (_runConfig?.IsTutorial == true || _runManager?.Journey.campaign == true)
|
||||
{
|
||||
CurrentEncounter = _runConfig.IsTutorial ? TutorialCampaign.Plan(_runConfig.TutorialLesson)
|
||||
: EncounterDirector.Plan(CurrentWaveNumber, _runManager.Journey.activeRoute);
|
||||
: EncounterDirector.Plan(CurrentWaveNumber, _runManager.Journey.activeRoute,
|
||||
_runConfig.RunSeed, _runManager.Journey.encounterRevision);
|
||||
for (int slot = 0; slot < CurrentEncounter.Enemies.Count; slot++)
|
||||
{
|
||||
string id = CurrentEncounter.Enemies[slot];
|
||||
if (id == "race_condition" && slot + 1 < CurrentEncounter.Enemies.Count
|
||||
&& CurrentEncounter.Enemies[slot + 1] == id)
|
||||
{ SpawnRacePair(CurrentEncounter.UptimeBonus); slot++; }
|
||||
else SpawnEnemy(id, CurrentEncounter.UptimeBonus);
|
||||
else
|
||||
{
|
||||
bool escort = slot == CurrentEncounter.Enemies.Count - 1 && id == "daemon";
|
||||
var enemy = SpawnEnemy(id, CurrentEncounter.UptimeBonus + (escort ? CurrentEncounter.EscortUptime : 0));
|
||||
if (escort) enemy.State.Shield += CurrentEncounter.EscortShield;
|
||||
}
|
||||
}
|
||||
Log(CurrentEncounter.Title + ": " + CurrentEncounter.Advice);
|
||||
return;
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace KernelPanic.Combat
|
||||
public const int DrawPerTurn = 1;
|
||||
public const int MinimumHandFloor = 0;
|
||||
public const int SegfaultCorruptionRecoveryRounds = 3;
|
||||
public const int CCriticalChancePercent = 35;
|
||||
public const int COverkillSpillPercent = 50;
|
||||
public const int OrphanSpawnChancePercent = 25;
|
||||
|
||||
public const int BaseEnemyUptimeMin = 5;
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace KernelPanic.Combat
|
||||
return amount;
|
||||
}
|
||||
|
||||
int critChance = request.Language == Language.C ? 50 : 25;
|
||||
int critChance = request.Language == Language.C ? CombatTuning.CCriticalChancePercent : 25;
|
||||
wasCritical = RandomRoll.RollRange(1, 100, new RollContext(request.Source)) <= critChance;
|
||||
return wasCritical ? ScaleCritical(amount) : amount;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace KernelPanic.Combat
|
||||
public string Advice { get; }
|
||||
public IReadOnlyList<string> Enemies { get; }
|
||||
public int UptimeBonus { get; }
|
||||
public int EscortShield { get; internal set; }
|
||||
public int EscortUptime { get; internal set; }
|
||||
public EncounterPlan(string title, string advice, int uptimeBonus, params string[] enemies)
|
||||
{ Title = title; Advice = advice; UptimeBonus = uptimeBonus; Enemies = Array.AsReadOnly(enemies); }
|
||||
}
|
||||
@@ -17,6 +19,64 @@ namespace KernelPanic.Combat
|
||||
/// <summary>Authored encounter composition. Reads no random state; spawning owns stat rolls.</summary>
|
||||
public static class EncounterDirector
|
||||
{
|
||||
// A stable integer mixer, independent of both gameplay random streams and runtime hash codes.
|
||||
public static EncounterPlan Plan(int wave, WaveRoute route, int seed, int revision)
|
||||
{
|
||||
if (revision == 0) return Plan(wave, route);
|
||||
uint hash = unchecked((uint)seed ^ ((uint)wave * 0x9E3779B9u));
|
||||
hash ^= hash >> 16; hash = unchecked(hash * 0x7FEB352Du); hash ^= hash >> 15;
|
||||
int variant = (int)(hash % 3);
|
||||
var baseline = Plan(wave, WaveRoute.Repair);
|
||||
string title = baseline.Title, advice = baseline.Advice;
|
||||
string[] enemies = new List<string>(baseline.Enemies).ToArray();
|
||||
if (variant > 0)
|
||||
{
|
||||
switch (wave)
|
||||
{
|
||||
case 1:
|
||||
title = variant == 1 ? "Stale services" : "Scheduled startup";
|
||||
enemies = variant == 1 ? new[] { "zombie_process", "zombie_process" } : new[] { "zombie_process", "cron_job" };
|
||||
advice = variant == 1 ? "Both Zombies can revive once. Finish weakened zombies decisively."
|
||||
: "The Zombie can revive once. Cron Job announces its heavy attack with a countdown.";
|
||||
break;
|
||||
case 2:
|
||||
title = variant == 1 ? "Leaking firewall" : "Orphan cleanup";
|
||||
enemies = variant == 1 ? new[] { "firewalld", "memory_leak" } : new[] { "zombie_process", "segfault" };
|
||||
advice = variant == 1 ? "Memory Leak grows each round while firewalld shields its neighbour."
|
||||
: "The Zombie can revive once. Segfault has a death payload; plan for the process it leaves behind.";
|
||||
break;
|
||||
case 3:
|
||||
title = variant == 1 ? "Hidden dependencies" : "Scheduled replication";
|
||||
enemies = variant == 1 ? new[] { "rootkit", "zombie_process", "memory_leak" } : new[] { "fork_bomb", "cron_job", "zombie_process" };
|
||||
advice = variant == 1 ? "Rootkit resists damage while allies remain. Clear its support while containing the growing Memory Leak."
|
||||
: "Fork Bomb copies itself after acting. Cron Job counts down to a heavy attack; stop their growth early.";
|
||||
break;
|
||||
case 4:
|
||||
title = variant == 1 ? "Protected concurrency" : "Leaking concurrency";
|
||||
enemies = new[] { "race_condition", "race_condition", variant == 1 ? "firewalld" : "memory_leak" };
|
||||
advice = "Race partners act in uncertain order; defeating one enrages the survivor. Choose between support and paired threats.";
|
||||
break;
|
||||
case RunJourney.BossWave:
|
||||
title = variant == 1 ? "Kernel Overseer / scheduled interrupt" : "Kernel Overseer / memory pressure";
|
||||
enemies = new[] { "kernel_overseer", variant == 1 ? "cron_job" : "memory_leak" };
|
||||
advice = baseline.Advice;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var plan = new EncounterPlan(title, advice, baseline.UptimeBonus, enemies);
|
||||
if (wave > 1 && route == WaveRoute.Challenge)
|
||||
{
|
||||
int modifier = (int)((hash >> 8) % 3);
|
||||
var escort = new List<string>(enemies) { "daemon" };
|
||||
string detail = modifier == 0 ? "Veiled escort: damage the extra Daemon to reveal its intent."
|
||||
: modifier == 1 ? "Armored escort: the extra Daemon starts with 6 Shield; damage reveals its intent."
|
||||
: "Hardened escort: the extra Daemon has +4 Uptime; damage reveals its intent.";
|
||||
plan = new EncounterPlan(title + " / challenge", advice + " " + detail, baseline.UptimeBonus, escort.ToArray())
|
||||
{ EscortShield = modifier == 1 ? 6 : 0, EscortUptime = modifier == 2 ? 4 : 0 };
|
||||
}
|
||||
return plan;
|
||||
}
|
||||
|
||||
public static EncounterPlan Plan(int wave, WaveRoute route)
|
||||
{
|
||||
string title, advice;
|
||||
|
||||
@@ -122,7 +122,9 @@ namespace KernelPanic.Combat
|
||||
EnemyBehaviorFlags.ObfuscateIntent | EnemyBehaviorFlags.Elite,
|
||||
new[]
|
||||
{
|
||||
new EnemyIntent(EnemyIntentKind.Attack, 6, 8, Language.C, "daemon hit", "!")
|
||||
new EnemyIntent(EnemyIntentKind.Attack, 8, 10, Language.C, "surge", "!"),
|
||||
new EnemyIntent(EnemyIntentKind.Defend, 6, 8, Language.C, "harden", "#"),
|
||||
new EnemyIntent(EnemyIntentKind.Attack, 3, 4, Language.C, "bypass Shield", "!", true)
|
||||
},
|
||||
EnemyTier.Elite);
|
||||
|
||||
|
||||
@@ -64,6 +64,8 @@ namespace KernelPanic.Combat
|
||||
|
||||
public void PickNextIntent()
|
||||
{
|
||||
// Exposure belongs to the selected action, not the enemy's entire lifetime.
|
||||
if (HasBehavior(EnemyBehaviorFlags.ObfuscateIntent)) IntentRevealed = false;
|
||||
if (HasBehavior(EnemyBehaviorFlags.BossCycle) && _intentPool.Count > 0)
|
||||
{
|
||||
CurrentIntent = _intentPool[TurnsAlive % _intentPool.Count];
|
||||
|
||||
Reference in New Issue
Block a user