Update flavor text and balance some stuff
This commit is contained in:
@@ -287,6 +287,41 @@ namespace KernelPanic.Combat
|
||||
Add("shop_go_select", Single, false, "deal 3 damage per active goroutine as one hit (base cap 9).", Go(GoOperation.Select));
|
||||
Add("shop_go_num_goroutines", None, false, "draw 1 per active goroutine (fixed cap 3; limited by free RAM).", Go(GoOperation.NumGoroutines));
|
||||
|
||||
// Repository expansion: the established languages each have eight shop choices.
|
||||
Add("shop_c_memcpy", Single, true, "deal {amount:0}." + CRecoil + " draw 1 (fixed).", Damage(6, Language.C), Fx(CardEffectKind.FixedDraw, 1));
|
||||
Add("shop_c_memset", All, true, "deal {amount:0} to all enemies." + CRecoil, Damage(4, Language.C, all: true));
|
||||
Add("shop_c_realloc", Single, true, "deal {amount:0}." + CRecoil + " then repair up to {amount:1} corrupted cards in your active deck.", Damage(12, Language.C), Fx(CardEffectKind.RepairCorruptedCards, 2));
|
||||
|
||||
Add("shop_py_islice", None, false, "preparation: inspect the top {inspectCount} cards. take one; others keep their order.", Py(PythonOperation.Inspect));
|
||||
Add("shop_py_deque", None, false, "preparation: immediately draw 1 (fixed). gain {shield:1} Shield.", Py(PythonOperation.Draw, 1), Shield(3));
|
||||
Add("shop_py_sum", Single, false, "payload: deal {amount:0} to a chosen enemy.", Py(PythonOperation.Print, 10));
|
||||
Add("shop_py_suppress", None, false, "payload: gain {shield:0} Shield. can be repeated or captured by automation.", Py(PythonOperation.Shield, 7));
|
||||
Add("shop_py_map", Single, false, "payload: deal {amount:0}. then draw 1 (fixed); repeats and automation copy only the damage.", Py(PythonOperation.Print, 3), Fx(CardEffectKind.FixedDraw, 1));
|
||||
|
||||
Add("shop_js_array_map", All, true, "deal {amount:0}-{max:0} to each enemy. roll separately for each target.", Damage(2, Language.JavaScript, 5, all: true));
|
||||
Add("shop_js_promise_resolve", Single, true, "deal {amount:0}-{max:0}.", Damage(1, Language.JavaScript, 4));
|
||||
Add("shop_js_try_catch", None, false, "gain {shield:0} Shield. cleanse harmful statuses.", Shield(5), Fx(CardEffectKind.Cleanse));
|
||||
Add("shop_js_json_parse", Single, true, "deal {amount:0}-{max:0}. draw 1 (fixed).", Damage(3, Language.JavaScript, 8), Fx(CardEffectKind.FixedDraw, 1));
|
||||
Add("shop_js_eval", Single, true, "deal {amount:0}-{max:0}.", Damage(0, Language.JavaScript, 30));
|
||||
|
||||
Add("shop_rs_vec_push", Single, true, "deal {amount:0}. overkill becomes Shield.", Damage(7, Language.Rust));
|
||||
Add("shop_rs_result_ok", Single, true, "deal {amount:0}. overkill becomes Shield. gain {shield:1} Shield.", Damage(4, Language.Rust), Shield(3));
|
||||
Add("shop_rs_option_take", Single, true, "deal {amount:0}. overkill becomes Shield.", Damage(3, Language.Rust));
|
||||
Add("shop_rs_mutex_lock", None, false, "gain {shield:0} Shield.", Shield(7));
|
||||
Add("shop_rs_iterator_collect", None, false, "draw 2 (fixed).", Fx(CardEffectKind.FixedDraw, 2));
|
||||
Add("shop_rs_match", Single, true, "deal {amount:0}; {secondary:0} if the previous card was Rust. overkill becomes Shield.", Fx(CardEffectKind.PreviousLanguageDamage, 5, secondary: 9, language: Language.Rust));
|
||||
Add("shop_rs_arc_clone", None, false, "copy the lowest-cost card in hand.", Fx(CardEffectKind.CopyLowestCostHandCard));
|
||||
Add("shop_rs_mem_drop", Single, true, "deal {amount:0}. overkill becomes Shield.", Damage(14, Language.Rust));
|
||||
|
||||
Add("shop_java_arraylist_add", Single, true, "uses 2 RAM. deal {amount:0}. draw 1 (fixed)." + Jit, Damage(5, Language.Java), Fx(CardEffectKind.FixedDraw, 1));
|
||||
Add("shop_java_stringbuilder_append", Single, true, "uses 2 RAM. deal {amount:0}; {secondary:0} if the previous card was Java." + Jit, Fx(CardEffectKind.PreviousLanguageDamage, 5, secondary: 9, language: Language.Java));
|
||||
Add("shop_java_require_non_null", None, false, "uses 2 RAM. gain {shield:0} Shield. advances JIT warmup.", Shield(3));
|
||||
Add("shop_java_try_finally", None, false, "uses 2 RAM. gain {shield:0} Shield. draw 1 (fixed). advances JIT warmup.", Shield(5), Fx(CardEffectKind.FixedDraw, 1));
|
||||
Add("shop_java_stream_map", All, true, "uses 2 RAM. deal {amount:0} to all enemies." + Jit, Damage(4, Language.Java, all: true));
|
||||
Add("shop_java_class_for_name", None, false, "uses 2 RAM. draw 2 (fixed). advances JIT warmup.", Fx(CardEffectKind.FixedDraw, 2));
|
||||
Add("shop_java_system_gc", None, false, "uses 2 RAM. repair up to {amount:0} corrupted cards in your active deck. gain {shield:1} Shield. advances JIT warmup.", Fx(CardEffectKind.RepairCorruptedCards, 2), Shield(4));
|
||||
Add("shop_java_jit_compile", Single, true, "uses 2 RAM. deal {amount:0}. Java cards cost 1 less this turn." + Jit, Fx(CardEffectKind.FirstToPackage, 8, language: Language.Java));
|
||||
|
||||
var byId = new Dictionary<string, CardCatalogEntry>(StringComparer.Ordinal);
|
||||
foreach (CardCatalogEntry entry in entries) byId.Add(entry.Id, entry);
|
||||
Entries = entries.AsReadOnly();
|
||||
|
||||
@@ -158,10 +158,10 @@ namespace KernelPanic.Combat
|
||||
if (operation == PythonOperation.Update && python.automation) low = high = 5;
|
||||
if (operation != PythonOperation.Zip) repeats = python.repeats;
|
||||
}
|
||||
if (operation is PythonOperation.Loop or PythonOperation.Cinnamon or PythonOperation.Unattended)
|
||||
if (operation is PythonOperation.Loop or PythonOperation.Cinnamon or PythonOperation.Unattended or PythonOperation.Shield)
|
||||
{
|
||||
int shieldBase = operation == PythonOperation.Cinnamon && python.damageBefore ? 5 : effect.Amount;
|
||||
int shieldRepeats = operation == PythonOperation.Cinnamon ? python.repeats : 1;
|
||||
int shieldRepeats = operation is PythonOperation.Cinnamon or PythonOperation.Shield ? python.repeats : 1;
|
||||
hasShield = true;
|
||||
int shieldValue = ScaledShield(shieldBase, sourceFlat, magnitude, lazy, combat);
|
||||
for (int i = 0; i < shieldRepeats; i++) targetShield = CardScaling.Add(targetShield, shieldValue);
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using KernelPanic.Core;
|
||||
|
||||
namespace KernelPanic.Combat
|
||||
{
|
||||
public sealed partial class CombatManager
|
||||
{
|
||||
public NixGovernorState Nix { get; } = new();
|
||||
public GoroutineScheduler Go { get; } = new();
|
||||
public Goroutine SelectedGoroutine { get; private set; }
|
||||
public CardInstance PendingGoroutineCard => _pendingGoroutineCard;
|
||||
private CardInstance _pendingGoroutineCard;
|
||||
private bool _switchingGovernor;
|
||||
|
||||
private void ApplyGovernorModifiers()
|
||||
{
|
||||
if (_playerState == null) return;
|
||||
_playerState.GovernorDamagePercent = Nix.DamagePercent;
|
||||
_playerState.GovernorShieldPercent = Nix.ShieldPercent;
|
||||
}
|
||||
// V5 uses the selected living enemy, otherwise the first living enemy in process order.
|
||||
private CombatantState GovernorTarget() => _selectedEnemyIndex >= 0 && _selectedEnemyIndex < _enemies.Count
|
||||
&& IsLiveGoTarget(_enemies[_selectedEnemyIndex].State) ? _enemies[_selectedEnemyIndex].State : FirstLivingGoTarget();
|
||||
public NixGovernorSwitchBlockReason GetGovernorSwitchBlockReason(NixGovernor governor)
|
||||
{
|
||||
if (_switchingGovernor) return NixGovernorSwitchBlockReason.SwitchingInProgress;
|
||||
if (TutorialGuide?.Active == true) return NixGovernorSwitchBlockReason.TutorialActive;
|
||||
if (currentPhase != TurnPhase.Execute) return NixGovernorSwitchBlockReason.OutsideExecutePhase;
|
||||
if (!CanSurrenderRun) return NixGovernorSwitchBlockReason.CombatUnavailable;
|
||||
var reason = Nix.GetSwitchBlockReason(governor, RoundNumber, _playerState.Cycles);
|
||||
if (reason != NixGovernorSwitchBlockReason.None) return reason;
|
||||
return Nix.Version >= 5 && governor == NixGovernor.Performance && GovernorTarget() == null
|
||||
? NixGovernorSwitchBlockReason.NoLivingTarget : NixGovernorSwitchBlockReason.None;
|
||||
}
|
||||
public bool CanSwitchGovernor(NixGovernor governor) =>
|
||||
GetGovernorSwitchBlockReason(governor) == NixGovernorSwitchBlockReason.None;
|
||||
public bool TrySwitchGovernor(NixGovernor governor)
|
||||
{
|
||||
var reason = GetGovernorSwitchBlockReason(governor);
|
||||
if (reason != NixGovernorSwitchBlockReason.None)
|
||||
{
|
||||
if (reason != NixGovernorSwitchBlockReason.SwitchingInProgress)
|
||||
Log($"[nixos] {reason.GetMessage()}");
|
||||
return false;
|
||||
}
|
||||
var target = GovernorTarget();
|
||||
var previous = Nix.Governor;
|
||||
_switchingGovernor = true;
|
||||
try
|
||||
{
|
||||
if (!Nix.TrySwitch(governor, RoundNumber, _playerState.Cycles, out int cost)) return false;
|
||||
_playerState.Cycles -= cost;
|
||||
ApplyGovernorModifiers();
|
||||
Log($"[nixos] governor switched: {previous.ToString().ToLowerInvariant()} -> {governor.ToString().ToLowerInvariant()}");
|
||||
if (Nix.Version >= 5)
|
||||
{
|
||||
switch (governor)
|
||||
{
|
||||
case NixGovernor.Performance:
|
||||
var hit = _damagePipeline.DealDamage(new DamageRequest(_playerState, target, 5, Language.Go, false, false, false)
|
||||
.WithCause("NixOS specialisation"));
|
||||
if (hit.TargetDefeated) QueueDefeatedCombatantForRemoval(target);
|
||||
break;
|
||||
case NixGovernor.Powersave: _playerState.Shield = CardScaling.Add(_playerState.Shield, 6); break;
|
||||
case NixGovernor.Schedutil: DrawCards(1, "nixos specialisation"); break;
|
||||
}
|
||||
}
|
||||
CheckWinOrLoss(); StateChanged?.Invoke(); return true;
|
||||
}
|
||||
finally { _switchingGovernor = false; StateChanged?.Invoke(); }
|
||||
}
|
||||
|
||||
public string GoPlayBlockReason(CardInstance card)
|
||||
{
|
||||
var operation = GoEffect.OperationFor(card);
|
||||
if (operation == GoOperation.Deploy && (!Go.HasCapacity || Go.Active.Any(g => g.SourceCard == card))) return "goroutine limit: 3 active";
|
||||
if (operation == GoOperation.Cancel && Go.Count == 0) return "no active goroutine to cancel";
|
||||
if (operation is GoOperation.Extend or GoOperation.ExtendAll && !Go.Active.Any(Go.CanExtend)) return "no goroutine can be extended";
|
||||
return null;
|
||||
}
|
||||
private bool NeedsGoSelection(CardInstance card) => GoEffect.OperationFor(card) switch
|
||||
{
|
||||
GoOperation.Cancel => Go.Count > 0,
|
||||
GoOperation.Extend or GoOperation.Rollback => Go.Active.Any(Go.CanExtend),
|
||||
_ => false
|
||||
};
|
||||
public bool IsEligibleGoSelection(Goroutine work, CardInstance card) => work?.Active == true && Go.Active.Contains(work)
|
||||
&& (GoEffect.OperationFor(card) == GoOperation.Cancel || Go.CanExtend(work));
|
||||
private bool ValidateGoPlay(CardInstance card)
|
||||
{
|
||||
string reason = GoPlayBlockReason(card);
|
||||
if (reason != null) { Log(reason); return false; }
|
||||
if (NeedsGoSelection(card) && !IsEligibleGoSelection(SelectedGoroutine, card))
|
||||
{
|
||||
_pendingGoroutineCard = card; _pendingTargetCard = null;
|
||||
Log("select a goroutine in the scheduler"); StateChanged?.Invoke(); return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void SelectGoroutine(long id)
|
||||
{
|
||||
if (!CanSurrenderRun) return;
|
||||
var work = Go.Active.FirstOrDefault(g => g.Id == id);
|
||||
if (work == null || _pendingGoroutineCard != null && !IsEligibleGoSelection(work, _pendingGoroutineCard)) return;
|
||||
SelectedGoroutine = work;
|
||||
var pending = _pendingGoroutineCard; _pendingGoroutineCard = null;
|
||||
if (pending != null && _handController.Cards.Contains(pending)) PlayCard(pending);
|
||||
StateChanged?.Invoke();
|
||||
}
|
||||
public void CancelGoroutineSelection() { _pendingGoroutineCard = null; SelectedGoroutine = null; StateChanged?.Invoke(); }
|
||||
internal void DeployGoroutine(CombatContext context, int damage, int ticks)
|
||||
{
|
||||
var work = Go.Deploy(context.Card, damage, ticks, RoundNumber, context.Targets.FirstOrDefault());
|
||||
if (work != null) Log($"[go] PID {work.Id:000} deployed / {work.RemainingTicks} ticks / starts next round");
|
||||
StateChanged?.Invoke();
|
||||
}
|
||||
private void OnGoroutineTerminated(Goroutine work)
|
||||
{
|
||||
work.SourceCard.ClearTargetSnapshot(); _deckController.Discard(work.SourceCard);
|
||||
if (SelectedGoroutine == work) SelectedGoroutine = null;
|
||||
Log($"[go] PID {work.Id:000} terminated");
|
||||
}
|
||||
private bool IsLiveGoTarget(CombatantState target) => target != null && target.CurrentUptime > 0 && !target.IsDefeated
|
||||
&& _enemies.Any(enemy => enemy.State == target && !enemy.PendingRevive);
|
||||
private CombatantState FirstLivingGoTarget() => _enemies.Select(enemy => enemy.State).FirstOrDefault(IsLiveGoTarget);
|
||||
public int GoroutineDamageAmount(Goroutine work) => CardScaling.Add(work.BaseDamage,
|
||||
CardScaling.Add(_playerState?.FlatEffectBonus ?? 0, _playerState?.FlatCardDamageBonus ?? 0));
|
||||
internal void ResolveGoroutineTick(Goroutine work)
|
||||
{
|
||||
if (!IsLiveGoTarget(work.Target)) work.Target = FirstLivingGoTarget();
|
||||
StateChanged?.Invoke();
|
||||
if (work.Target == null) { Log($"[go] PID {work.Id:000} skipped / no living target"); return; }
|
||||
var context = BuildContext(work.SourceCard, new[] { work.Target });
|
||||
CardDamageExecutor.ApplyHit(context, DamageRequest.FromCard(context, work.Target,
|
||||
GoroutineDamageAmount(work), Language.Go, false, true));
|
||||
Log($"[go] PID {work.Id:000} tick / {Math.Max(0, work.RemainingTicks - 1)} remaining");
|
||||
RemoveDefeatedEnemies();
|
||||
}
|
||||
private IEnumerator TickGoroutinesSequenced()
|
||||
{
|
||||
foreach (var work in Go.Active.ToArray())
|
||||
{
|
||||
while (VisualResolutionPending && !RunFinished && !_awaitingWaveContinue) yield return null;
|
||||
if (CheckWinOrLoss()) yield break;
|
||||
if (work.DeploymentRound < RoundNumber && work.LastTickRound < RoundNumber && work.Active)
|
||||
{
|
||||
work.Resolving = true; StateChanged?.Invoke();
|
||||
yield return null;
|
||||
}
|
||||
if (!Go.Tick(work, RoundNumber, ResolveGoroutineTick)) continue;
|
||||
StateChanged?.Invoke();
|
||||
if (CheckWinOrLoss()) yield break;
|
||||
yield return Wait(CombatTuning.QueueCardResolveDelaySeconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aaf765e970a82354a9cfc3500f4c53ce
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using KernelPanic.Core;
|
||||
|
||||
namespace KernelPanic.Combat
|
||||
{
|
||||
public enum GoOperation { None, Deploy, Extend, ExtendAll, Cancel, WaitGroup, Gosched, Select, NumGoroutines, Rollback }
|
||||
|
||||
public sealed class GoEffect : ICardEffect
|
||||
{
|
||||
private readonly GoOperation _operation;
|
||||
private readonly int _amount, _ticks;
|
||||
public GoEffect(GoOperation operation, int amount, int ticks = 0) { _operation = operation; _amount = amount; _ticks = ticks; }
|
||||
public static GoOperation OperationFor(CardInstance card) => card?.Definition != null && CardCatalog.TryGet(card.Definition.Id, out var entry)
|
||||
? (GoOperation)(entry.Effects.FirstOrDefault(effect => effect.Kind == CardEffectKind.Go)?.SecondaryAmount ?? 0) : GoOperation.None;
|
||||
public void Execute(CombatContext context)
|
||||
{
|
||||
var combat = context.CombatManager;
|
||||
var go = combat.Go;
|
||||
switch (_operation)
|
||||
{
|
||||
case GoOperation.Deploy: combat.DeployGoroutine(context, _amount, _ticks); break;
|
||||
case GoOperation.Extend: go.Extend(combat.SelectedGoroutine, _amount); break;
|
||||
case GoOperation.ExtendAll:
|
||||
foreach (var work in go.Active.ToArray()) go.Extend(work, _amount);
|
||||
break;
|
||||
case GoOperation.Cancel:
|
||||
if (go.Terminate(combat.SelectedGoroutine)) new ShieldEffect(_amount).Execute(context);
|
||||
break;
|
||||
case GoOperation.WaitGroup: new ShieldEffect(Math.Min(9, 3 * go.Count)).Execute(context); break;
|
||||
case GoOperation.Gosched:
|
||||
new FixedDrawEffect(1).Execute(context);
|
||||
if (go.Count > 0) new ShieldEffect(1).Execute(context);
|
||||
break;
|
||||
case GoOperation.Select: new DealDamageEffect(3 * go.Count, 3 * go.Count, Core.Language.Go).Execute(context); break;
|
||||
case GoOperation.NumGoroutines: new FixedDrawEffect(Math.Min(3, go.Count)).Execute(context); break;
|
||||
case GoOperation.Rollback:
|
||||
if (combat.CanPlayerReceiveCardHeal(context.Card))
|
||||
{
|
||||
int heal = UpgradeMath.ScaleAmount(UpgradeMath.ApplySourceFlatBonus(_amount, context), context.Card);
|
||||
context.Source.CurrentUptime = Math.Min(context.Source.MaxUptime, CardScaling.Add(context.Source.CurrentUptime, heal));
|
||||
}
|
||||
go.Extend(combat.SelectedGoroutine, 1);
|
||||
break;
|
||||
}
|
||||
if (_operation != GoOperation.Deploy) combat.CancelGoroutineSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc2025fa9ee44d04ead099248fc56197
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using KernelPanic.Core;
|
||||
|
||||
namespace KernelPanic.Combat
|
||||
{
|
||||
public sealed class Goroutine
|
||||
{
|
||||
public long Id { get; internal set; }
|
||||
public CardInstance SourceCard { get; internal set; }
|
||||
public string SourceInstanceId => SourceCard.InstanceId;
|
||||
public int BaseDamage { get; internal set; }
|
||||
public CombatantState Target { get; internal set; }
|
||||
public int RemainingTicks { get; internal set; }
|
||||
public int DeploymentRound { get; internal set; }
|
||||
public int LastTickRound { get; internal set; }
|
||||
public bool Active { get; internal set; }
|
||||
public bool Resolving { get; internal set; }
|
||||
}
|
||||
|
||||
/// <summary>Bounded persistent work, advanced only by the authoritative Interpret phase.</summary>
|
||||
public sealed class GoroutineScheduler
|
||||
{
|
||||
public const int Capacity = 3, MaximumTicks = 5;
|
||||
private readonly List<Goroutine> _active = new();
|
||||
private long _nextId;
|
||||
public IReadOnlyList<Goroutine> Active => _active.AsReadOnly();
|
||||
public int Count => _active.Count;
|
||||
public bool HasCapacity => Count < Capacity;
|
||||
public event Action<Goroutine> Terminated;
|
||||
public Goroutine Deploy(CardInstance card, int damage, int ticks, int round, CombatantState target)
|
||||
{
|
||||
if (card == null || !HasCapacity || ticks <= 0 || _active.Any(g => g.SourceCard == card)) return null;
|
||||
var work = new Goroutine { Id = checked(++_nextId), SourceCard = card,
|
||||
BaseDamage = CardScaling.Add(Math.Max(0, damage), card.MagnitudeBonus),
|
||||
Target = target, RemainingTicks = Math.Min(MaximumTicks, ticks), DeploymentRound = round,
|
||||
LastTickRound = round, Active = true };
|
||||
_active.Add(work);
|
||||
return work;
|
||||
}
|
||||
public bool CanExtend(Goroutine work) => work != null && _active.Contains(work) && work.RemainingTicks < MaximumTicks;
|
||||
public bool Extend(Goroutine work, int ticks)
|
||||
{
|
||||
if (!CanExtend(work) || ticks <= 0) return false;
|
||||
work.RemainingTicks = (int)Math.Min(MaximumTicks, (long)work.RemainingTicks + ticks);
|
||||
return true;
|
||||
}
|
||||
public bool Terminate(Goroutine work)
|
||||
{
|
||||
if (work == null || !_active.Remove(work)) return false;
|
||||
work.Active = false; work.Resolving = false; work.Target = null;
|
||||
Terminated?.Invoke(work); return true;
|
||||
}
|
||||
public bool Tick(Goroutine work, int round, Action<Goroutine> resolve)
|
||||
{
|
||||
if (work == null || !_active.Contains(work) || work.DeploymentRound >= round || work.LastTickRound >= round) return false;
|
||||
work.LastTickRound = round; work.Resolving = true;
|
||||
try { resolve(work); }
|
||||
finally
|
||||
{
|
||||
work.Resolving = false;
|
||||
if (work.Active && --work.RemainingTicks <= 0) Terminate(work);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void Clear() { foreach (var work in _active.ToArray()) Terminate(work); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0a7570692c134644952fcb305ab2d72
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
|
||||
namespace KernelPanic.Combat
|
||||
{
|
||||
public enum NixGovernor { Performance, Powersave, Schedutil }
|
||||
|
||||
/// <summary>Wave-local policy state. Commit only after combat validates phase and target.</summary>
|
||||
public sealed class NixGovernorState
|
||||
{
|
||||
public NixGovernor Governor { get; private set; } = NixGovernor.Schedutil;
|
||||
public int Version { get; private set; }
|
||||
public bool Active => Version > 0;
|
||||
public bool FreeSwitchUsed { get; private set; }
|
||||
public int LastSwitchRound { get; private set; } = -1;
|
||||
public int SwitchCost => Version >= 3 && !FreeSwitchUsed ? 0 : 1;
|
||||
public int DamagePercent => DamageFor(Governor);
|
||||
public int ShieldPercent => ShieldFor(Governor);
|
||||
public int DamageFor(NixGovernor governor) => governor switch
|
||||
{
|
||||
NixGovernor.Performance => !Active ? 100 : Version >= 4 ? 130 : 120,
|
||||
NixGovernor.Powersave => !Active ? 100 : 80,
|
||||
NixGovernor.Schedutil => !Active ? 100 : Version >= 2 ? 110 : 105,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(governor), governor, "Unknown governor.")
|
||||
};
|
||||
public int ShieldFor(NixGovernor governor) => governor switch
|
||||
{
|
||||
NixGovernor.Performance => !Active ? 100 : 75,
|
||||
NixGovernor.Powersave => !Active ? 100 : Version >= 4 ? 140 : 130,
|
||||
NixGovernor.Schedutil => !Active ? 100 : Version >= 2 ? 110 : 105,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(governor), governor, "Unknown governor.")
|
||||
};
|
||||
public void BeginWave(int version)
|
||||
{
|
||||
Version = Math.Max(0, Math.Min(5, version));
|
||||
Governor = NixGovernor.Schedutil;
|
||||
LastSwitchRound = -1;
|
||||
FreeSwitchUsed = false;
|
||||
}
|
||||
public NixGovernorSwitchBlockReason GetSwitchBlockReason(NixGovernor governor, int round, int cycles)
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(NixGovernor), governor)) return NixGovernorSwitchBlockReason.InvalidGovernor;
|
||||
if (!Active) return NixGovernorSwitchBlockReason.Inactive;
|
||||
if (governor == Governor) return NixGovernorSwitchBlockReason.AlreadySelected;
|
||||
if (LastSwitchRound == round) return NixGovernorSwitchBlockReason.AlreadySwitchedThisRound;
|
||||
if (cycles < SwitchCost) return NixGovernorSwitchBlockReason.InsufficientCycles;
|
||||
return NixGovernorSwitchBlockReason.None;
|
||||
}
|
||||
public bool CanSwitch(NixGovernor governor, int round, int cycles) =>
|
||||
GetSwitchBlockReason(governor, round, cycles) == NixGovernorSwitchBlockReason.None;
|
||||
public bool TrySwitch(NixGovernor governor, int round, int cycles, out int cost)
|
||||
{
|
||||
cost = 0;
|
||||
if (!CanSwitch(governor, round, cycles)) return false;
|
||||
cost = SwitchCost;
|
||||
Governor = governor;
|
||||
LastSwitchRound = round;
|
||||
FreeSwitchUsed = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0105ba7bc7169504aad48d7cf0bbbd5d
|
||||
@@ -6,7 +6,7 @@ using KernelPanic.Data;
|
||||
|
||||
namespace KernelPanic.Combat
|
||||
{
|
||||
public enum PythonOperation { Print, Loop, Draw, List, Zip, Async, Inspect, Install, Unattended, Cinnamon, Update, Timeshift }
|
||||
public enum PythonOperation { Print, Loop, Draw, List, Zip, Async, Inspect, Install, Unattended, Cinnamon, Update, Timeshift, Shield }
|
||||
|
||||
public sealed class PythonEffect : ICardEffect
|
||||
{
|
||||
@@ -75,17 +75,16 @@ namespace KernelPanic.Combat
|
||||
{
|
||||
if (previous == card) break;
|
||||
if (!IsPythonCard(previous.Definition)) continue;
|
||||
string id = previous.Definition.Id;
|
||||
if (id == "lang_py_for_loop") loops++;
|
||||
else if (id == "shop_py_zip") areas++;
|
||||
if (HasOperation(previous.Definition, PythonOperation.Loop)) loops++;
|
||||
else if (HasOperation(previous.Definition, PythonOperation.Zip)) areas++;
|
||||
else if (IsPayload(previous.Definition))
|
||||
{
|
||||
if (loops > 0) loops--;
|
||||
if (id is "lang_py_print" or "shop_py_list_append") { if (areas > 0) areas--; }
|
||||
if (id != "mint_cinnamon") damage = true;
|
||||
if (HasOperation(previous.Definition, PythonOperation.Print, PythonOperation.List) && areas > 0) areas--;
|
||||
if (HasOperation(previous.Definition, PythonOperation.Print, PythonOperation.List, PythonOperation.Update)) damage = true;
|
||||
}
|
||||
}
|
||||
return (loops > 0 ? 2 : 1, areas > 0 && card.Definition.Id is "lang_py_print" or "shop_py_list_append", damage, automated);
|
||||
return (loops > 0 ? 2 : 1, areas > 0 && HasOperation(card.Definition, PythonOperation.Print, PythonOperation.List), damage, automated);
|
||||
}
|
||||
public IEnumerable<string> Readout => new[] { $"Python: repeat {_loops.Count} | area {_areas.Count} | scripts {_scripts.Count}/2" }
|
||||
.Concat(_scripts.Select(s => s.Waiting ? $"{s.Name}: waiting for payload"
|
||||
@@ -130,9 +129,12 @@ namespace KernelPanic.Combat
|
||||
public static bool IsPythonCard(CardDefinition card) => card != null && card.Language == Language.Python
|
||||
&& !card.Effects.Any(e => e != null) && CardCatalog.TryGet(card.Id, out var entry)
|
||||
&& entry.Effects.Any(e => e.Kind == CardEffectKind.Python);
|
||||
public static bool IsPayload(CardDefinition card) => IsPythonCard(card)
|
||||
&& card.Id is "lang_py_print" or "shop_py_list_append" or "mint_cinnamon" or "mint_update_manager";
|
||||
public static bool IsAsync(CardDefinition card) => IsPythonCard(card) && card.Id == "shop_py_async_def";
|
||||
private static bool HasOperation(CardDefinition card, params PythonOperation[] operations) => IsPythonCard(card)
|
||||
&& CardCatalog.TryGet(card.Id, out var entry)
|
||||
&& entry.Effects.Any(effect => effect.Kind == CardEffectKind.Python && operations.Contains((PythonOperation)effect.SecondaryAmount));
|
||||
public static bool IsPayload(CardDefinition card) => HasOperation(card,
|
||||
PythonOperation.Print, PythonOperation.List, PythonOperation.Cinnamon, PythonOperation.Update, PythonOperation.Shield);
|
||||
public static bool IsAsync(CardDefinition card) => HasOperation(card, PythonOperation.Async);
|
||||
|
||||
public static int InspectCount(string distroId, int version) =>
|
||||
string.Equals(distroId, "ubuntu", StringComparison.OrdinalIgnoreCase) && version >= 3 ? 5 : 3;
|
||||
@@ -176,14 +178,14 @@ namespace KernelPanic.Combat
|
||||
public void Execute(CombatContext context, PythonOperation operation, int amount)
|
||||
{
|
||||
Bind(context.CombatManager);
|
||||
if (operation is PythonOperation.Print or PythonOperation.List or PythonOperation.Cinnamon or PythonOperation.Update)
|
||||
if (operation is PythonOperation.Print or PythonOperation.List or PythonOperation.Cinnamon or PythonOperation.Update or PythonOperation.Shield)
|
||||
{
|
||||
int value = amount;
|
||||
if (operation == PythonOperation.List) value = CardScaling.Add(value, (int)Math.Min(int.MaxValue, 2L * Math.Max(0, context.Card.QueuePlayCount - 1)));
|
||||
if (operation == PythonOperation.Cinnamon && DamageThisPhase) value = 5;
|
||||
if (operation == PythonOperation.Update && AutomationRan) value = 5;
|
||||
var payload = new Payload { Card = context.Card.CopyForCombat(), Target = context.Targets.FirstOrDefault(), All = operation == PythonOperation.Update };
|
||||
if (operation == PythonOperation.Cinnamon) payload.Shield = CardShieldExecutor.ScaleAmount(value, context);
|
||||
if (operation is PythonOperation.Cinnamon or PythonOperation.Shield) payload.Shield = CardShieldExecutor.ScaleAmount(value, context);
|
||||
else payload.Damage = CardDamageExecutor.ScaleAmount(value, context);
|
||||
// Capture the operation once, before applying any temporary repeat/area transformations.
|
||||
foreach (var script in _scripts.Where(s => s.Waiting))
|
||||
@@ -244,10 +246,11 @@ namespace KernelPanic.Combat
|
||||
}
|
||||
private void Inspect(CombatContext context)
|
||||
{
|
||||
string source = context.Card.Definition.DisplayName;
|
||||
var cards = context.DeckController.PeekTop(InspectCount(_combat.RunConfig?.Distro?.Id, _combat.RunConfig?.DistroVersion ?? 1)).ToArray();
|
||||
if (cards.Length == 0) { _combat.ReportEffectResult("ask ubuntu: draw pile empty"); return; }
|
||||
if (!cards.Any(context.HandController.CanAdd)) { _combat.ReportEffectResult("ask ubuntu: not enough RAM"); return; }
|
||||
Offer("ask ubuntu: choose one card; the others keep their order", cards.Select(c =>
|
||||
if (cards.Length == 0) { _combat.ReportEffectResult(source + ": draw pile empty"); return; }
|
||||
if (!cards.Any(context.HandController.CanAdd)) { _combat.ReportEffectResult(source + ": not enough RAM"); return; }
|
||||
Offer(source + ": choose one card; the others keep their order", cards.Select(c =>
|
||||
new PythonChoiceOption(c, _combat.GetDisplayedPlayCost(c),
|
||||
context.HandController.CanAdd(c) ? $"> take card / {HandController.GetRamCost(c)} RAM" : $"needs {HandController.GetRamCost(c)} free RAM",
|
||||
context.HandController.CanAdd(c))),
|
||||
|
||||
Reference in New Issue
Block a user