-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
101 lines (79 loc) · 2.65 KB
/
main.c
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
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include "carta.h"
#include "funcoesDeLista.h"
#include "funcoesDeFila.h"
#include "funcoesDePilha.h"
#include "funcoesAdicionais.h"
int main()
{
setlocale(LC_ALL, "Portuguese");
Lista *mao;
mao = NULL;
mao = criarLista();
Lista **colecaoDoJogador;
colecaoDoJogador = (Lista**)malloc(sizeof(Lista*)*COLECOES);
for (int i = 0; i < COLECOES; i++){
colecaoDoJogador[i] = criarLista();
}
Fila **mesa;
mesa = (Fila**)malloc(sizeof(Lista*)*FILAS_DE_CARTAS);
for (int i = 0; i < FILAS_DE_CARTAS; i++){
mesa[i] = criarFila();
}
Pilha *baralho;
baralho = NULL;
baralho = criarPilha();
Carta cartaDeUsoGeral;
atribuirBois(&cartaDeUsoGeral, baralho);
embaralhar(baralho);
for (int i = 0; i < CARTAS_DO_JOGADOR; i++){
removerPilha(baralho,&cartaDeUsoGeral);
cartaDeUsoGeral.jogador = 1;
inserirOrenado(mao,cartaDeUsoGeral);
}
for (int i = 0; i < FILAS_DE_CARTAS; i++){
removerPilha(baralho,&cartaDeUsoGeral);
inserirFila(mesa[i],cartaDeUsoGeral);
}
Lista *cartasDaRodada;
cartasDaRodada = NULL;
cartasDaRodada = criarLista();
char nomeDoUsuario[30];
int numeroDePcs;
printf("Bem vindo! Digite seu nome: ");
scanf("%29s", nomeDoUsuario);
while( getchar() != '\n' );
do
{
printf("Digite a quantidade de jogadores, alem de voce, no jogo (1 a 9): ");
scanf("%d", &numeroDePcs);
while( getchar() != '\n' );
} while (numeroDePcs < 1 || numeroDePcs > 9);
int rodadasJogadas = 1;
while (rodadasJogadas <= RODADAS_TOTAIS){
exibirTela(mao, colecaoDoJogador[0], mesa, &nomeDoUsuario);
int cartaEscolhida;
do
{
printf("Digite o indice (de 1 a 10) da carta que quer jogar: ");
scanf("%d", &cartaEscolhida);
while( getchar() != '\n' );
} while (cartaEscolhida < 1 || cartaEscolhida > 10 || cartaEscolhida > quantidade(mao));
acessarIndice(mao, cartaEscolhida, &cartaDeUsoGeral);
removerIndice(mao, cartaEscolhida);
inserirOrenado(cartasDaRodada, cartaDeUsoGeral);
for (int i = 1; i <= numeroDePcs; i++){
removerPilha(baralho,&cartaDeUsoGeral);
cartaDeUsoGeral.jogador = i+1;
inserirOrenado(cartasDaRodada, cartaDeUsoGeral);
}
adicionarCartaNaFila(mesa, colecaoDoJogador, cartasDaRodada);
rodadasJogadas++;
}
printf("\n-------------------------");
printf("\n----- O JOGO ACABOU -----\n");
exibirPontuacao(colecaoDoJogador, numeroDePcs+1);
return 0;
}