Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
El Legado De Pintia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
diegval
El Legado De Pintia
Merge requests
!60
Ciudad
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Merged
Ciudad
ciudad
into
develop
Overview
0
Commits
7
Pipelines
0
Changes
2
Merged
izajime
requested to merge
ciudad
into
develop
5 months ago
Overview
0
Commits
7
Pipelines
0
Changes
2
Expand
0
0
Merge request reports
Viewing commit
440e22ef
Prev
Next
Show latest version
2 files
+
29
−
15
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
440e22ef
Fix: Ahora al subir la taberna de nivel comprueba las monedas y las resta
· 440e22ef
izajime
authored
5 months ago
app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/ModalConfirmacion.kt
+
18
−
14
Options
package
com.example.ellegadodepintia.exploradoresDePintia
import
android.content.DialogInterface
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
@@ -11,11 +10,12 @@ import androidx.fragment.app.DialogFragment
import
com.example.ellegadodepintia.R
import
com.example.ellegadodepintia.exploradoresDePintia.model.GameState
import
com.example.ellegadodepintia.exploradoresDePintia.model.objeto.Objeto
import
com.example.ellegadodepintia.repositorios.RepositorioJugador
class
ModalConfirmacion
:
DialogFragment
()
{
var
objeto
:
Objeto
?
=
null
var
coste
:
Int
?
=
null
private
var
onDismissListener
:
(()
->
Unit
)?
=
null
var
onDismissListener
:
((
isMejora
:
Boolean
)
->
Unit
)?
=
null
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
@@ -29,29 +29,33 @@ class ModalConfirmacion : DialogFragment() {
val
nivelActual
=
GameState
.
jugador
.
nivelCiudad
val
costeNuevoNivel
=
50
*
nivelActual
val
monedasJugador
=
GameState
.
jugador
.
monedas
val
textoInformacion
=
view
.
findViewById
<
TextView
>(
R
.
id
.
textoInformacion
)
(
"Vas a mejorar la taberna por el coste de $costeNuevoNivel monedas. ¿Estás seguro?"
).
also
{
textoInformacion
.
text
=
it
}
val
botonMejorar
=
view
.
findViewById
<
Button
>(
R
.
id
.
botonMejorar
)
botonMejorar
.
setOnClickListener
{
val
nObjetos
=
(
nivelActual
+
1
)
*
2
GameState
.
jugador
.
actualizarObjetosTienda
(
nObjetos
)
GameState
.
jugador
.
actualizarObjetosArmeria
(
nObjetos
)
GameState
.
jugador
.
actualizarNivelCiudad
(
nivelActual
+
1
)
"Se ha subido de nivel la taberna correctamente"
.
also
{
textoInformacion
.
text
=
it
}
dismiss
()
if
(
monedasJugador
>=
costeNuevoNivel
){
val
nObjetos
=
(
nivelActual
+
1
)
*
2
GameState
.
jugador
.
actualizarObjetosTienda
(
nObjetos
)
GameState
.
jugador
.
actualizarObjetosArmeria
(
nObjetos
)
GameState
.
jugador
.
actualizarNivelCiudad
(
nivelActual
+
1
)
GameState
.
jugador
.
actualizarMonedas
(
monedasJugador
-
costeNuevoNivel
)
RepositorioJugador
.
setMonedas
(
monedasJugador
-
costeNuevoNivel
)
onDismissListener
?.
invoke
(
true
)
dismiss
()
}
else
{
onDismissListener
?.
invoke
(
false
)
dismiss
()
}
}
val
botonCancelar
=
view
.
findViewById
<
Button
>(
R
.
id
.
botonCancelar
)
botonCancelar
.
setOnClickListener
{
onDismissListener
?.
invoke
(
false
)
dismiss
()
}
}
override
fun
onDismiss
(
dialog
:
DialogInterface
)
{
super
.
onDismiss
(
dialog
)
onDismissListener
?.
invoke
()
}
}
Loading