using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Model.Dice; using Model.Dice.Faces; using Model.Players; namespace Model.Games { public class GameRunner { private readonly IManager globalPlayerManager; private readonly IManager>>> globalDieManager; private readonly List games; public GameRunner(IManager globalPlayerManager, IManager>>> globalDieManager, List games) { this.globalPlayerManager = globalPlayerManager; this.globalDieManager = globalDieManager; this.games = games ?? new(); } public IEnumerable GetAll() => games.AsEnumerable(); /// /// finds the game with that name and returns it ///
/// that copy does not belong to this gamerunner's games, so it should not be modified ///
/// a games's name /// game with said name, or null if no such game was found public Game GetOneGameByName(string name) { if (!string.IsNullOrWhiteSpace(name)) { Game result = games.FirstOrDefault(g => g.Name == name); return result; // may return null } throw new ArgumentException("param should not be null or blank", nameof(name)); } } }