Ajout dans trash
This commit is contained in:
66
Correction/MiniJeuxFinal/Games/Trash/Ppc0.cs
Normal file
66
Correction/MiniJeuxFinal/Games/Trash/Ppc0.cs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
namespace MiniJeuxFinal.Games.Trash
|
||||||
|
{
|
||||||
|
internal class Ppc0
|
||||||
|
{
|
||||||
|
private static Dictionary<string, int> _scores;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Bienvenue dans ");
|
||||||
|
Console.WriteLine("✊✋✌️ Pierre-Papier-Ciseaux !");
|
||||||
|
Console.WriteLine("Premier à 3 points gagne !");
|
||||||
|
PierrePapierCiseaux();
|
||||||
|
// Résultat final
|
||||||
|
Console.WriteLine($"\n{(_scores["joueur"] == 3 ? "🎉 TU AS GAGNÉ !" : "😢 L\'ordinateur a gagné...")}");
|
||||||
|
Console.WriteLine($"Score final : {_scores["joueur"]} - {_scores["ordi"]}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static void PierrePapierCiseaux()
|
||||||
|
{
|
||||||
|
var random = new Random();
|
||||||
|
var choix_possibles = new[] { "pierre", "papier", "ciseaux" };
|
||||||
|
_scores = new Dictionary<string, int>()
|
||||||
|
{
|
||||||
|
{"joueur", 0},
|
||||||
|
{"ordi", 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
// On boucle à jusqu'a que le joueur ou l'utilisateur arrive à 3.
|
||||||
|
while (_scores["joueur"] < 3 && _scores["ordi"] < 3)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"\nScore : Toi {_scores["joueur"]} - {_scores["ordi"]} Ordinateur");
|
||||||
|
Console.WriteLine("Choisis (pierre, papier, ciseaux) : ");
|
||||||
|
var joueur = Console.ReadLine().ToLower();
|
||||||
|
if (!choix_possibles.Contains(joueur))
|
||||||
|
{
|
||||||
|
Console.WriteLine("❌ Choix invalide !");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ordi = random.GetItems(choix_possibles, 1).FirstOrDefault();
|
||||||
|
Console.WriteLine($"🤖 L'ordinateur a choisi : {ordi}");
|
||||||
|
// Déterminer le gagnant
|
||||||
|
if (joueur == ordi)
|
||||||
|
{
|
||||||
|
Console.WriteLine("✨ Égalité !");
|
||||||
|
}
|
||||||
|
else if ((joueur == "pierre" && ordi == "ciseaux") ||
|
||||||
|
(joueur == "papier" && ordi == "pierre") ||
|
||||||
|
(joueur == "ciseaux" && ordi == "papier"))
|
||||||
|
{
|
||||||
|
Console.WriteLine("✅ Tu gagnes cette manche !");
|
||||||
|
_scores["joueur"] += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("❌ L'ordinateur gagne cette manche !");
|
||||||
|
_scores["ordi"] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
Console.WriteLine("✊✋✌️ Pierre-Papier-Ciseaux !");
|
Console.WriteLine("✊✋✌️ Pierre-Papier-Ciseaux !");
|
||||||
Console.WriteLine("Premier à 3 points gagne !");
|
Console.WriteLine("Premier à 3 points gagne !");
|
||||||
PierrePapierCiseaux();
|
PierrePapierCiseaux();
|
||||||
|
|
||||||
// Résultat final
|
// Résultat final
|
||||||
Console.WriteLine($"\n{(_scores["joueur"] == 3 ? "🎉 TU AS GAGNÉ !" : "😢 L\'ordinateur a gagné...")}");
|
Console.WriteLine($"\n{(_scores["joueur"] == 3 ? "🎉 TU AS GAGNÉ !" : "😢 L\'ordinateur a gagné...")}");
|
||||||
Console.WriteLine($"Score final : {_scores["joueur"]} - {_scores["ordi"]}");
|
Console.WriteLine($"Score final : {_scores["joueur"]} - {_scores["ordi"]}");
|
||||||
|
|||||||
Reference in New Issue
Block a user