Newer
Older
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "initialisation.h"
int NBjoueur;
void NbJoueurs()
{
printf("Veuillez-vous saisir le nombre des joueurs au debut:");
scanf("%d",&NBjoueur);
while (!(NBjoueur<=NombreMaxJoueurs)&&(NBjoueur>0))
{
printf("Le nombre de joueurs n'est pas valide! Veuillez-vous resaisir:");
scanf("%d",&NBjoueur);
}
return;
}
PJoueur JoueurSaisie()
{
int i;
printf("Veuillez-vous numeroter selon votre position.\n Appuyer sur Enter pour finir la saisie \n Remarque: La personne a votre gauche correspond a numero suivant.\n");
PJoueur p,q,head;
head=(PJoueur)malloc(sizeof(Joueur));
printf("Le nom du joueur N 0:");
getchar();
fgets(head->nom,20,stdin);
p=head;
printf("[DEBUG] Player's name: %s", p->nom);
for(i=1; i<NBjoueur; i++)
{
q=(PJoueur)malloc(sizeof(Joueur));
printf("Le nom du joueur N %d:",i);
fgets(q->nom,20,stdin);
p->next=q;
p=q;
}
p->next=head;
return head;
}
int RandomDes(int a,int NbFace)
{
srand ((unsigned int)time(NULL)+a);
return (rand()%NbFace+1);
}
PJoueur LePremier(PJoueur b)
{
int num=RandomDes(0,NBjoueur)-1;
printf("On a choisi par harsard le numero %d comme le permier joueur\n",num);
return AvanceListe(b,num);
}
PJoueur AvanceListe(PJoueur c,int d)
{
for(int i=0; i<d; i++) c=c->next;
return c;
}
void DistriDes(PJoueur p)
{
char t,u;
int k,n=1;
printf("Nous commencons a distribuer les des. Le premier joueur doit etre devant l'ecran.\n");
for (int i=0; i<NBjoueur; i++)
{
while(1)
{
printf("Veuillez le joueur %s \rpresenter devant l'ecran! Vous etes le joueur %s? Y/N\n",p->nom,p->nom);
scanf(" %c",&t);
if(t=='y'||t=='Y')break;
}
printf("Votre resultat est:\n");
for (int j=0; j<5; j++)
{
p->Des[j]=RandomDes(j*n,6);
printf("%d ",p->Des[j]);
n++;
}
while(1)
{
printf("Passer au joueur suivant? Y/N");
scanf(" %c",&u);
if(u=='y'||u=='Y')break;
}
p=p->next;
system("clear");
}
}