-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd.cpp
65 lines (64 loc) · 1.71 KB
/
cmd.cpp
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
#include "cmd.h"
#include "table.h";
void Cmd::printOnConsole(Table* table, bool cls)
{
// crée une grid custom pour que peu importe la taille de la grille (qu'elle soit carré ou non)
// l'espace à l'intérieur des cases soit le même peu importe le chiffre (ou nombre) à l'intérieur de celles-ci
if (cls)
{
system("CLS");
}
cout << "score: " << table->getScore();
int maxSize = log10(4 * pow(2, (table->_sizeX * table->_sizeY)));
string preString = " ";
string verticalSeperation = " | ";
string horizontalSeperation = " ";
for (int i = 0; i < (maxSize + 4) * table->_sizeX + 1; i++)
{
horizontalSeperation += "-";
}
string horizontalEmptySeperation = verticalSeperation;
for (int i = 0; i < table->_sizeX; i++)
{
for (int i = 0; i < maxSize + 1; i++)
{
horizontalEmptySeperation += preString;
}
horizontalEmptySeperation += verticalSeperation;
}
for (int j = 0; j < table->_sizeY; j++)
{
cout << endl << horizontalSeperation;
for (int k = 0; k < ((maxSize + .5f) / 2 - .5f) / 2; k++)
{
cout << endl << horizontalEmptySeperation;
}
cout << endl << verticalSeperation;
for (int i = 0; i < table->_sizeX; i++)
{
int len = (maxSize - (table->_Cells[j][i].getValue() == 0 ? 1 : log10(table->_Cells[j][i].getValue())));
for (int k = 0; k < (len - .5f) / 2; k++)
{
cout << preString;
}
if (table->_Cells[j][i].getValue() == 0)
{
cout << " ";
}
else
{
cout << table->_Cells[j][i].getValue();
}
for (int k = 0; k < (len + .5f) / 2; k++)
{
cout << preString;
}
cout << verticalSeperation;
}
for (int k = 0; k < ((maxSize + .5f) / 2 - .5f) / 2; k++)
{
cout << endl << horizontalEmptySeperation;
}
}
cout << endl << horizontalSeperation;
}