forked from Mici7120/code-legends
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtablero.cpp
More file actions
127 lines (109 loc) · 3.09 KB
/
tablero.cpp
File metadata and controls
127 lines (109 loc) · 3.09 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
#include "tablero.h"
Tablero::Tablero(){
}
void Tablero::Interfaz(){
int opcion;
do{
cout << "\n1. ImprimirTablero\n2. Estado Ejercitos\n3. Salir al menu\n";
cin >> opcion;
switch(opcion){
case 1:
imprimirTablero();
break;
case 2:
for(int x = 0; x<=9; x++){
for(int y = 0; y<=9; y++){
if(Puntero[x][y].tieneEjercito){
Puntero[x][y].informacionEjercito();
}
}
}
break;
}
}while(opcion != 3);
delete[]Puntero;
}
void Tablero::configurarPartida(int tipoConfiguracion){
ifstream configuracion;
int recorridoColumna = 0;
string aux;
string texto;
Puntero = new Box*[10];
*Puntero = new Box[9];
*(Puntero+1) = new Box[9];
*(Puntero+2) = new Box[9];
*(Puntero+3) = new Box[9];
*(Puntero+4) = new Box[9];
*(Puntero+5) = new Box[9];
*(Puntero+6) = new Box[9];
*(Puntero+7) = new Box[9];
*(Puntero+8) = new Box[9];
*(Puntero+9) = new Box[9];
*(Puntero+10) = new Box[9];
switch (tipoConfiguracion){
case 0:
configuracion.open("nuevaPartida.txt");
if(configuracion.fail()){
cout << "No se creo una nueva partida";
}else{
cout << "Se creo una nueva partida\n";
}
while(!configuracion.eof()){
string aux;
int recorridoRenglon = 0;
while(getline(configuracion, aux, '|')){
if(stoi(aux) == 1 || stoi(aux) == 2){
Puntero[recorridoColumna][recorridoRenglon].setTieneEjercito();
Puntero[recorridoColumna][recorridoRenglon].setID(stoi(aux));
recorridoRenglon++;
int luchadores, tiradores, magos;
cout << "Ingrese cantidad Luchadores: ";
cin >> luchadores;
cout << "Ingrese cantidad Tiradores: ";
cin >> tiradores;
cout << "Ingrese cantidad Magos: ";
cin >> magos;
Puntero[recorridoColumna][recorridoRenglon].setEjercito(luchadores, tiradores, magos);
}else{
Puntero[recorridoColumna][recorridoRenglon].setID(stoi(aux));
recorridoRenglon++;}
}
recorridoColumna ++;
}
configuracion.close();
break;
case 1:
configuracion.open("cargarPartida.txt");
if(configuracion.fail()){
cout << "No se encontro partida guardada";
}else{
cout << "Se cargo una partida\n";
}
while(!configuracion.eof()){
string aux;
int recorridoRenglon = 0;
while(getline(configuracion, aux, '|')){
if(stoi(aux) == 10 || stoi(aux) == 20){
Puntero[recorridoColumna][recorridoRenglon].setTieneEjercito();
Puntero[recorridoColumna][recorridoRenglon].setID(stoi(aux));
recorridoRenglon++;
}else{
Puntero[recorridoColumna][recorridoRenglon].setID(stoi(aux));
recorridoRenglon++;}
}
recorridoColumna ++;
}
configuracion.close();
break;
}
}
void Tablero::estadoEjercitos(){
}
void Tablero::imprimirTablero(){
for(int x = 0; x != 10; x++){
for(int y = 0; y != 10; y++){
cout << Puntero[x][y].getID() << " ";
}
cout << endl;
}
}