Correction de l'erreur quand on retire un jeton dans un code vide, du bug d'affichage des jeux, et disparition du curseur quand demanderJeton
continuous-integration/drone/push Build is passing Details

master
Céleste BARBOSA 12 months ago
parent 3dc8dada39
commit 0880133369

@ -55,6 +55,7 @@ namespace ConsoleApp
public static Jeton? DemanderJeton(Object? sender, DemanderJetonEventArgs e) public static Jeton? DemanderJeton(Object? sender, DemanderJetonEventArgs e)
{ {
Console.TreatControlCAsInput = true; Console.TreatControlCAsInput = true;
Console.CursorVisible = false;
bool aChoisi = false; bool aChoisi = false;
int indice = 0; int indice = 0;
@ -80,21 +81,27 @@ namespace ConsoleApp
break; break;
case ConsoleKey.Escape: case ConsoleKey.Escape:
return null; if (e.Indice != 0)
{
aChoisi = true;
indice = -2;
}
break;
default: default:
break; break;
} }
if (indice < 0) if (indice == -1)
indice = couleurs.Length - 1; indice = couleurs.Length - 1;
else if (indice >= couleurs.Length) else if (indice == couleurs.Length)
indice = 0; indice = 0;
} }
Console.TreatControlCAsInput = false; Console.TreatControlCAsInput = false;
Console.CursorVisible = true;
return new Jeton(couleurs[indice]); return indice != -2 ? new Jeton(couleurs[indice]) : null;
} }
/// <summary> /// <summary>

@ -6,5 +6,11 @@ namespace CoreLibrary.Events
/// </summary> /// </summary>
public class DemanderJetonEventArgs : EventArgs public class DemanderJetonEventArgs : EventArgs
{ {
public int Indice { get; private set; }
public DemanderJetonEventArgs(int indice)
{
Indice = indice;
}
} }
} }

@ -83,7 +83,7 @@ namespace CoreLibrary
/// Méthode pour déclencher l'événement de demande d'ajout d'un jeton. /// Méthode pour déclencher l'événement de demande d'ajout d'un jeton.
/// </summary> /// </summary>
/// <returns>Le jeton demandé</returns> /// <returns>Le jeton demandé</returns>
private Jeton? QuandDemanderJeton() => DemanderJeton?.Invoke(this, new DemanderJetonEventArgs()); private Jeton? QuandDemanderJeton(int indice) => DemanderJeton?.Invoke(this, new DemanderJetonEventArgs(indice));
/// <summary> /// <summary>
/// Méthode pour déclencher l'événement d'ajout d'un joueur. /// Méthode pour déclencher l'événement d'ajout d'un joueur.
@ -197,7 +197,7 @@ namespace CoreLibrary
{ {
while (!code.EstComplet()) while (!code.EstComplet())
{ {
Jeton? jeton = QuandDemanderJeton(); Jeton? jeton = QuandDemanderJeton(code.NbJetons);
if (DemanderJeton == null) if (DemanderJeton == null)
{ {

Loading…
Cancel
Save