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
0ce0c8c5
authored
May 13, 2025
by
Diego Pérez Peña
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Terminada la localización al inglés y refactorizaciones menores
parent
d45390bb
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
752 additions
and
99 deletions
devtools_options.yaml
lib/l10n/app_en.arb
lib/l10n/app_es.arb
lib/l10n/app_localizations.dart
lib/l10n/app_localizations_en.dart
lib/l10n/app_localizations_es.dart
lib/modelo/pista.dart
lib/paginas/pantalla_juego.dart
devtools_options.yaml
0 → 100644
View file @
0ce0c8c5
description
:
This file stores settings for Dart & Flutter DevTools.
documentation
:
https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions
:
lib/l10n/app_en.arb
View file @
0ce0c8c5
...
...
@@ -52,11 +52,99 @@
"description": "Mathematical expression for the smallest possible number"
},
"specialHints": "Special Hints",
"hintsWarning": "Be careful! Unlocking hints is penalized",
"evenOrOdd": "Is it even or odd?",
"divisible": "By which number is it divisible?",
"digitsSum": "What do its digits add up to?",
"digitsCount": "How many digits does it have?",
"hintsWarning": "Watch out! Unlocking them is penalized",
"lockedHint": "Locked Hint",
"tapToUnlock": "Tap to Unlock",
"unlockConfirm": "Are you sure? Tap again to Confirm",
"evenOddHint": "Is it even or odd?",
"divisibleHint": "By which number is it divisible?",
"digitsSumHint": "What do its digits add up to?",
"digitsCountHint": "How many digits does it have?",
"evenNumber": "The number is Even",
"oddNumber": "The number is Odd",
"divisibleBy": "The number is Divisible by {number}",
"primeLessMax": "The number is a Prime Less than {maximum}",
"notDivisibleByPrimes": "The number is NOT Divisible by primes less than {maximum}",
"digitsSum": "The number's digits add up to {total}",
"digitsCount": "The number has {count, plural, =1{1 digit} other{{count} digits}}",
"@specialHints": {
"description": "The title of the page where you can unlock extra hints"
},
"@hintsWarning": {
"description": "A text indicating the user that unlocking hints reduces the total score"
},
"@lockedHint": {
"description": "Expression that indicates that a hint cannot be unlocked"
},
"@tapToUnlock": {
"description": "Expression that invites the user to tap in order to unlock the hint"
},
"@unlockConfirm": {
"description": "Expression that asks the user to tap again if they really want to unlock the hint"
},
"@evenOddHint": {
"description": "Interrogation that asks whether the secret number is even or odd"
},
"@divisibleHint": {
"description": "Interrogation that asks by which number the secret number is divisible"
},
"@digitsSumHint": {
"description": "Interrogation that asks for the total sum of the secret number's digits"
},
"@digitsCountHint": {
"description": "Interrogation that asks how many digits the secret number has"
},
"@evenNumber": {
"description": "Expression that indicates that the secret number is even (divisible by 2)"
},
"@oddNumber": {
"description": "Expression that indicates that the secret number is odd (not divisible by 2)"
},
"@divisibleBy": {
"description": "Expression that indicates that the secret number is divisible by a certain number",
"placeholders": {
"number": {
"type": "num",
"format": "compact"
}
}
},
"@primeLessMax": {
"description": "Expression that indicates that the secret number is a prime less than a certain maximum",
"placeholders": {
"maximum": {
"type": "num",
"format": "compact"
}
}
},
"@notDivisibleByPrimes": {
"description": "Expression that indicates that the secret number is not divisible by any prime numbers less than a certain maximum",
"placeholders": {
"maximum": {
"type": "num",
"format": "compact"
}
}
},
"@digitsSum": {
"description": "Expression that indicates that the secret number's digits' sum is equal to a certain number",
"placeholders": {
"total": {
"type": "num",
"format": "compact"
}
}
},
"@digitsCount": {
"description": "Expression that indicates that the secret number has a certain number of digits",
"placeholders": {
"count": {
"type": "num",
"format": "compact"
}
}
},
"pause": "Pause",
"resume": "Resume",
"changeHand": "Change hand",
...
...
@@ -80,5 +168,63 @@
},
"@exitGame": {
"description": "Text that refers to quitting the current game and returning to the main menu"
},
"highestScore": "New hi-score!",
"nthHiScore": "This is your {nth, select, 2{2nd} 3{3rd} other{{nth}th}} highest score",
"enterYourName": "Enter your name:",
"yourName": "Your name...",
"saveHiScore": "Save hi-score",
"dontSaveHiScore": "Exit without saving",
"congratulations": "Congratulations!",
"score": "Score: {score}",
"playAgain": "Play again",
"exitToMainMenu": "Exit to main menu",
"noMoreAttempts": "No more attempts!",
"betterLuck": "Better luck next time...",
"@highestScore": {
"description": "Expression that refers to a new Hi-Score being achieved"
},
"@nthHiScore": {
"description": "Text that refers to achieving the nth highest score",
"placeholders": {
"nth": {
"type": "String"
}
}
},
"@enterYourName": {
"description": "Text that invites the user to enter their first name"
},
"@yourName": {
"description": "Text that refers to the user's first name"
},
"@saveHiScore": {
"description": "Text that indicates the action of saving the hi-score for future reference"
},
"@dontSaveHiScore": {
"description": "Text that indicates the rejection of saving the hi-score for future reference"
},
"@congratulations": {
"description": "Expression of congratulation"
},
"@score": {
"description": "Text that shows the obtained score in the game",
"placeholders": {
"score": {
"type": "num"
}
}
},
"@playAgain": {
"description": "Text that refers to playing a new game"
},
"@exitToMainMenu": {
"description": "Text that refers to returning to the game's main menu"
},
"@noMoreAttempts": {
"description": "Text that indicates that the user used up all of its attempts"
},
"@betterLuck": {
"description": "Expression that wishes better luck for the next time playing"
}
}
\ No newline at end of file
lib/l10n/app_es.arb
View file @
0ce0c8c5
...
...
@@ -12,10 +12,38 @@
"attempts": "Intentos",
"maximum": "Máximo",
"minimum": "Mínimo",
"specialHints": "Pistas Especiales",
"hintsWarning": "¡Atención! Usarlas quita puntos",
"lockedHint": "Pista Bloqueada",
"tapToUnlock": "Toca para Desbloquear",
"unlockConfirm": "¿Seguro? Toca de nuevo para Confirmar",
"evenOddHint": "¿Es par o impar?",
"divisibleHint": "¿Entre qué número es divisible?",
"digitsSumHint": "¿Cuál es la suma de sus cifras?",
"digitsCountHint": "¿Cuántas cifras tiene?",
"evenNumber": "El número es Par",
"oddNumber": "El número es Impar",
"divisibleBy": "El número es divisible entre {number}",
"primeLessMax": "El número es primo inferior a {maximum}",
"notDivisibleByPrimes": "El número NO es divisible entre primos inferiores a {maximum}",
"digitsSum": "La suma de las cifras del número da {total}",
"digitsCount": "El número tiene {count, plural, =1{1 cifra} other{{count} cifras}}",
"pause": "Pausa",
"resume": "Reanudar",
"changeHand": "Cambiar de mano",
"newGame": "Nueva partida",
"changeDifficulty": "Cambiar dificultad",
"exitGame": "Terminar partida"
"exitGame": "Terminar partida",
"highestScore": "¡Esta es tu mejor puntuación!",
"nthHiScore": "Esta es tu {nth}ª mejor puntuación",
"enterYourName": "Introduce aquí tu nombre::",
"yourName": "Tu nombre...",
"saveHiScore": "Guardar récord",
"dontSaveHiScore": "Salir sin guardar",
"congratulations": "¡Enhorabuena!",
"score": "Puntuación: {score}",
"playAgain": "Jugar otra vez",
"exitToMainMenu": "Volver al inicio",
"noMoreAttempts": "¡Sin intentos!",
"betterLuck": "Más suerte la próxima vez..."
}
\ No newline at end of file
lib/l10n/app_localizations.dart
View file @
0ce0c8c5
...
...
@@ -173,6 +173,102 @@ abstract class AppLocalizations {
/// **'Minimum'**
String
get
minimum
;
/// The title of the page where you can unlock extra hints
///
/// In en, this message translates to:
/// **'Special Hints'**
String
get
specialHints
;
/// A text indicating the user that unlocking hints reduces the total score
///
/// In en, this message translates to:
/// **'Watch out! Unlocking them is penalized'**
String
get
hintsWarning
;
/// Expression that indicates that a hint cannot be unlocked
///
/// In en, this message translates to:
/// **'Locked Hint'**
String
get
lockedHint
;
/// Expression that invites the user to tap in order to unlock the hint
///
/// In en, this message translates to:
/// **'Tap to Unlock'**
String
get
tapToUnlock
;
/// Expression that asks the user to tap again if they really want to unlock the hint
///
/// In en, this message translates to:
/// **'Are you sure? Tap again to Confirm'**
String
get
unlockConfirm
;
/// Interrogation that asks whether the secret number is even or odd
///
/// In en, this message translates to:
/// **'Is it even or odd?'**
String
get
evenOddHint
;
/// Interrogation that asks by which number the secret number is divisible
///
/// In en, this message translates to:
/// **'By which number is it divisible?'**
String
get
divisibleHint
;
/// Interrogation that asks for the total sum of the secret number's digits
///
/// In en, this message translates to:
/// **'What do its digits add up to?'**
String
get
digitsSumHint
;
/// Interrogation that asks how many digits the secret number has
///
/// In en, this message translates to:
/// **'How many digits does it have?'**
String
get
digitsCountHint
;
/// Expression that indicates that the secret number is even (divisible by 2)
///
/// In en, this message translates to:
/// **'The number is Even'**
String
get
evenNumber
;
/// Expression that indicates that the secret number is odd (not divisible by 2)
///
/// In en, this message translates to:
/// **'The number is Odd'**
String
get
oddNumber
;
/// Expression that indicates that the secret number is divisible by a certain number
///
/// In en, this message translates to:
/// **'The number is Divisible by {number}'**
String
divisibleBy
(
num
number
);
/// Expression that indicates that the secret number is a prime less than a certain maximum
///
/// In en, this message translates to:
/// **'The number is a Prime Less than {maximum}'**
String
primeLessMax
(
num
maximum
);
/// Expression that indicates that the secret number is not divisible by any prime numbers less than a certain maximum
///
/// In en, this message translates to:
/// **'The number is NOT Divisible by primes less than {maximum}'**
String
notDivisibleByPrimes
(
num
maximum
);
/// Expression that indicates that the secret number's digits' sum is equal to a certain number
///
/// In en, this message translates to:
/// **'The number\'s digits add up to {total}'**
String
digitsSum
(
num
total
);
/// Expression that indicates that the secret number has a certain number of digits
///
/// In en, this message translates to:
/// **'The number has {count, plural, =1{1 digit} other{{count} digits}}'**
String
digitsCount
(
num
count
);
/// Expression of the frozen state of a game
///
/// In en, this message translates to:
...
...
@@ -208,6 +304,78 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Exit game'**
String
get
exitGame
;
/// Expression that refers to a new Hi-Score being achieved
///
/// In en, this message translates to:
/// **'New hi-score!'**
String
get
highestScore
;
/// Text that refers to achieving the nth highest score
///
/// In en, this message translates to:
/// **'This is your {nth, select, 2{2nd} 3{3rd} other{{nth}th}} highest score'**
String
nthHiScore
(
String
nth
);
/// Text that invites the user to enter their first name
///
/// In en, this message translates to:
/// **'Enter your name:'**
String
get
enterYourName
;
/// Text that refers to the user's first name
///
/// In en, this message translates to:
/// **'Your name...'**
String
get
yourName
;
/// Text that indicates the action of saving the hi-score for future reference
///
/// In en, this message translates to:
/// **'Save hi-score'**
String
get
saveHiScore
;
/// Text that indicates the rejection of saving the hi-score for future reference
///
/// In en, this message translates to:
/// **'Exit without saving'**
String
get
dontSaveHiScore
;
/// Expression of congratulation
///
/// In en, this message translates to:
/// **'Congratulations!'**
String
get
congratulations
;
/// Text that shows the obtained score in the game
///
/// In en, this message translates to:
/// **'Score: {score}'**
String
score
(
num
score
);
/// Text that refers to playing a new game
///
/// In en, this message translates to:
/// **'Play again'**
String
get
playAgain
;
/// Text that refers to returning to the game's main menu
///
/// In en, this message translates to:
/// **'Exit to main menu'**
String
get
exitToMainMenu
;
/// Text that indicates that the user used up all of its attempts
///
/// In en, this message translates to:
/// **'No more attempts!'**
String
get
noMoreAttempts
;
/// Expression that wishes better luck for the next time playing
///
/// In en, this message translates to:
/// **'Better luck next time...'**
String
get
betterLuck
;
}
class
_AppLocalizationsDelegate
extends
LocalizationsDelegate
<
AppLocalizations
>
{
...
...
lib/l10n/app_localizations_en.dart
View file @
0ce0c8c5
...
...
@@ -48,6 +48,100 @@ class AppLocalizationsEn extends AppLocalizations {
String
get
minimum
=>
'Minimum'
;
@override
String
get
specialHints
=>
'Special Hints'
;
@override
String
get
hintsWarning
=>
'Watch out! Unlocking them is penalized'
;
@override
String
get
lockedHint
=>
'Locked Hint'
;
@override
String
get
tapToUnlock
=>
'Tap to Unlock'
;
@override
String
get
unlockConfirm
=>
'Are you sure? Tap again to Confirm'
;
@override
String
get
evenOddHint
=>
'Is it even or odd?'
;
@override
String
get
divisibleHint
=>
'By which number is it divisible?'
;
@override
String
get
digitsSumHint
=>
'What do its digits add up to?'
;
@override
String
get
digitsCountHint
=>
'How many digits does it have?'
;
@override
String
get
evenNumber
=>
'The number is Even'
;
@override
String
get
oddNumber
=>
'The number is Odd'
;
@override
String
divisibleBy
(
num
number
)
{
final
intl
.
NumberFormat
numberNumberFormat
=
intl
.
NumberFormat
.
compact
(
locale:
localeName
,
);
final
String
numberString
=
numberNumberFormat
.
format
(
number
);
return
'The number is Divisible by
$numberString
'
;
}
@override
String
primeLessMax
(
num
maximum
)
{
final
intl
.
NumberFormat
maximumNumberFormat
=
intl
.
NumberFormat
.
compact
(
locale:
localeName
,
);
final
String
maximumString
=
maximumNumberFormat
.
format
(
maximum
);
return
'The number is a Prime Less than
$maximumString
'
;
}
@override
String
notDivisibleByPrimes
(
num
maximum
)
{
final
intl
.
NumberFormat
maximumNumberFormat
=
intl
.
NumberFormat
.
compact
(
locale:
localeName
,
);
final
String
maximumString
=
maximumNumberFormat
.
format
(
maximum
);
return
'The number is NOT Divisible by primes less than
$maximumString
'
;
}
@override
String
digitsSum
(
num
total
)
{
final
intl
.
NumberFormat
totalNumberFormat
=
intl
.
NumberFormat
.
compact
(
locale:
localeName
,
);
final
String
totalString
=
totalNumberFormat
.
format
(
total
);
return
'The number
\'
s digits add up to
$totalString
'
;
}
@override
String
digitsCount
(
num
count
)
{
final
intl
.
NumberFormat
countNumberFormat
=
intl
.
NumberFormat
.
compact
(
locale:
localeName
,
);
final
String
countString
=
countNumberFormat
.
format
(
count
);
String
_temp0
=
intl
.
Intl
.
pluralLogic
(
count
,
locale:
localeName
,
other:
'
$countString
digits'
,
one:
'1 digit'
,
);
return
'The number has
$_temp0
'
;
}
@override
String
get
pause
=>
'Pause'
;
@override
...
...
@@ -64,4 +158,52 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String
get
exitGame
=>
'Exit game'
;
@override
String
get
highestScore
=>
'New hi-score!'
;
@override
String
nthHiScore
(
String
nth
)
{
String
_temp0
=
intl
.
Intl
.
selectLogic
(
nth
,
{
'2'
:
'2nd'
,
'3'
:
'3rd'
,
'other'
:
'
${nth}
th'
,
},
);
return
'This is your
$_temp0
highest score'
;
}
@override
String
get
enterYourName
=>
'Enter your name:'
;
@override
String
get
yourName
=>
'Your name...'
;
@override
String
get
saveHiScore
=>
'Save hi-score'
;
@override
String
get
dontSaveHiScore
=>
'Exit without saving'
;
@override
String
get
congratulations
=>
'Congratulations!'
;
@override
String
score
(
num
score
)
{
return
'Score:
$score
'
;
}
@override
String
get
playAgain
=>
'Play again'
;
@override
String
get
exitToMainMenu
=>
'Exit to main menu'
;
@override
String
get
noMoreAttempts
=>
'No more attempts!'
;
@override
String
get
betterLuck
=>
'Better luck next time...'
;
}
lib/l10n/app_localizations_es.dart
View file @
0ce0c8c5
...
...
@@ -48,6 +48,100 @@ class AppLocalizationsEs extends AppLocalizations {
String
get
minimum
=>
'Mínimo'
;
@override
String
get
specialHints
=>
'Pistas Especiales'
;
@override
String
get
hintsWarning
=>
'¡Atención! Usarlas quita puntos'
;
@override
String
get
lockedHint
=>
'Pista Bloqueada'
;
@override
String
get
tapToUnlock
=>
'Toca para Desbloquear'
;
@override
String
get
unlockConfirm
=>
'¿Seguro? Toca de nuevo para Confirmar'
;
@override
String
get
evenOddHint
=>
'¿Es par o impar?'
;
@override
String
get
divisibleHint
=>
'¿Entre qué número es divisible?'
;
@override
String
get
digitsSumHint
=>
'¿Cuál es la suma de sus cifras?'
;
@override
String
get
digitsCountHint
=>
'¿Cuántas cifras tiene?'
;
@override
String
get
evenNumber
=>
'El número es Par'
;
@override
String
get
oddNumber
=>
'El número es Impar'
;
@override
String
divisibleBy
(
num
number
)
{
final
intl
.
NumberFormat
numberNumberFormat
=
intl
.
NumberFormat
.
compact
(
locale:
localeName
,
);
final
String
numberString
=
numberNumberFormat
.
format
(
number
);
return
'El número es divisible entre
$numberString
'
;
}
@override
String
primeLessMax
(
num
maximum
)
{
final
intl
.
NumberFormat
maximumNumberFormat
=
intl
.
NumberFormat
.
compact
(
locale:
localeName
,
);
final
String
maximumString
=
maximumNumberFormat
.
format
(
maximum
);
return
'El número es primo inferior a
$maximumString
'
;
}
@override
String
notDivisibleByPrimes
(
num
maximum
)
{
final
intl
.
NumberFormat
maximumNumberFormat
=
intl
.
NumberFormat
.
compact
(
locale:
localeName
,
);
final
String
maximumString
=
maximumNumberFormat
.
format
(
maximum
);
return
'El número NO es divisible entre primos inferiores a
$maximumString
'
;
}
@override
String
digitsSum
(
num
total
)
{
final
intl
.
NumberFormat
totalNumberFormat
=
intl
.
NumberFormat
.
compact
(
locale:
localeName
,
);
final
String
totalString
=
totalNumberFormat
.
format
(
total
);
return
'La suma de las cifras del número da
$totalString
'
;
}
@override
String
digitsCount
(
num
count
)
{
final
intl
.
NumberFormat
countNumberFormat
=
intl
.
NumberFormat
.
compact
(
locale:
localeName
,
);
final
String
countString
=
countNumberFormat
.
format
(
count
);
String
_temp0
=
intl
.
Intl
.
pluralLogic
(
count
,
locale:
localeName
,
other:
'
$countString
cifras'
,
one:
'1 cifra'
,
);
return
'El número tiene
$_temp0
'
;
}
@override
String
get
pause
=>
'Pausa'
;
@override
...
...
@@ -64,4 +158,44 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String
get
exitGame
=>
'Terminar partida'
;
@override
String
get
highestScore
=>
'¡Esta es tu mejor puntuación!'
;
@override
String
nthHiScore
(
String
nth
)
{
return
'Esta es tu
$nth
ª mejor puntuación'
;
}
@override
String
get
enterYourName
=>
'Introduce aquí tu nombre::'
;
@override
String
get
yourName
=>
'Tu nombre...'
;
@override
String
get
saveHiScore
=>
'Guardar récord'
;
@override
String
get
dontSaveHiScore
=>
'Salir sin guardar'
;
@override
String
get
congratulations
=>
'¡Enhorabuena!'
;
@override
String
score
(
num
score
)
{
return
'Puntuación:
$score
'
;
}
@override
String
get
playAgain
=>
'Jugar otra vez'
;
@override
String
get
exitToMainMenu
=>
'Volver al inicio'
;
@override
String
get
noMoreAttempts
=>
'¡Sin intentos!'
;
@override
String
get
betterLuck
=>
'Más suerte la próxima vez...'
;
}
lib/modelo/pista.dart
View file @
0ce0c8c5
import
'package:flutter/material.dart'
;
import
'package:peponator/l10n/app_localizations.dart'
;
import
'package:peponator/widgets/pista_widget.dart'
;
class
Pista
{
static
const
primos
=
[
3
,
5
,
7
,
11
,
13
,
17
,
19
,
23
,
29
,
31
,
37
,
41
,
43
,
47
,
53
,
59
,
61
,
67
,
71
,
73
,
79
,
83
,
89
,
97
];
final
ClasePista
clase
;
final
VoidCallback
?
onPressed
;
late
final
int
divisible
;
late
final
String
mensaje
;
late
String
?
mensaje
;
late
final
int
_numero
;
late
final
int
_divisible
;
EstadoPista
estado
=
EstadoPista
.
bloqueado
;
...
...
@@ -17,46 +17,75 @@ class Pista{
required
int
numero
,
this
.
onPressed
})
{
if
(
clase
!=
ClasePista
.
divisible
){
divisible
=
0
;
}
else
{
bool
found
=
false
;
for
(
int
i
=
0
;
(
i
<
primos
.
length
)
&&
(
primos
[
i
]<=
numero
/
2
);
i
++){
if
(
numero
%
primos
[
i
]
==
0
){
divisible
=
primos
[
i
];
found
=
true
;
break
;
}
}
if
(!
found
){
if
(
numero
<
100
){
divisible
=
1
;
}
else
{
divisible
=
-
1
;
}
_numero
=
numero
;
_divisible
=
clase
.
getDivisible
(
_numero
);
}
bool
validarNumero
(
int
adivinar
,
int
numero
){
return
clase
.
validarNumero
(
adivinar
,
numero
,
_divisible
);
}
Widget
createWidget
(
BuildContext
context
){
return
PistaWidget
(
key:
Key
(
clase
.
name
),
titulo:
clase
.
getTitle
(
context
),
mensaje:
(
estado
.
desbloqueada
())?
clase
.
generateMensaje
(
_numero
,
_divisible
,
context
)
:
estado
.
getMensaje
(
context
),
estado:
estado
,
onPressed:
(
estado
==
EstadoPista
.
disponible
||
estado
==
EstadoPista
.
confirmacion
)?
onPressed
:
null
);
}
}
enum
ClasePista
{
parImpar
,
divisible
,
sumaCifras
,
numeroCifras
;
static
const
primos
=
[
3
,
5
,
7
,
11
,
13
,
17
,
19
,
23
,
29
,
31
,
37
,
41
,
43
,
47
,
53
,
59
,
61
,
67
,
71
,
73
,
79
,
83
,
89
,
97
];
int
getDivisible
(
int
numero
){
if
(
this
!=
ClasePista
.
divisible
)
return
0
;
for
(
int
i
=
0
;
(
i
<
primos
.
length
)
&&
(
primos
[
i
]<=
numero
/
2
);
i
++){
if
(
numero
%
primos
[
i
]
==
0
){
return
primos
[
i
];
}
}
if
(
numero
<
100
){
return
1
;
}
return
-
1
;
}
mensaje
=
_generaPista
(
numero
);
String
getTitle
(
BuildContext
context
){
switch
(
this
){
case
parImpar:
return
AppLocalizations
.
of
(
context
)?.
evenOddHint
??
'¿Es par o impar?'
;
case
divisible:
return
AppLocalizations
.
of
(
context
)?.
divisibleHint
??
'¿Entre qué número es divisible?'
;
case
sumaCifras:
return
AppLocalizations
.
of
(
context
)?.
digitsSumHint
??
'¿Cuál es la suma de sus cifras?'
;
case
numeroCifras:
return
AppLocalizations
.
of
(
context
)?.
digitsCountHint
??
'¿Cuántas cifras tiene?'
;
}
}
String
_generaPista
(
int
numero
){
switch
(
clase
){
String
generateMensaje
(
int
numero
,
int
divisible
,
BuildContext
context
){
switch
(
this
){
case
ClasePista
.
parImpar
:
if
(
numero
%
2
==
0
){
return
'El número es par'
;
return
AppLocalizations
.
of
(
context
)?.
evenNumber
??
'El número es par'
;
}
return
'El número es impar'
;
return
AppLocalizations
.
of
(
context
)?.
oddNumber
??
'El número es impar'
;
case
ClasePista
.
divisible
:
if
(
divisible
==
1
){
return
'El número es primo inferior a 100'
;
return
AppLocalizations
.
of
(
context
)?.
primeLessMax
(
100
)
??
'El número es primo inferior a 100'
;
}
if
(
divisible
==
-
1
){
return
'El número NO es divisible entre primos inferiores a 100'
;
return
AppLocalizations
.
of
(
context
)?.
notDivisibleByPrimes
(
100
)
??
'El número NO es divisible entre primos inferiores a 100'
;
}
return
'El número es divisible entre
$divisible
'
;
return
AppLocalizations
.
of
(
context
)?.
divisibleBy
(
divisible
)
??
'El número es divisible entre
$divisible
'
;
case
ClasePista
.
sumaCifras
:
int
pseudo
=
numero
;
int
suma
=
0
;
...
...
@@ -64,7 +93,7 @@ class Pista{
suma
+=
pseudo
%
10
;
pseudo
=
(
pseudo
/
10
).
floor
();
}
return
'La suma de las cifras del número da
$suma
'
;
return
AppLocalizations
.
of
(
context
)?.
digitsSum
(
suma
)
??
'La suma de las cifras del número da
$suma
'
;
case
ClasePista
.
numeroCifras
:
int
div
=
10
;
int
num
=
1
;
...
...
@@ -72,6 +101,12 @@ class Pista{
num
++;
div
*=
10
;
}
String
?
ret
=
AppLocalizations
.
of
(
context
)?.
digitsCount
(
num
);
if
(
ret
!=
null
){
return
ret
;
}
if
(
num
==
1
){
return
'El número tiene 1 cifra'
;
}
...
...
@@ -79,8 +114,8 @@ class Pista{
}
}
bool
validarNumero
(
int
adivinar
,
int
numero
){
switch
(
clase
){
bool
validarNumero
(
int
adivinar
,
int
numero
,
int
divisible
){
switch
(
this
){
case
ClasePista
.
parImpar
:
return
adivinar
%
2
==
numero
%
2
;
case
ClasePista
.
divisible
:
...
...
@@ -90,7 +125,6 @@ class Pista{
if
(
divisible
==
-
1
){
for
(
int
i
=
0
;
(
i
<
primos
.
length
)
&&
(
primos
[
i
]<=
numero
/
2
);
i
++){
if
(
numero
%
primos
[
i
]
==
0
){
divisible
=
primos
[
i
];
return
false
;
}
}
...
...
@@ -115,36 +149,6 @@ class Pista{
return
(
numero
/
div
<
10
&&
numero
/
div
>=
1
);
}
}
Widget
createWidget
(){
return
PistaWidget
(
key:
Key
(
clase
.
name
),
titulo:
clase
.
getTitle
(),
mensaje:
(
estado
.
desbloqueada
())?
mensaje
:
estado
.
getMensaje
(),
estado:
estado
,
onPressed:
(
estado
==
EstadoPista
.
disponible
||
estado
==
EstadoPista
.
confirmacion
)?
onPressed
:
null
);
}
}
enum
ClasePista
{
parImpar
,
divisible
,
sumaCifras
,
numeroCifras
;
String
getTitle
(){
switch
(
this
){
case
parImpar:
return
'¿Es par o impar?'
;
case
divisible:
return
'¿Entre qué número es divisible?'
;
case
sumaCifras:
return
'¿Cuál es la suma de sus cifras?'
;
case
numeroCifras:
return
'¿Cuántas cifras tiene?'
;
}
}
}
enum
EstadoPista
{
...
...
@@ -200,16 +204,16 @@ enum EstadoPista {
return
Colors
.
black
;
}
String
getMensaje
(){
String
getMensaje
(
BuildContext
context
){
switch
(
this
){
case
bloqueado:
return
"PISTA BLOQUEADA"
;
return
AppLocalizations
.
of
(
context
)?.
lockedHint
??
'Pista Bloqueada'
;
case
disponible:
return
"PULSA PARA DESBLOQUEAR"
;
return
AppLocalizations
.
of
(
context
)?.
tapToUnlock
??
'Pulsa para Desbloquear'
;
case
confirmacion:
return
"¿Seguro? Pulsa de nuevo para confirmar"
;
return
AppLocalizations
.
of
(
context
)?.
unlockConfirm
??
'¿Seguro? Pulsa de nuevo para Confirmar'
;
default
:
return
""
;
return
''
;
}
}
...
...
lib/paginas/pantalla_juego.dart
View file @
0ce0c8c5
...
...
@@ -287,19 +287,23 @@ class _PantallaJuegoState extends State<PantallaJuego>
padding:
(
orientation
==
Orientation
.
portrait
||
!
manoDerecha
)?
const
EdgeInsets
.
only
(
right:
56.0
)
:
const
EdgeInsets
.
only
(
left:
56.0
),
child:
Text
(
'Pistas Especiales'
,
style:
Theme
.
of
(
context
).
textTheme
.
headlineLarge
,
child:
FittedBox
(
child:
Text
(
AppLocalizations
.
of
(
context
)?.
specialHints
??
'Pistas Especiales'
,
style:
Theme
.
of
(
context
).
textTheme
.
headlineLarge
,
),
),
),
Padding
(
padding:
(
orientation
==
Orientation
.
portrait
||
!
manoDerecha
)?
const
EdgeInsets
.
only
(
top:
8.0
,
right:
56.0
)
:
const
EdgeInsets
.
only
(
top:
8.0
,
left:
56.0
),
child:
Text
(
'¡Atención! Usarlas quita puntos'
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
?.
copyWith
(
fontStyle:
FontStyle
.
italic
child:
FittedBox
(
child:
Text
(
AppLocalizations
.
of
(
context
)?.
hintsWarning
??
'¡Atención! Usarlas quita puntos'
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
?.
copyWith
(
fontStyle:
FontStyle
.
italic
),
),
),
),
...
...
@@ -309,7 +313,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
MediaQuery
.
of
(
context
).
size
.
height
-
MediaQuery
.
of
(
context
).
padding
.
vertical
-
76.0
,
child:
ListView
.
builder
(
itemBuilder:
(
context
,
index
)
{
return
pistas
[
index
].
createWidget
();
return
pistas
[
index
].
createWidget
(
context
);
},
itemCount:
pistas
.
length
,
shrinkWrap:
true
,
...
...
@@ -381,7 +385,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
if
(!
espera
){
setState
(()
{
mostrarPistas
=
!
mostrarPistas
;
for
(
Pista
p
in
pistas
){
for
(
var
p
in
pistas
){
if
(
p
.
estado
==
EstadoPista
.
confirmacion
){
p
.
estado
=
EstadoPista
.
disponible
;
}
...
...
@@ -676,7 +680,9 @@ class _PantallaJuegoState extends State<PantallaJuego>
),
const
SizedBox
(
height:
16.0
),
Text
(
(
posicion
==
0
)?
'¡Esta es tu mejor puntuación!'
:
'Esta es tu
${posicion+1}
ª mejor puntuación'
,
(
posicion
==
0
)?
AppLocalizations
.
of
(
context
)?.
highestScore
??
'¡Esta es tu mejor puntuación!'
:
AppLocalizations
.
of
(
context
)?.
nthHiScore
((
posicion
+
1
).
toString
())
??
'Esta es tu
${posicion+1}
ª mejor puntuación'
,
textAlign:
TextAlign
.
center
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
,
),
...
...
@@ -688,7 +694,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
[
Text
(
'Introduce aquí tu nombre:'
,
AppLocalizations
.
of
(
context
)?.
enterYourName
??
'Introduce aquí tu nombre:'
,
style:
Theme
.
of
(
context
).
textTheme
.
bodyLarge
,
),
TextField
(
...
...
@@ -697,7 +703,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
,
maxLength:
10
,
decoration:
InputDecoration
(
hintText:
'Tu nombre...'
,
hintText:
AppLocalizations
.
of
(
context
)?.
yourName
??
'Tu nombre...'
,
border:
OutlineInputBorder
(),
errorBorder:
OutlineInputBorder
(
borderSide:
BorderSide
(
...
...
@@ -745,7 +751,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
});
}
:
null
,
child:
Text
(
'Guardar récord'
,
AppLocalizations
.
of
(
context
)?.
saveHiScore
??
'Guardar récord'
,
textScaler:
TextScaler
.
linear
(
1.1
),
)
),
...
...
@@ -767,7 +773,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
});
},
child:
Text
(
'Salir sin guardar'
,
AppLocalizations
.
of
(
context
)?.
dontSaveHiScore
??
'Salir sin guardar'
,
textScaler:
TextScaler
.
linear
(
1.1
),
)
),
...
...
@@ -793,13 +799,17 @@ class _PantallaJuegoState extends State<PantallaJuego>
Column
(
children:
[
Text
(
victoria
?
'¡Enhorabuena!'
:
'¡Sin intentos!'
,
victoria
?
AppLocalizations
.
of
(
context
)?.
congratulations
??
'¡Enhorabuena!'
:
AppLocalizations
.
of
(
context
)?.
noMoreAttempts
??
'¡Sin intentos!'
,
textAlign:
TextAlign
.
center
,
style:
Theme
.
of
(
context
).
textTheme
.
headlineMedium
,
),
const
SizedBox
(
height:
16.0
),
Text
(
victoria
?
'Puntuación:
$puntuacion
'
:
'Más suerte la próxima vez...'
,
victoria
?
AppLocalizations
.
of
(
context
)?.
score
(
puntuacion
)
??
'Puntuación:
$puntuacion
'
:
AppLocalizations
.
of
(
context
)?.
betterLuck
??
'Más suerte la próxima vez...'
,
textAlign:
TextAlign
.
center
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
,
),
...
...
@@ -844,7 +854,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
size:
32.0
),
label:
Text
(
element
.
text
,
element
.
getText
(
context
)
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
?.
copyWith
(
fontWeight:
(
Theme
.
of
(
context
).
brightness
==
Brightness
.
light
)?
null
:
FontWeight
.
bold
,
color:
element
.
getColor
(
Theme
.
of
(
context
).
brightness
)
??
Theme
.
of
(
context
).
colorScheme
.
primary
...
...
@@ -865,7 +875,12 @@ class _PantallaJuegoState extends State<PantallaJuego>
if
(!
espera
){
setState
(()
{
numeroEscogido
??=
0
;
numeroEscogido
=
numeroEscogido
!*
10
+
number
;
if
(
numeroEscogido
!
>=
(-
1
>>>
1
)/
10
-
9
){
numeroEscogido
=
(-
1
>>>
1
);
}
else
{
numeroEscogido
=
numeroEscogido
!*
10
+
number
;
}
if
(
numeroEscogido
==
0
)
numeroEscogido
=
null
;
textController
.
text
=
numeroEscogido
?.
toString
()
??
""
;
if
(
numeroEscogido
!=
null
&&
(
numeroEscogido
!
<
limiteInferior
||
numeroEscogido
!
>
limiteSuperior
)){
...
...
@@ -1033,14 +1048,13 @@ class _PantallaJuegoState extends State<PantallaJuego>
}
enum
OpcionesFinPartida
{
repetir
(
Icons
.
play_arrow_outlined
,
"Jugar otra vez"
),
cambiarDificultad
(
Icons
.
settings_outlined
,
"Cambiar de dificultad"
),
salir
(
Icons
.
logout
,
"Volver al inicio"
);
repetir
(
Icons
.
play_arrow_outlined
),
cambiarDificultad
(
Icons
.
settings_outlined
),
salir
(
Icons
.
logout
);
final
IconData
icon
;
final
String
text
;
const
OpcionesFinPartida
(
this
.
icon
,
this
.
text
);
const
OpcionesFinPartida
(
this
.
icon
);
Color
?
getColor
(
Brightness
brillo
)
{
switch
(
this
){
...
...
@@ -1058,4 +1072,15 @@ enum OpcionesFinPartida {
return
null
;
}
}
String
getText
(
BuildContext
context
){
switch
(
this
){
case
OpcionesFinPartida
.
repetir
:
return
AppLocalizations
.
of
(
context
)?.
playAgain
??
'Jugar otra vez'
;
case
OpcionesFinPartida
.
cambiarDificultad
:
return
AppLocalizations
.
of
(
context
)?.
changeDifficulty
??
'Cambiar de dificultad'
;
case
OpcionesFinPartida
.
salir
:
return
AppLocalizations
.
of
(
context
)?.
exitToMainMenu
??
'Volver al inicio'
;
}
}
}
\ 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