/
empaquetar.cpp
101 lines (79 loc) · 2.17 KB
/
empaquetar.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
100
101
#include "empaquetar.h"
Empaquetar::Empaquetar(int IDJugador, int IDjuego, bool CrearJuego, bool ActualizarJuego, bool Actualizado,
Lista *listaCambios) : IDJugador(
IDJugador), IDjuego(IDjuego), CrearJuego(CrearJuego), ActualizarJuego(ActualizarJuego), Actualizado(
Actualizado), ListaCambios(listaCambios) {}
Empaquetar::Empaquetar() {}
int Empaquetar::getIDJugador() const {
return IDJugador;
}
void Empaquetar::setIDJugador(int idjugador) {
IDJugador = idjugador;
}
int Empaquetar::getIDjuego() const {
return IDjuego;
}
void Empaquetar::setIDjuego(int idjuego) {
IDjuego = idjuego;
}
Lista *Empaquetar::getListaCambios() const {
return ListaCambios;
}
void Empaquetar::setListaCambios(Lista *listaCambios) {
ListaCambios = listaCambios;
}
bool Empaquetar::getCrearJuego() {
return CrearJuego;
}
void Empaquetar::setCrearJuego(bool crearJuego) {
CrearJuego = crearJuego;
}
bool Empaquetar::getActualizarJuego() {
return ActualizarJuego;
}
void Empaquetar::setActualizarJuego(bool actualizarJuego) {
ActualizarJuego = actualizarJuego;
}
bool Empaquetar::getActualizado() {
return Actualizado;
}
void Empaquetar::setActualizado(bool actualizado) {
Actualizado = actualizado;
}
void Empaquetar::setCambios(json cambio) {
Cambios = cambio;
}
json Empaquetar::getCambios() {
return Cambios;
}
int Empaquetar::getPuntaje() const {
return Puntaje;
}
void Empaquetar::setPuntaje(int puntaje) {
Puntaje = puntaje;
}
json Empaquetar::generarJsonEmpaquetado() {
json empa;
empa["IDPLAYER"] = getIDJugador();
empa["IDGAME"] = getIDjuego();
empa["CREATE"] = getCrearJuego();
empa["REFRESH"] = getActualizarJuego();
empa["REFRESHED"] = getActualizado();
empa["JSON"] = generarJson();
return empa;
}
json Empaquetar::generarJson() {
json j1;
Nodo *temp;
temp = ListaCambios->getHead();
int i = 1;
j1["0"] = ListaCambios->size;
while (temp != NULL) {
std::string s = std::to_string(i);
j1[s] = {{"Letra", temp->letra},
{"Posi", {temp->col, temp->fil}}};
temp = temp->next;
i++;
}
return j1;
}