Gamificación

This commit is contained in:
2026-05-09 17:24:46 +02:00
parent dcecee805b
commit e2cebafdbb
29 changed files with 877 additions and 58 deletions

View File

@@ -7,6 +7,8 @@ class Usuario {
final String? foto;
final String? creadoPorClienteId;
final String? clienteIdSeleccionado;
final int fuego;
final List<String> medallas;
Usuario({
required this.id,
@@ -16,6 +18,8 @@ class Usuario {
this.foto,
this.creadoPorClienteId,
this.clienteIdSeleccionado,
this.fuego = 0,
this.medallas = const [],
});
bool get estaSeleccionado => clienteIdSeleccionado != null;
@@ -29,6 +33,8 @@ class Usuario {
String? foto,
String? creadoPorClienteId,
String? clienteIdSeleccionado,
int? fuego,
List<String>? medallas,
bool liberarSeleccion = false,
}) {
return Usuario(
@@ -41,6 +47,8 @@ class Usuario {
clienteIdSeleccionado: liberarSeleccion
? null
: (clienteIdSeleccionado ?? this.clienteIdSeleccionado),
fuego: fuego ?? this.fuego,
medallas: medallas ?? this.medallas,
);
}
@@ -53,6 +61,8 @@ class Usuario {
if (creadoPorClienteId != null) 'creadoPorClienteId': creadoPorClienteId,
if (clienteIdSeleccionado != null)
'clienteIdSeleccionado': clienteIdSeleccionado,
if (fuego > 0) 'fuego': fuego,
if (medallas.isNotEmpty) 'medallas': medallas,
};
factory Usuario.fromJson(Map<String, dynamic> json) => Usuario(
@@ -63,5 +73,9 @@ class Usuario {
foto: json['foto'] as String?,
creadoPorClienteId: json['creadoPorClienteId'] as String?,
clienteIdSeleccionado: json['clienteIdSeleccionado'] as String?,
fuego: (json['fuego'] as num?)?.toInt() ?? 0,
medallas: (json['medallas'] as List<dynamic>? ?? const [])
.map((valor) => valor.toString())
.toList(),
);
}