Implement basic structure for combat system and refactor code

This commit is contained in:
2026-07-03 13:14:36 +02:00
parent 754f81eb4c
commit d98d34ec3f
78 changed files with 1212 additions and 13 deletions
+140
View File
@@ -0,0 +1,140 @@
using System;
using KernelPanic.Combat;
namespace KernelPanic.Core
{
/// <summary>
/// Provides runtime events for gameplay systems that need to observe combat and run milestones.
/// </summary>
public static class GameEvents
{
public static event Action<CardPlayedEvent> CardPlayed;
public static event Action<CardResolvedEvent> CardResolved;
public static event Action<PhaseChangedEvent> PhaseChanged;
public static event Action<DamageDealtEvent> DamageDealt;
public static event Action<WaveClearedEvent> WaveCleared;
public static event Action<RunEndedEvent> RunEnded;
public static void RaiseCardPlayed(CardPlayedEvent payload)
{
CardPlayed?.Invoke(payload);
}
public static void RaiseCardResolved(CardResolvedEvent payload)
{
CardResolved?.Invoke(payload);
}
public static void RaisePhaseChanged(PhaseChangedEvent payload)
{
PhaseChanged?.Invoke(payload);
}
public static void RaiseDamageDealt(DamageDealtEvent payload)
{
DamageDealt?.Invoke(payload);
}
public static void RaiseWaveCleared(WaveClearedEvent payload)
{
WaveCleared?.Invoke(payload);
}
public static void RaiseRunEnded(RunEndedEvent payload)
{
RunEnded?.Invoke(payload);
}
}
/// <summary>
/// Describes a card that entered a resolution track.
/// </summary>
public readonly struct CardPlayedEvent
{
public CardPlayedEvent(CardInstance card, ResolutionTrack track)
{
Card = card;
Track = track;
}
public CardInstance Card { get; }
public ResolutionTrack Track { get; }
}
/// <summary>
/// Describes a card whose effects finished resolving.
/// </summary>
public readonly struct CardResolvedEvent
{
public CardResolvedEvent(CardInstance card, ResolutionTrack track)
{
Card = card;
Track = track;
}
public CardInstance Card { get; }
public ResolutionTrack Track { get; }
}
/// <summary>
/// Describes a transition between combat phases.
/// </summary>
public readonly struct PhaseChangedEvent
{
public PhaseChangedEvent(TurnPhase previousPhase, TurnPhase nextPhase)
{
PreviousPhase = previousPhase;
NextPhase = nextPhase;
}
public TurnPhase PreviousPhase { get; }
public TurnPhase NextPhase { get; }
}
/// <summary>
/// Describes damage applied from one combatant to another.
/// </summary>
public readonly struct DamageDealtEvent
{
public DamageDealtEvent(CombatantState source, CombatantState target, int amount, Language language)
{
Source = source;
Target = target;
Amount = amount;
Language = language;
}
public CombatantState Source { get; }
public CombatantState Target { get; }
public int Amount { get; }
public Language Language { get; }
}
/// <summary>
/// Describes a completed enemy wave.
/// </summary>
public readonly struct WaveClearedEvent
{
public WaveClearedEvent(int waveNumber)
{
WaveNumber = waveNumber;
}
public int WaveNumber { get; }
}
/// <summary>
/// Describes the end of a run and its earned meta currency.
/// </summary>
public readonly struct RunEndedEvent
{
public RunEndedEvent(bool playerDied, int entropyEarned)
{
PlayerDied = playerDied;
EntropyEarned = entropyEarned;
}
public bool PlayerDied { get; }
public int EntropyEarned { get; }
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cf446c6fd7627294c9e2aa23c9b576e7
+21
View File
@@ -0,0 +1,21 @@
namespace KernelPanic.Core
{
/// <summary>
/// Identifies a programming language used as a card damage type.
/// </summary>
public enum Language
{
C,
CPlusPlus,
Rust,
Python,
JavaScript,
TypeScript,
Haskell,
Assembly,
Java,
Go,
Ruby,
PHP
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c06078e18f184c84cab3579c0e562dbe
+13
View File
@@ -0,0 +1,13 @@
namespace KernelPanic.Core
{
/// <summary>
/// Describes the rarity tier of cards and rewards.
/// </summary>
public enum Rarity
{
Common,
Rare,
Epic,
Legendary
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 542a3f97e8074ed428fd7019177f221b
+12
View File
@@ -0,0 +1,12 @@
namespace KernelPanic.Core
{
/// <summary>
/// Identifies the combat resolution track a card uses when played.
/// </summary>
public enum ResolutionTrack
{
Native,
InterpreterQueue,
LazyStack
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3b76dcac6b8cae447bb9079460692238
+15
View File
@@ -0,0 +1,15 @@
namespace KernelPanic.Core
{
/// <summary>
/// Identifies a combat status effect category.
/// </summary>
public enum StatusType
{
Segfault,
MemoryLeak,
RaceCondition,
Deprecated,
DependencyError,
Deadlock
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cbdd46dffec613346ae6191f18a94225
+15
View File
@@ -0,0 +1,15 @@
namespace KernelPanic.Core
{
/// <summary>
/// Describes the high-level phases of one combat turn.
/// </summary>
public enum TurnPhase
{
Boot,
Allocate,
Execute,
Interpret,
EnemyProcess,
GarbageCollection
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e1974726f936d0640943801549b4574e