using CoreLibrary; namespace ConsoleApp { public class Utils { private readonly static Dictionary couleursTerminal = new Dictionary() { {Couleur.NOIR, ConsoleColor.Black }, {Couleur.BLANC, ConsoleColor.White }, {Couleur.ROUGE, ConsoleColor.Red }, {Couleur.VERT, ConsoleColor.Green }, {Couleur.BLEU, ConsoleColor.Blue }, {Couleur.JAUNE, ConsoleColor.DarkYellow } }; private readonly static Dictionary indicateursTerminal = new Dictionary() { {Indicateur.BONNEPLACE, ConsoleColor.Black }, {Indicateur.BONNECOULEUR, ConsoleColor.White } }; public static void DessinerTitre() { Console.WriteLine(""" __ __ _ _ _ | \/ | __ _ ___| |_ ___ _ _ _ __ (_) _ _ __| | | |\/| |/ _` |(_-<| _|/ -_)| '_|| ' \ | || ' \ / _` | |_| |_|\__,_|/__/ \__|\___||_| |_|_|_||_||_||_|\__,_| """); DessinerSeparateur(); } public static void DessinerSeparateur() { Console.WriteLine(""" ─────────────────────────────────────────────────────── """); } public static void DessinerPion(Enum pion) { Console.Write(" "); Console.ForegroundColor = pion.GetType().Equals(typeof(Couleur)) ? couleursTerminal.GetValueOrDefault((Couleur)pion) : indicateursTerminal.GetValueOrDefault((Indicateur)pion); Console.BackgroundColor = Console.ForegroundColor.Equals(ConsoleColor.Black) ? ConsoleColor.White : ConsoleColor.Black; Console.Write("⬤"); Console.ResetColor(); Console.Write(" "); } public static void DessinerPlateau(IEnumerable> grille, IEnumerable> indicateurs) { IEnumerable[] grilleTableau = (IEnumerable[])grille.ToArray(); IEnumerable[] indicateursTableau = (IEnumerable[])indicateurs.ToArray(); Console.WriteLine(" Codes Indicateurs "); Console.WriteLine("──────────────── ────────────────"); Console.WriteLine("│ │ │ │"); for (int i = 0; i < grille.Count(); ++i) { Console.Write("│ "); Jeton?[] ligneGrille = grilleTableau[i].ToArray(); for (int j = 0; j < ligneGrille.Length; ++j) { Jeton? jeton = ligneGrille[j]; if (jeton.HasValue) { DessinerPion(jeton.Value.Couleur); } else { Console.Write(" "); } } Console.Write(" │ │ "); if (indicateursTableau[i] != null) { Indicateur[] ligneIndicateurs = indicateursTableau[i].ToArray(); for (int j = 0; j < ligneIndicateurs.Length; ++j) { DessinerPion(ligneIndicateurs[j]); } if (ligneIndicateurs.Length < 4) { Console.Write("".PadLeft((4 - ligneIndicateurs.Length) * 3)); } } else { Console.Write(" "); } Console.WriteLine(" │"); } Console.WriteLine("│ │ │ │"); Console.WriteLine("──────────────── ────────────────"); } } }