| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System.Collections.Generic;
- namespace MazeGen
- {
- public enum CombatEventKind
- {
- FightStart,
- RoundStart,
- Hit,
- Miss,
- Death,
- FightEnd
- }
- /// <summary>
- /// One atomic thing that happened during a battle. A resolved battle is nothing but an
- /// ordered list of these.
- ///
- /// This is the seam that lets "just log it" and "watch it on a grid" share one outcome: the
- /// resolver runs to completion up front and emits this list, log-only mode prints it, and the
- /// arena replays the exact same list as animation. The view therefore cannot desync from the
- /// simulation, and switching modes can never change who wins.
- /// </summary>
- public class CombatEvent
- {
- public CombatEventKind Kind;
- public int Round;
- /// <summary>Combatant id of whoever acted, or -1 for battle/round-level events.</summary>
- public int ActorId = -1;
- /// <summary>Combatant id of whoever was acted upon, or -1.</summary>
- public int TargetId = -1;
- /// <summary>Damage dealt (Hit), or the target's remaining health (Death).</summary>
- public float Amount;
- /// <summary>Pre-rendered log line, so the log/thought/feed surfaces don't each re-describe it.</summary>
- public string Text;
- }
- public enum BattleOutcome
- {
- AgentsVictory,
- MonstersVictory,
- Stalemate
- }
- /// <summary>The complete, already-decided result of one battle.</summary>
- public class BattleResult
- {
- public BattleOutcome Outcome;
- public int Rounds;
- public readonly List<CombatEvent> Events = new List<CombatEvent>();
- public IReadOnlyList<Combatant> Combatants;
- /// <summary>Agents who were reduced to 0 health in this battle.</summary>
- public readonly List<Combatant> FallenAgents = new List<Combatant>();
- /// <summary>Monsters killed in this battle.</summary>
- public readonly List<Combatant> FallenMonsters = new List<Combatant>();
- /// <summary>Agents still standing when the battle ended.</summary>
- public readonly List<Combatant> SurvivingAgents = new List<Combatant>();
- public string Summary
- {
- get
- {
- switch (Outcome)
- {
- case BattleOutcome.AgentsVictory:
- return $"Agents won in {Rounds} round(s) - {FallenMonsters.Count} monster(s) killed, {FallenAgents.Count} agent(s) lost.";
- case BattleOutcome.MonstersVictory:
- return $"Monsters won in {Rounds} round(s) - all {FallenAgents.Count} agent(s) died.";
- default:
- return $"Stalemate after {Rounds} round(s) - both sides still standing, everyone disengages.";
- }
- }
- }
- }
- }
|