Skip to content
Snippets Groups Projects
Commit f53c5961 authored by izajime's avatar izajime
Browse files

Fix: Se actualizan las monedas

parent 3c5d8d2a
No related branches found
No related tags found
2 merge requests!65Feature:,!51Tienda to guapa
...@@ -8,6 +8,7 @@ import android.widget.TextView ...@@ -8,6 +8,7 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.example.ellegadodepintia.exploradoresDePintia.ModalDetallesCompra import com.example.ellegadodepintia.exploradoresDePintia.ModalDetallesCompra
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState import com.example.ellegadodepintia.exploradoresDePintia.model.GameState
import com.example.ellegadodepintia.exploradoresDePintia.model.LayoutUtils
import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.ObjetoConsumible import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.ObjetoConsumible
import com.example.ellegadodepintia.repositorios.RepositorioJugador import com.example.ellegadodepintia.repositorios.RepositorioJugador
import com.example.ellegadodepintia.repositorios.RepositorioObjetos import com.example.ellegadodepintia.repositorios.RepositorioObjetos
...@@ -17,6 +18,8 @@ class TiendaActivity : AppCompatActivity() { ...@@ -17,6 +18,8 @@ class TiendaActivity : AppCompatActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_tienda) setContentView(R.layout.activity_tienda)
GameState.jugador.addObserver { LayoutUtils.actualizarMonedasTienda(this) }
val nivelCiudad = GameState.jugador.nivelCiudad val nivelCiudad = GameState.jugador.nivelCiudad
val nObjetos = nivelCiudad * 2 val nObjetos = nivelCiudad * 2
val objetos = RepositorioObjetos.obtenerObjetosAleatoriosTienda(nObjetos) val objetos = RepositorioObjetos.obtenerObjetosAleatoriosTienda(nObjetos)
......
...@@ -38,7 +38,7 @@ class Resumen : AppCompatActivity() { ...@@ -38,7 +38,7 @@ class Resumen : AppCompatActivity() {
val mensajeResultado = result.data?.getStringExtra("resultado")!!.toInt() val mensajeResultado = result.data?.getStringExtra("resultado")!!.toInt()
println(mensajeResultado) println(mensajeResultado)
val textoResumen = findViewById<TextView>(R.id.textoResumen) val textoResumen = findViewById<TextView>(R.id.textoResumen)
"Ha susado el ticker para generar aun más monedas. Enhorabuena, has conseguido $mensajeResultado monedas.".also { "Has usado el ticker para generar aun más monedas. Enhorabuena, has conseguido $mensajeResultado monedas.".also {
textoResumen.text = it textoResumen.text = it
} }
GameState.jugador.monedas+=mensajeResultado-gananciaTotal GameState.jugador.monedas+=mensajeResultado-gananciaTotal
......
package com.example.ellegadodepintia.exploradoresDePintia.model package com.example.ellegadodepintia.exploradoresDePintia.model
import android.app.Activity import android.app.Activity
import android.content.Context
import android.view.View import android.view.View
import android.widget.ImageView import android.widget.ImageView
import android.widget.ProgressBar import android.widget.ProgressBar
...@@ -115,6 +116,12 @@ object LayoutUtils { ...@@ -115,6 +116,12 @@ object LayoutUtils {
GameState.jugador.monedas.toString() GameState.jugador.monedas.toString()
.also { context!!.findViewById<TextView>(R.id.moneyText).text = it } .also { context!!.findViewById<TextView>(R.id.moneyText).text = it }
} }
fun actualizarMonedasTienda(tienda : Context) {
GameState.jugador.monedas.toString()
.also { (tienda as Activity).findViewById<TextView>(R.id.textoMonedas).text = it }
}
fun actualizarMonedasInventario(view: View) { fun actualizarMonedasInventario(view: View) {
GameState.jugador.monedas.toString() GameState.jugador.monedas.toString()
.also { view.findViewById<TextView>(R.id.moneyText).text = it } .also { view.findViewById<TextView>(R.id.moneyText).text = it }
......
...@@ -419,7 +419,7 @@ ...@@ -419,7 +419,7 @@
<TextView <TextView
android:id="@+id/textoInformacion" android:id="@+id/textoInformacion"
android:layout_width="match_parent" android:layout_width="300dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Aquí aparecera la información relevante de las compras" android:text="Aquí aparecera la información relevante de las compras"
android:textSize="15sp" android:textSize="15sp"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment