CombatEvent.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System.Collections.Generic;
  2. namespace MazeGen
  3. {
  4. public enum CombatEventKind
  5. {
  6. FightStart,
  7. RoundStart,
  8. Hit,
  9. Miss,
  10. Death,
  11. FightEnd
  12. }
  13. /// <summary>
  14. /// One atomic thing that happened during a battle. A resolved battle is nothing but an
  15. /// ordered list of these.
  16. ///
  17. /// This is the seam that lets "just log it" and "watch it on a grid" share one outcome: the
  18. /// resolver runs to completion up front and emits this list, log-only mode prints it, and the
  19. /// arena replays the exact same list as animation. The view therefore cannot desync from the
  20. /// simulation, and switching modes can never change who wins.
  21. /// </summary>
  22. public class CombatEvent
  23. {
  24. public CombatEventKind Kind;
  25. public int Round;
  26. /// <summary>Combatant id of whoever acted, or -1 for battle/round-level events.</summary>
  27. public int ActorId = -1;
  28. /// <summary>Combatant id of whoever was acted upon, or -1.</summary>
  29. public int TargetId = -1;
  30. /// <summary>Damage dealt (Hit), or the target's remaining health (Death).</summary>
  31. public float Amount;
  32. /// <summary>Pre-rendered log line, so the log/thought/feed surfaces don't each re-describe it.</summary>
  33. public string Text;
  34. }
  35. public enum BattleOutcome
  36. {
  37. AgentsVictory,
  38. MonstersVictory,
  39. Stalemate
  40. }
  41. /// <summary>The complete, already-decided result of one battle.</summary>
  42. public class BattleResult
  43. {
  44. public BattleOutcome Outcome;
  45. public int Rounds;
  46. public readonly List<CombatEvent> Events = new List<CombatEvent>();
  47. public IReadOnlyList<Combatant> Combatants;
  48. /// <summary>Agents who were reduced to 0 health in this battle.</summary>
  49. public readonly List<Combatant> FallenAgents = new List<Combatant>();
  50. /// <summary>Monsters killed in this battle.</summary>
  51. public readonly List<Combatant> FallenMonsters = new List<Combatant>();
  52. /// <summary>Agents still standing when the battle ended.</summary>
  53. public readonly List<Combatant> SurvivingAgents = new List<Combatant>();
  54. public string Summary
  55. {
  56. get
  57. {
  58. switch (Outcome)
  59. {
  60. case BattleOutcome.AgentsVictory:
  61. return $"Agents won in {Rounds} round(s) - {FallenMonsters.Count} monster(s) killed, {FallenAgents.Count} agent(s) lost.";
  62. case BattleOutcome.MonstersVictory:
  63. return $"Monsters won in {Rounds} round(s) - all {FallenAgents.Count} agent(s) died.";
  64. default:
  65. return $"Stalemate after {Rounds} round(s) - both sides still standing, everyone disengages.";
  66. }
  67. }
  68. }
  69. }
  70. }