using System.Collections.Generic;
namespace MazeGen
{
public enum FightState
{
/// Declared, but not started yet - the join window is counting down.
Mustering,
/// Outcome is decided; if it's being watched, playback is still running.
Resolving,
Resolved,
/// Never happened (every participant left/died, or the monsters were already dead).
Cancelled
}
/// Whether a fight's outcome is just logged, or played out on the arena grid.
public enum CombatViewMode
{
Simulate,
Watch
}
///
/// A fight that has been declared in a room but hasn't started yet. The join window is the
/// whole point of this type existing: an agent that picks a fight doesn't fight immediately,
/// it commits and then waits, and during that wait other agents can walk in and pile on
/// (improving the odds) or try to sneak past.
///
public class PendingFight
{
public readonly int Id;
public readonly Room Room;
public readonly MonsterEncounter Encounter;
/// Agents committed to this fight, in join order. The first is whoever started it.
public readonly List Agents = new List();
/// Seconds of join window left. Ticks on SimulationClock time, so pausing freezes it.
public float JoinTimeRemaining;
public FightState State = FightState.Mustering;
/// Why this fight started, for the log/HUD.
public string Trigger;
/// Null until resolution.
public BattleResult Result;
/// How this fight was (or will be) resolved.
public CombatViewMode ResolvedAs;
///
/// The observer's choice of Watch/Log for when the join window naturally expires. Setting
/// this (via CombatDirector.PreferWatch/PreferSimulate) is only a preference, not a trigger -
/// the join window always has to run out on its own first; see CombatDirector.Update.
/// Null means "use the director's default timeout resolution".
///
public CombatViewMode? PreferredResolution;
public PendingFight(int id, Room room, MonsterEncounter encounter)
{
Id = id;
Room = room;
Encounter = encounter;
}
public bool Contains(MazeAgent agent) => agent != null && Agents.Contains(agent);
public string Describe() => $"Fight #{Id} in room {Room.Id}: {Agents.Count} agent(s) vs {Encounter.AliveMonsterCount} monster(s)";
}
}