using System; namespace Game { /// /// Represents the state of the game after reaching a ceasefire. /// public sealed class Ceasefire : WarState { /// /// Gets a flag indicating whether the player achieved absolute victory. /// public override bool IsAbsoluteVictory { get; } /// /// Gets the outcome of the war. /// public override WarResult? FinalOutcome { get { if (IsAbsoluteVictory || PlayerForces.TotalTroops > 3 / 2 * ComputerForces.TotalTroops) return WarResult.PlayerVictory; else if (PlayerForces.TotalTroops < 2 / 3 * ComputerForces.TotalTroops) return WarResult.ComputerVictory; else return WarResult.PeaceTreaty; } } /// /// Initializes a new instance of the Ceasefire class. /// /// /// The computer's forces. /// /// /// The player's forces. /// /// /// Indicates whether the player acheived absolute victory (defeating /// the computer without destroying its military). /// public Ceasefire(ArmedForces computerForces, ArmedForces playerForces, bool absoluteVictory = false) : base(computerForces, playerForces) { IsAbsoluteVictory = absoluteVictory; } protected override (WarState nextState, string message) AttackWithArmy(int attackSize) => throw new InvalidOperationException("THE WAR IS OVER"); protected override (WarState nextState, string message) AttackWithNavy(int attackSize) => throw new InvalidOperationException("THE WAR IS OVER"); protected override (WarState nextState, string message) AttackWithAirForce(int attackSize) => throw new InvalidOperationException("THE WAR IS OVER"); } }