Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Rafa Castillo Passols
/
peponator
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ae36ff73
authored
May 15, 2025
by
Rafa Castillo Passols
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Añadida una clase para manejar mejor los mensajes del peponator
parent
64241337
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
9 deletions
lib/paginas/pantalla_juego.dart
lib/widgets/peponator_mensaje_factory.dart
lib/widgets/widgets.dart
lib/paginas/pantalla_juego.dart
View file @
ae36ff73
...
...
@@ -13,6 +13,7 @@ import 'package:peponator/widgets/peponator_mensaje.dart';
import
'package:peponator/widgets/teclado_numerico.dart'
;
import
'package:peponator/widgets/tu_mensaje.dart'
;
import
'package:peponator/widgets/widgets.dart'
;
import
'package:provider/provider.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
...
...
@@ -124,8 +125,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
));
}
mensajes
.
add
(
PeponatorMensaje
(
message:
"¡Hola! Estoy pensando en un número "
"del
$limiteInferior
al
$limiteSuperior
. ¿Te crees capaz de adivinarlo?"
));
mensajes
.
add
(
PeponetorMensajeFactory
.
mensajeInicial
(
limiteInferior
,
limiteSuperior
));
mostrarPistas
=
false
;
todasPistasBien
=
false
;
...
...
@@ -1009,14 +1009,17 @@ class _PantallaJuegoState extends State<PantallaJuego>
setState
(()
{
if
(
numeroEscogido
!
<
numeroAdivinar
){
mensajes
.
add
(
PeponetorMensajeFactory
.
respuesta
(
numeroEscogido
!,
numeroAdivinar
));
limiteInferior
=
numeroEscogido
!
+
1
;
_updateMaximum
=
false
;
}
if
(
numeroEscogido
!
>
numeroAdivinar
){
else
if
(
numeroEscogido
!
>
numeroAdivinar
){
mensajes
.
add
(
PeponetorMensajeFactory
.
respuesta
(
numeroEscogido
!,
numeroAdivinar
));
limiteSuperior
=
numeroEscogido
!
-
1
;
_updateMaximum
=
true
;
}
if
(
numeroEscogido
!
==
numeroAdivinar
){
else
{
mensajes
.
add
(
PeponetorMensajeFactory
.
victoria
(
intentos
));
victoria
=
true
;
puntuacion
=
dificultad
.
generarPuntuacion
(
intentos
);
...
...
@@ -1028,11 +1031,12 @@ class _PantallaJuegoState extends State<PantallaJuego>
}
}
// TODO: Construir respuesta de Peponator
mensajes
.
add
(
PeponatorMensaje
(
message:
"¡Hola! Estoy pensando en un número del
$limiteInferior
al
$limiteSuperior
. ¿Te crees capaz de adivinarlo?"
));
intentos
++;
if
(
intentos
==
maxIntentos
)
{
mensajes
.
add
(
PeponetorMensajeFactory
.
derrota
());
}
numeroEscogido
=
null
;
intentos
++;
espera
=
false
;
_controller
.
reset
();
...
...
lib/widgets/peponator_mensaje_factory.dart
0 → 100644
View file @
ae36ff73
import
'package:peponator/widgets/peponator_mensaje.dart'
;
abstract
class
PeponetorMensajeFactory
{
static
PeponatorMensaje
mensajeInicial
(
int
inferior
,
int
superior
)
{
return
PeponatorMensaje
(
message:
"¡Hola! Estoy pensando en un número del
$inferior
"
" al
$superior
. ¿Te crees capaz de adivinarlo?"
);
}
static
PeponatorMensaje
respuesta
(
int
intento
,
int
numAdivinar
)
{
StringBuffer
sb
=
StringBuffer
(
"El
$intento
está por "
);
sb
.
write
(
intento
<
numAdivinar
?
"debajo. "
:
"encima. "
);
sb
.
write
(
"
\n
Sigue intentándolo!"
);
return
PeponatorMensaje
(
message:
sb
.
toString
());
}
static
PeponatorMensaje
victoria
(
int
numIntentos
)
{
return
PeponatorMensaje
(
message:
"Felicidades! Lo has conseguido en
$numIntentos
intentos"
);
}
static
PeponatorMensaje
derrota
()
{
return
PeponatorMensaje
(
message:
"Que pena! La próxima lo conseguirás"
);
}
}
\ No newline at end of file
lib/widgets/widgets.dart
View file @
ae36ff73
...
...
@@ -4,4 +4,5 @@ export 'pista_widget.dart';
export
'teclado_numerico.dart'
;
export
'pantalla_pausa.dart'
;
export
'dificultad_dialog.dart'
;
export
'widget_dificultad.dart'
;
\ No newline at end of file
export
'widget_dificultad.dart'
;
export
'peponator_mensaje_factory.dart'
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment