-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilidades.cpp
99 lines (54 loc) · 2.93 KB
/
utilidades.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
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
#include <iostream>
#include "utilidades.h"
// -------------------------------------------------------------------------------------------
Estado_t construir_edificio_por_nombre(Andypolis& andypolis){
string nombre;
string coord_x, coord_y;
Estado_t estado = OK;
cout << TAB << SUBRAYADO << MSJ_INGRESO_EDIFICIO_CONSTRUIR << FIN_DE_FORMATO << endl;
cout << "> ";
getline(cin, nombre);
if(!andypolis.esta_edificio(nombre))
return ERROR_EDIFICIO_INEXISTENTE;
cout << endl << TAB << SUBRAYADO << "Ingrese las coordenadas donde quiere construir el edificio:" << FIN_DE_FORMATO << endl;
cout << "Coordenada x > "; getline(cin, coord_x);
cout << endl << "Coordenada y > "; getline(cin, coord_y);
if(!es_un_numero(coord_x) || !es_un_numero(coord_y))
return ERROR_PAR_COORDENADAS_INVALIDAS;
estado = andypolis.construir_edificio_en_coord(nombre, stoi(coord_x), stoi(coord_y));
return estado;
}
// -------------------------------------------------------------------------------------------
Estado_t consultar_coordenada(const Andypolis &andypolis){
Estado_t estado = OK;
string coord_x, coord_y;
cout << TAB << SUBRAYADO << "Ingrese las coordenadas que quiere consultar:" << FIN_DE_FORMATO << endl;
cout << "Coordenada x > "; getline(cin, coord_x);
cout << endl << "Coordenada y > "; getline(cin, coord_y); cout << endl;
if(!es_un_numero(coord_x) || !es_un_numero(coord_y))
return ERROR_PAR_COORDENADAS_INVALIDAS;
estado = andypolis.consultar_casillero_de_mapa(stoi(coord_x),stoi(coord_y));
return estado;
}
// -------------------------------------------------------------------------------------------
Estado_t demoler_edificio_por_coordenada(Andypolis& andypolis){
Estado_t estado = OK;
string coord_x, coord_y;
cout << TAB << SUBRAYADO << "Ingrese la coordenadas del edificio que quiere demoler:" << FIN_DE_FORMATO << endl;
cout << "Coordenada x > "; getline(cin, coord_x);
cout << endl << "Coordenada y > "; getline(cin, coord_y); cout << endl;
if(!es_un_numero(coord_x) || !es_un_numero(coord_y))
return ERROR_PAR_COORDENADAS_INVALIDAS;
estado = andypolis.destruir_edificio_de_coord(stoi(coord_x), stoi(coord_y));
return estado;
}
// -------------------------------------------------------------------------------------------
Estado_t lluvia_de_recursos(Andypolis& andypolis){
Estado_t estado;
int cantidad_lluvia_piedra, cantidad_lluvia_madera, cantidad_lluvia_metal;
cantidad_lluvia_piedra = rand() % RAND_MAX_PIEDRA + 1;
cantidad_lluvia_madera = rand() % RAND_MAX_MADERA;
cantidad_lluvia_metal = rand() % RAND_MAX_METAL + 2;
estado = andypolis.posicionar_lluvia_de_recursos( cantidad_lluvia_piedra, cantidad_lluvia_madera, cantidad_lluvia_metal);
return estado;
}