Initial commit

This commit is contained in:
Grizouille
2025-12-06 09:14:15 +01:00
commit ac3dbe4169
12 changed files with 454 additions and 0 deletions

53
MiniJeux/MiniJeux.sln Normal file
View File

@@ -0,0 +1,53 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniJeux", "MiniJeux\MiniJeux.csproj", "{5BA674C8-192C-47C8-8F50-F9F17A762B2C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniJeux.Test", "Tests\MiniJeux.Test\MiniJeux.Test.csproj", "{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|x64.ActiveCfg = Debug|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|x64.Build.0 = Debug|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|x86.ActiveCfg = Debug|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Debug|x86.Build.0 = Debug|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|Any CPU.Build.0 = Release|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|x64.ActiveCfg = Release|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|x64.Build.0 = Release|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|x86.ActiveCfg = Release|Any CPU
{5BA674C8-192C-47C8-8F50-F9F17A762B2C}.Release|x86.Build.0 = Release|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|x64.ActiveCfg = Debug|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|x64.Build.0 = Debug|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|x86.ActiveCfg = Debug|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Debug|x86.Build.0 = Debug|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|Any CPU.Build.0 = Release|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|x64.ActiveCfg = Release|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|x64.Build.0 = Release|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|x86.ActiveCfg = Release|Any CPU
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{09AF8FA9-D62B-45DB-AC87-0BAE32811EAC} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,87 @@
using System;
public class Pendu
{
public Pendu()
{
Start();
}
private void Start()
{
string[] mots = { "ordinateur", "programmation", "developpement", "algorithmie", "variable" };
Random random = new Random();
string motSecret = mots[random.Next(0, mots.Length)];
char[] lettresTrouvees = new char[motSecret.Length];
for (int i = 0; i < lettresTrouvees.Length; i++)
{
lettresTrouvees[i] = '_';
}
int vies = 7;
bool motComplet = false;
Console.WriteLine("=== JEU DU PENDU ===");
Console.WriteLine($"Le mot a {motSecret.Length} lettres");
while (vies > 0 && !motComplet)
{
// Afficher l'état actuel
Console.WriteLine($"\nVies restantes : {vies}");
Console.WriteLine("Mot : " + string.Join(" ", lettresTrouvees));
// Demander une lettre
Console.Write("Propose une lettre : ");
var infoLettre = Console.ReadLine();//.KeyChar;
var lettre = infoLettre[0];
// Vérifier si la lettre est dans le mot
bool lettreTrouvee = false;
for (int i = 0; i < motSecret.Length; i++)
{
if (motSecret[i] == lettre)
{
lettresTrouvees[i] = lettre;
lettreTrouvee = true;
}
}
if (!lettreTrouvee)
{
vies--;
Console.WriteLine($"❌ La lettre '{lettre}' n'est pas dans le mot.");
}
else
{
Console.WriteLine($"✅ Bonne lettre !");
}
// Vérifier si le mot est complet
motComplet = true;
foreach (char c in lettresTrouvees)
{
if (c == '_')
{
motComplet = false;
break;
}
}
}
// Résultat final
if (motComplet)
{
Console.WriteLine($"\n🎉 FÉLICITATIONS ! Tu as trouvé le mot : {motSecret}");
}
else
{
Console.WriteLine($"\n💀 PERDU ! Le mot était : {motSecret}");
}
Console.WriteLine("\nAppuyez sur une touche pour quitter...");
Console.ReadLine();
}
}

64
MiniJeux/MiniJeux/Ppc.cs Normal file
View File

@@ -0,0 +1,64 @@
public class Ppc
{
private static readonly Dictionary<string, int> Scores = new Dictionary<string, int>()
{
{"joueur", 0},
{"ordi", 0}
};
public Ppc()
{
Console.WriteLine("Bienvenue dans ");
Console.WriteLine("✊✋✌️ Pierre-Papier-Ciseaux !");
Console.WriteLine("Premier à 3 points gagne !");
Start();
// 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 Start()
{
var random = new Random();
var choix_possibles = new[] { "pierre", "papier", "ciseaux" };
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();
if (!choix_possibles.Contains(joueur?.ToLower()))
{
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;
}
}
}
}

View File

@@ -0,0 +1,70 @@
using System;
using System.Runtime.CompilerServices;
class Program()
{
private static readonly Dictionary<string, int> Scores = new Dictionary<string, int>()
{
{"joueur", 0},
{"ordi", 0}
};
public static void Main()
{
// new Ppc();
new Pendu();
// 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" };
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();
if (!choix_possibles.Contains(joueur?.ToLower()))
{
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;
}
}
}
}

View File

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\MiniJeux\MiniJeux.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,10 @@
namespace MiniJeux.Test;
public class PpcTest
{
[Fact]
public void Test1()
{
}
}