-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay_waitingForAI.cpp
More file actions
129 lines (117 loc) · 4.47 KB
/
Copy pathdisplay_waitingForAI.cpp
File metadata and controls
129 lines (117 loc) · 4.47 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// display_waitingForAI.h
#include <iostream>
#include <string>
#include <unistd.h> // For the calling of sleep()
#include "selfDefStruct.h" // For the calling of self-defined structures (UNO, playedUNO, listOfCards)
#include "display_waitingForAI.h" // Allow other programs to call this function via the header file
using namespace std;
void display_waitingForAI(playedUNO currentCard, int AIIndex, ListOfCards player[], int numOfPlayers) {
system("clear");
// // DEBUG USE
// cout << "DEBUG:" << endl;
// for ( int i = 0 ; i < numOfPlayers ; i++ ) {
// cout << i << ": ";
// for ( int j = 0 ; j < player[i].card.size() ; j++ ) {
// cout << player[i].card[j].col << player[i].card[j].num << " ";
// }
// cout << endl;
// }
// cout << endl;
int *numOfCards = new int[numOfPlayers];
for ( int i = 0 ; i < numOfPlayers ; i++ ) {
// Count the number of cards
numOfCards[i] = player[i].card.size();
}
//1 Print the number of AI and which AI is playing on the top
cout << "Current player (number of cards left) :" << endl;
cout << "You(" << numOfCards[0] << ")";
for ( int i = 2 ; i < numOfPlayers + 1 ; i++ ) {
if ( (AIIndex + 1) == i )
cout << " \033[1;32;40m[AI" << i << "(" << numOfCards[i-1] << ")]\033[0m";
else
cout << " AI" << i << "(" << numOfCards[i-1] << ")";
}
cout << endl << endl;
//2 Display the latest discard
cout << "Latest discard :" <<endl;
if ( currentCard.card.col == 'n' ) {
if ( currentCard.colourToChange == 'b' )
cout << "\033[1;40;34m";
else if ( currentCard.colourToChange == 'g' )
cout << "\033[1;40;32m";
else if ( currentCard.colourToChange == 'r' )
cout << "\033[1;40;31m";
else if ( currentCard.colourToChange == 'y' )
cout << "\033[1;40;33m";
}
else if ( currentCard.card.col == 'b')
cout << "\033[1;44;37m";
else if ( currentCard.card.col == 'g')
cout << "\033[1;42;30m";
else if ( currentCard.card.col == 'r')
cout << "\033[1;41;37m";
else if ( currentCard.card.col == 'y')
cout << "\033[1;43;30m";
cout << "┌───────┐" << endl;
cout << "│ │" << endl;
cout << "│";
if ( currentCard.card.num >= '0' && currentCard.card.num <= '9' )
cout << " " << currentCard.card.num << " ";
else if ( currentCard.card.col == 'n' && currentCard.card.num == 'D')
cout << " Draw 4";
else if ( currentCard.card.num == 'W')
cout << " Wild ";
else if ( currentCard.card.num == 'D')
cout << " Draw 2";
else if ( currentCard.card.num == 'R')
cout << "Reverse";
else if ( currentCard.card.num == 'S')
cout << " Skip ";
cout << "│" << endl;
cout << "│ │" << endl;
cout << "└───────┘" << "\033[0m" << endl << endl;
//3 Display the instruction and meanings of notations
cout << "(D = Draw 2 (Draw 4 if it is white/black))" << endl;
cout << "(W = Wild)" << endl;
cout << "(R = Reverse)" << endl;
cout << "(S = Skip)" << endl;
//4 Print the cards that are held by the player currently (Organized by colours)
cout << "Your cards :" << endl;
for ( int i = 0 ; i < player[0].card.size() ; i++ ) { // Pint blue
cout << "\033[1;34m";
if ( player[0].card[i].col == 'b') {
cout << player[0].card[i].num << " ";
}
cout << "\033[0m";
}
for ( int i = 0 ; i < player[0].card.size() ; i++ ) { // Pint green
cout << "\033[1;32m";
if ( player[0].card[i].col == 'g') {
cout << player[0].card[i].num << " ";
}
cout << "\033[0m";
}
for ( int i = 0 ; i < player[0].card.size() ; i++ ) { // Pint red
cout << "\033[1;31m";
if ( player[0].card[i].col == 'r') {
cout << player[0].card[i].num << " ";
}
cout << "\033[0m";
}
for ( int i = 0 ; i < player[0].card.size() ; i++ ) { // Pint yellow
cout << "\033[1;33m";
if ( player[0].card[i].col == 'y') {
cout << player[0].card[i].num << " ";
}
cout << "\033[0m";
}
for ( int i = 0 ; i < player[0].card.size() ; i++ ) { // Pint no colour
if ( player[0].card[i].col == 'n') {
cout << player[0].card[i].num << " ";
}
}
cout << endl;
sleep(2);
delete [] numOfCards;
return;
}