using System.Collections.Generic;
private static Random _rng = new Random();
public static void Main()
var events = new List<IGameEvent>()
{new GameEvent("Sudden death", "Random player suddenly dies.", () => RandomPlayerDies(playerCount)), new GameEvent("Ethernal success", "Random player wins the game.", () => RandomPlayerWins(playerCount))};
var activeEvent = events[_rng.Next(events.Count)];
Console.WriteLine(activeEvent.Title);
Console.WriteLine(activeEvent.Description);
var isSuccess = activeEvent.Execute();
Console.WriteLine("Event requrements not met.");
private static bool RandomPlayerDies(int playerCount)
var result = _rng.Next(2) != 0;
Console.WriteLine($"Player {_rng.Next(1, playerCount + 1):D} immediately dies.");
private static bool RandomPlayerWins(int playerCount)
var result = _rng.Next(2) != 0;
Console.WriteLine($"That's it. Player {_rng.Next(1, playerCount + 1):D} won.");
private static bool RandomlyExecutedAction()
return _rng.Next(2) != 0;
public interface IGameEvent
string Description { get; }
public class GameEvent : IGameEvent
private Func<bool> _action;
public string Title { get; init; }
public string Description { get; init; }
public GameEvent(string title, string description, Func<bool> action)
Description = description;