Gamificación
This commit is contained in:
@@ -85,6 +85,8 @@ class ServicioNearby extends ChangeNotifier {
|
||||
String? _miNombre;
|
||||
String? _miNick;
|
||||
String? _miAvatar;
|
||||
int _miFuego = 0;
|
||||
List<String> _miMedallas = const [];
|
||||
|
||||
final Map<String, JugadorConectado> _jugadores = {};
|
||||
final List<OnMensajeCallback> _listeners = [];
|
||||
@@ -213,6 +215,8 @@ class ServicioNearby extends ChangeNotifier {
|
||||
String miNombre, {
|
||||
String? miNick,
|
||||
String? miAvatar,
|
||||
int miFuego = 0,
|
||||
List<String> miMedallas = const [],
|
||||
}) async {
|
||||
if (_conectado ||
|
||||
_anunciando ||
|
||||
@@ -245,6 +249,8 @@ class ServicioNearby extends ChangeNotifier {
|
||||
foto: miAvatar,
|
||||
creadoPorClienteId: _hostClientId,
|
||||
clienteIdSeleccionado: _hostClientId,
|
||||
fuego: miFuego,
|
||||
medallas: miMedallas,
|
||||
);
|
||||
_estadoSala!.crearUsuario(usuarioHost);
|
||||
_sincronizarPoolDesdeSala();
|
||||
@@ -281,10 +287,14 @@ class ServicioNearby extends ChangeNotifier {
|
||||
String miNombre, {
|
||||
String? miNick,
|
||||
String? miAvatar,
|
||||
int miFuego = 0,
|
||||
List<String> miMedallas = const [],
|
||||
}) async {
|
||||
_miNombre = miNombre;
|
||||
_miNick = miNick;
|
||||
_miAvatar = miAvatar;
|
||||
_miFuego = miFuego;
|
||||
_miMedallas = miMedallas;
|
||||
|
||||
try {
|
||||
final resultado = await Nearby().startDiscovery(
|
||||
@@ -312,10 +322,14 @@ class ServicioNearby extends ChangeNotifier {
|
||||
String miNombre, {
|
||||
String? miNick,
|
||||
String? miAvatar,
|
||||
int miFuego = 0,
|
||||
List<String> miMedallas = const [],
|
||||
}) async {
|
||||
_miNombre = miNombre;
|
||||
_miNick = miNick;
|
||||
_miAvatar = miAvatar;
|
||||
_miFuego = miFuego;
|
||||
_miMedallas = miMedallas;
|
||||
try {
|
||||
await Nearby().requestConnection(
|
||||
miNombre,
|
||||
@@ -359,6 +373,8 @@ class ServicioNearby extends ChangeNotifier {
|
||||
'nombre': _miNombre ?? 'Jugador',
|
||||
if (_miNick != null) 'nick': _miNick,
|
||||
if (_miAvatar != null) 'avatar': _miAvatar,
|
||||
'fuego': _miFuego,
|
||||
'medallas': _miMedallas,
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -515,6 +531,10 @@ class ServicioNearby extends ChangeNotifier {
|
||||
final nombre = mensaje.datos['nombre'] as String? ?? 'Jugador';
|
||||
final nick = mensaje.datos['nick'] as String?;
|
||||
final avatar = mensaje.datos['avatar'] as String?;
|
||||
final fuego = (mensaje.datos['fuego'] as num?)?.toInt() ?? 0;
|
||||
final medallas = (mensaje.datos['medallas'] as List<dynamic>? ?? const [])
|
||||
.map((valor) => valor.toString())
|
||||
.toList();
|
||||
final clientId = endpointId;
|
||||
_jugadores[endpointId] = JugadorConectado(
|
||||
endpointId: endpointId,
|
||||
@@ -528,6 +548,8 @@ class ServicioNearby extends ChangeNotifier {
|
||||
nombre: nombre,
|
||||
nick: nick,
|
||||
avatar: avatar,
|
||||
fuego: fuego,
|
||||
medallas: medallas,
|
||||
);
|
||||
|
||||
enviarMensaje(
|
||||
@@ -555,6 +577,8 @@ class ServicioNearby extends ChangeNotifier {
|
||||
required String nombre,
|
||||
String? nick,
|
||||
String? avatar,
|
||||
int fuego = 0,
|
||||
List<String> medallas = const [],
|
||||
}) {
|
||||
final sala = _estadoSala;
|
||||
if (sala == null || sala.fase != FaseSalaMultijugador.lobby) return;
|
||||
@@ -579,6 +603,8 @@ class ServicioNearby extends ChangeNotifier {
|
||||
avatar: avatar,
|
||||
foto: avatar,
|
||||
creadoPorClienteId: clientId,
|
||||
fuego: fuego,
|
||||
medallas: medallas,
|
||||
);
|
||||
final resultadoCrear = sala.crearUsuario(usuario);
|
||||
if (!resultadoCrear.exitoso) return;
|
||||
@@ -769,6 +795,8 @@ class ServicioNearby extends ChangeNotifier {
|
||||
bool seleccionar = true,
|
||||
String? nick,
|
||||
String? avatar,
|
||||
int fuego = 0,
|
||||
List<String> medallas = const [],
|
||||
}) async {
|
||||
final nombreLimpio = nombre.trim();
|
||||
if (nombreLimpio.isEmpty) return;
|
||||
@@ -780,6 +808,8 @@ class ServicioNearby extends ChangeNotifier {
|
||||
avatar: avatar,
|
||||
foto: avatar,
|
||||
creadoPorClienteId: clientId,
|
||||
fuego: fuego,
|
||||
medallas: medallas,
|
||||
);
|
||||
if (_esHost && _estadoSala != null && clientId != null) {
|
||||
final resultado = _estadoSala!.crearUsuario(usuario);
|
||||
@@ -979,6 +1009,8 @@ class ServicioNearby extends ChangeNotifier {
|
||||
_miNombre = null;
|
||||
_miNick = null;
|
||||
_miAvatar = null;
|
||||
_miFuego = 0;
|
||||
_miMedallas = const [];
|
||||
_palabraRecibida = null;
|
||||
_soyImpostor = null;
|
||||
_faseActual = null;
|
||||
|
||||
Reference in New Issue
Block a user