You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
4.3 KiB
123 lines
4.3 KiB
using CoreLibrary;
|
|
|
|
namespace ConsoleApp
|
|
{
|
|
public class Utils
|
|
{
|
|
private readonly static Dictionary<Couleur, ConsoleColor> couleursTerminal = new Dictionary<Couleur, ConsoleColor>()
|
|
{
|
|
{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<Indicateur, ConsoleColor> indicateursTerminal = new Dictionary<Indicateur, ConsoleColor>()
|
|
{
|
|
{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<IEnumerable<Jeton?>> grille, IEnumerable<IEnumerable<Indicateur>> indicateurs)
|
|
{
|
|
IEnumerable<Jeton?>[] grilleTableau = (IEnumerable<Jeton?>[])grille.ToArray();
|
|
IEnumerable<Indicateur>[] indicateursTableau = (IEnumerable<Indicateur>[])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("──────────────── ────────────────");
|
|
}
|
|
}
|
|
}
|