1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bataille1
{
class Program
{
enum Couleur
{
pique,
carreau,
coeur,
trèfle
}
enum Valeur
{
Deux = 1,
Trois= 2,
Quatre = 3,
Cinq = 4,
Six = 5,
Sept = 6,
Huit = 7,
Neuf = 8,
Dix = 9,
Valet = 10,
Dame = 11,
Roi = 12,
As = 13
}
public static void Main(string[] args)
{
//tableau pour le jeu de carte
string[] JeuCarte = new string[52];
int i = 0;
//création des cartes
foreach (string name2 in Enum.GetNames(typeof(Valeur)))
{
foreach (string name in Enum.GetNames(typeof(Couleur)))
{
JeuCarte[i] = string.Format("{0} de {1}", name2, name);
i++;
}
}
//mélange des cartes et création des jeux des joueurs
Random rnd = new Random();
string[] JeuCarteRandom = JeuCarte.OrderBy(x => rnd.Next()).ToArray();
string[] Joueur1 = new string[52];
string[] Joueur2 = new string[52];
//répartition des cartes aux joueurs
int j = 0;
int k = 0;
while (j < 26)
{
Joueur1[j] = JeuCarteRandom[k];
j++;
k++;
}
j = 0;
while (j < 26)
{
Joueur2[j] = JeuCarteRandom[k];
j++;
k++;
}
//conversion des tableaux en liste
List<string> Jou1 = new List<string>(Joueur1);
List<string> Jou2 = new List<string>(Joueur2);
//jeu
Console.WriteLine("--------------Bataille---------------");
Console.ReadLine();
}
}
} |
Partager