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
c5ede89b
authored
May 15, 2025
by
Rafa Castillo Passols
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Arreglado el bug y añadido comparación a Dificultad
parent
5125893e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
6 deletions
lib/modelo/dificultad.dart
lib/paginas/pantalla_juego.dart
lib/modelo/dificultad.dart
View file @
c5ede89b
...
...
@@ -19,6 +19,7 @@ class Dificultad {
const
Dificultad
({
required
limite
,
required
maxIntentos
,
required
nombre
}):
_limite
=
limite
,
_maxIntentos
=
maxIntentos
,
_nombre
=
nombre
;
int
get
limite
=>
_limite
;
int
get
maxIntentos
=>
_maxIntentos
;
String
get
nombre
=>
_nombre
;
...
...
@@ -58,4 +59,19 @@ class Dificultad {
int
generarNumero
()
=>
Random
().
nextInt
(
limite
)
+
1
;
int
generarPuntuacion
(
int
intentos
)
=>
(
maxIntentos
-
intentos
)*
100
;
factory
Dificultad
.
copia
(
Dificultad
otro
)
{
return
Dificultad
(
limite:
otro
.
limite
,
maxIntentos:
otro
.
maxIntentos
,
nombre:
otro
.
nombre
);
}
@override
bool
operator
==(
Object
other
)
{
if
(
other
is
!
Dificultad
)
{
return
false
;
}
return
(
limite
==
other
.
limite
)
&&
(
maxIntentos
==
other
.
maxIntentos
);
}
}
\ No newline at end of file
lib/paginas/pantalla_juego.dart
View file @
c5ede89b
...
...
@@ -60,6 +60,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
late
bool
error
;
late
bool
espera
;
late
bool
victoria
;
bool
partidaEmpezada
=
false
;
late
int
puntuacion
;
late
int
posicion
;
...
...
@@ -141,17 +142,17 @@ class _PantallaJuegoState extends State<PantallaJuego>
}
void
_cambiarDificultadPausa
()
async
{
Dificultad
?
nuevaDificultad
=
await
Dificultad
prev
=
Dificultad
.
copia
(
dificultad
);
Dificultad
?
nueva
=
await
Navigator
.
push
<
Dificultad
>(
context
,
MaterialPageRoute
(
builder:
(
BuildContext
context
)
=>
PantallaDificultad
()
)
);
if
(
nuevaDificultad
!=
null
&&
dificultad
!=
nuevaDificultad
)
{
if
(
nueva
!=
null
&&
prev
!=
nueva
)
{
setState
(()
{
dificultad
=
nueva
Dificultad
;
dificultad
=
nueva
;
_nuevaPartida
();
});
}
...
...
@@ -166,7 +167,10 @@ class _PantallaJuegoState extends State<PantallaJuego>
Widget
_buildPaginaJuego
(
BuildContext
context
,
Orientation
orientation
)
{
dificultad
=
context
.
read
<
ListaDificultad
>().
seleccionada
;
_nuevaPartida
();
if
(!
partidaEmpezada
)
{
_nuevaPartida
();
partidaEmpezada
=
true
;
}
return
SafeArea
(
child:
Stack
(
children:
[
...
...
@@ -837,7 +841,9 @@ class _PantallaJuegoState extends State<PantallaJuego>
switch
(
element
){
case
OpcionesFinPartida
.
repetir
:
onPressed
=
()
{
_nuevaPartida
();
setState
(()
{
_nuevaPartida
();
});();
};
break
;
case
OpcionesFinPartida
.
cambiarDificultad
:
...
...
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