diff --git a/app/src/main/java/com/example/ellegadodepintia/ArmeriaActivity.kt b/app/src/main/java/com/example/ellegadodepintia/ArmeriaActivity.kt index 541e5e0cbcbc9f1f10222fd2b35764f33ce816ad..5b06fea38949b22c1d726bb141870b1575c1999c 100644 --- a/app/src/main/java/com/example/ellegadodepintia/ArmeriaActivity.kt +++ b/app/src/main/java/com/example/ellegadodepintia/ArmeriaActivity.kt @@ -11,7 +11,6 @@ import com.example.ellegadodepintia.exploradoresDePintia.ModalDetallesCompra import com.example.ellegadodepintia.exploradoresDePintia.model.GameState import com.example.ellegadodepintia.exploradoresDePintia.model.LayoutUtils import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.Objeto -import com.example.ellegadodepintia.repositorios.RepositorioJugador import com.example.ellegadodepintia.repositorios.RepositorioObjetos class ArmeriaActivity : AppCompatActivity() { @@ -31,7 +30,6 @@ class ArmeriaActivity : AppCompatActivity() { botonRefrescar.setOnClickListener { if(GameState.jugador.monedas >= 5){ GameState.jugador.actualizarObjetosArmeria(nObjetos) - RepositorioJugador.setMonedas(GameState.jugador.monedas - 5) GameState.jugador.actualizarMonedas(GameState.jugador.monedas - 5) "Se ha actualizado la tienda".also { texto.text = it } } else { @@ -50,7 +48,6 @@ class ArmeriaActivity : AppCompatActivity() { val nivelCiudad = GameState.jugador.nivelCiudad val nObjetos = nivelCiudad * 2 val objetos = RepositorioObjetos.convertirNombresAObjetos(GameState.jugador.objetosArmeria) - val preciosGenerados = ArrayList<Int>() val slots = listOf<ImageView>( findViewById(R.id.slot01), @@ -81,9 +78,7 @@ class ArmeriaActivity : AppCompatActivity() { precios.forEachIndexed { index, precio -> if (index < nObjetos) { - val resultado = (30..75).random() / nivelCiudad - preciosGenerados.add(resultado) - resultado.toString().also { precio.text = it } + objetos[index]!!.coste.toString().also { precio.text = it } } else { val nivelTaberna = index / 2 + 1 "Taberna lvl $nivelTaberna".also { precio.text = it } @@ -99,12 +94,11 @@ class ArmeriaActivity : AppCompatActivity() { slot.setOnClickListener { val modalDetallesFragment = ModalDetallesCompra().apply { objeto = objetos[index] - coste = preciosGenerados[index] } modalDetallesFragment.onDismissListener = { accionRealizada -> if (accionRealizada) { - ejecutarCompra(objetos[index], preciosGenerados[index]) + ejecutarCompra(objetos[index], objetos[index]!!.coste) } } @@ -129,7 +123,6 @@ class ArmeriaActivity : AppCompatActivity() { "No hay dinero".also { texto.text = it } }else{ GameState.jugador.actualizarMonedas(GameState.jugador.monedas - coste) - RepositorioJugador.setMonedas(GameState.jugador.monedas) if (objeto != null) { GameState.jugador.conseguirObjeto(objeto) } diff --git a/app/src/main/java/com/example/ellegadodepintia/MapActivity.kt b/app/src/main/java/com/example/ellegadodepintia/MapActivity.kt index 35d525cf0966019e68f3c70f8d9ac4f91ecbb4e7..97158bf5ec9239962714eb0f81265df75c5a5660 100644 --- a/app/src/main/java/com/example/ellegadodepintia/MapActivity.kt +++ b/app/src/main/java/com/example/ellegadodepintia/MapActivity.kt @@ -15,6 +15,8 @@ class MapActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_map) + GameState.jugador.addObserver { actualizarMonedas() } + val mapButton: ImageButton= findViewById(R.id.mapButton) val leaderboardButton: ImageButton = findViewById(R.id.leaderboardButton) val shopButton: ImageButton = findViewById(R.id.shopButton) @@ -24,8 +26,7 @@ class MapActivity : AppCompatActivity() { startActivity(intent) } - GameState.jugador.monedas.toString().also { findViewById<TextView>(R.id.moneyText).text = it } - + actualizarMonedas() mapButton.setBackgroundResource(R.drawable.style_texto_border) leaderboardButton.setBackgroundColor(Color.TRANSPARENT) @@ -55,4 +56,8 @@ class MapActivity : AppCompatActivity() { startActivity(intent) } } + + private fun actualizarMonedas(){ + GameState.jugador.monedas.toString().also { findViewById<TextView>(R.id.moneyText).text = it } + } } diff --git a/app/src/main/java/com/example/ellegadodepintia/TabernaActivity.kt b/app/src/main/java/com/example/ellegadodepintia/TabernaActivity.kt index a2ff965cef5f67c9021a44387b4a79631f5821a3..995444e8d8f5671dab1caa9755fcf542ddfc265f 100644 --- a/app/src/main/java/com/example/ellegadodepintia/TabernaActivity.kt +++ b/app/src/main/java/com/example/ellegadodepintia/TabernaActivity.kt @@ -1,11 +1,40 @@ package com.example.ellegadodepintia import android.os.Bundle +import android.widget.TextView import androidx.appcompat.app.AppCompatActivity +import com.example.ellegadodepintia.exploradoresDePintia.ModalConfirmacion +import com.example.ellegadodepintia.exploradoresDePintia.model.GameState class TabernaActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_taberna) + + GameState.jugador.addObserver { actualizarNivelTaberna() } + + val botonMejorar = findViewById<TextView>(R.id.botonMejorar) + val textoInformacion = findViewById<TextView>(R.id.textoInformacion) + + actualizarNivelTaberna() + + botonMejorar.setOnClickListener { + val confirmacionFragment = ModalConfirmacion() + + confirmacionFragment.onDismissListener = { mejorar -> + if (mejorar) { + "Se ha realizado la mejora con éxito".also { textoInformacion.text = it } + } else { + "No se ha podido realizar la mejora".also { textoInformacion.text = it } + } + } + confirmacionFragment.show(supportFragmentManager, "confirmacion") + } + } + + private fun actualizarNivelTaberna() { + val textoNivel = findViewById<TextView>(R.id.nivelActual) + "Nivel actual: ${GameState.jugador.nivelCiudad}".also { textoNivel.text = it } + } } diff --git a/app/src/main/java/com/example/ellegadodepintia/TiendaActivity.kt b/app/src/main/java/com/example/ellegadodepintia/TiendaActivity.kt index fe945231baa1804dbd81c4843053700f64790074..5c3cd801bca4542261f724a180c1a2650e19bc59 100644 --- a/app/src/main/java/com/example/ellegadodepintia/TiendaActivity.kt +++ b/app/src/main/java/com/example/ellegadodepintia/TiendaActivity.kt @@ -11,7 +11,6 @@ import com.example.ellegadodepintia.exploradoresDePintia.ModalDetallesCompra import com.example.ellegadodepintia.exploradoresDePintia.model.GameState import com.example.ellegadodepintia.exploradoresDePintia.model.LayoutUtils import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.Objeto -import com.example.ellegadodepintia.repositorios.RepositorioJugador import com.example.ellegadodepintia.repositorios.RepositorioObjetos class TiendaActivity : AppCompatActivity() { @@ -31,7 +30,6 @@ class TiendaActivity : AppCompatActivity() { botonRefrescar.setOnClickListener { if(GameState.jugador.monedas >= 5){ GameState.jugador.actualizarObjetosTienda(nObjetos) - RepositorioJugador.setMonedas(GameState.jugador.monedas - 5) GameState.jugador.actualizarMonedas(GameState.jugador.monedas - 5) "Se ha actualizado la tienda".also { texto.text = it } } else { @@ -50,7 +48,6 @@ class TiendaActivity : AppCompatActivity() { val nivelCiudad = GameState.jugador.nivelCiudad val nObjetos = nivelCiudad * 2 val objetos = RepositorioObjetos.convertirNombresAObjetos(GameState.jugador.objetosTienda) - val preciosGenerados = ArrayList<Int>() val slots = listOf<ImageView>( findViewById(R.id.slot01), @@ -81,9 +78,7 @@ class TiendaActivity : AppCompatActivity() { precios.forEachIndexed { index, precio -> if (index < nObjetos) { - val resultado = (30..75).random() / nivelCiudad - preciosGenerados.add(resultado) - resultado.toString().also { precio.text = it } + objetos[index]!!.coste.toString().also { precio.text = it } } else { val nivelTaberna = index / 2 + 1 "Taberna lvl $nivelTaberna".also { precio.text = it } @@ -99,15 +94,13 @@ class TiendaActivity : AppCompatActivity() { slot.setOnClickListener { val modalDetallesFragment = ModalDetallesCompra().apply { objeto = objetos[index] - coste = preciosGenerados[index] } modalDetallesFragment.onDismissListener = { accionRealizada -> if (accionRealizada) { - ejecutarCompra(objetos[index], preciosGenerados[index]) + ejecutarCompra(objetos[index], objetos[index]!!.coste) } } - modalDetallesFragment.show(supportFragmentManager, "modalDetalles") } } else { @@ -129,7 +122,6 @@ class TiendaActivity : AppCompatActivity() { "No hay dinero".also { texto.text = it } }else{ GameState.jugador.actualizarMonedas(GameState.jugador.monedas - coste) - RepositorioJugador.setMonedas(GameState.jugador.monedas) if (objeto != null) { GameState.jugador.conseguirObjeto(objeto) } diff --git a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/ModalConfirmacion.kt b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/ModalConfirmacion.kt new file mode 100644 index 0000000000000000000000000000000000000000..55bc9dd60632acae0083812f1b001e749c6c7c25 --- /dev/null +++ b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/ModalConfirmacion.kt @@ -0,0 +1,59 @@ +package com.example.ellegadodepintia.exploradoresDePintia + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Button +import android.widget.TextView +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 + +class ModalConfirmacion : DialogFragment() { + var objeto: Objeto? = null + var coste: Int? = null + var onDismissListener: ((isMejora: Boolean) -> Unit)? = null + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.modal_confirmacion, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + 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{ + 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) + onDismissListener?.invoke(true) + dismiss() + } else { + onDismissListener?.invoke(false) + dismiss() + } + + } + + val botonCancelar = view.findViewById<Button>(R.id.botonCancelar) + botonCancelar.setOnClickListener{ + onDismissListener?.invoke(false) + dismiss() + } + } +} diff --git a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/ModalDetallesCompra.kt b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/ModalDetallesCompra.kt index c368e605c256a3dee53db907d34d69e2581df628..8591fbffdf9038ca96b23c6f7fb2976cf29c060e 100644 --- a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/ModalDetallesCompra.kt +++ b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/ModalDetallesCompra.kt @@ -14,7 +14,6 @@ import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.Objeto class ModalDetallesCompra : DialogFragment() { var objeto: Objeto? = null - var coste: Int? = null var onDismissListener: ((accionRealizada: Boolean) -> Unit)? = null private var accionRealizada: Boolean = false @@ -45,7 +44,7 @@ class ModalDetallesCompra : DialogFragment() { descripcion.text = objeto!!.descripcion val coste = view.findViewById<TextView>(R.id.textoPrecio) - """Coste:${this.coste}""".also { coste.text = it } + """Coste:${this.objeto!!.coste}""".also { coste.text = it } val boton = view.findViewById<Button>(R.id.botonComprar) boton.setOnClickListener{ diff --git a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/Jugador.kt b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/Jugador.kt index c731282a9d17c72f8ef0592b4a28b6f0acf48a74..397ff5fd0cbc330c1654df1dfd0e6451f1d4590d 100644 --- a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/Jugador.kt +++ b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/Jugador.kt @@ -151,6 +151,13 @@ class Jugador { fun actualizarMonedas(valor: Int) { monedas = valor + RepositorioJugador.setMonedas(valor) + notifyObservers() + } + + fun actualizarNivelCiudad(valor: Int) { + nivelCiudad = valor + RepositorioJugador.setNivelTaberna(valor) notifyObservers() } diff --git a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/efecto/EfectoDetallesCompra.kt b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/efecto/EfectoDetallesCompra.kt index ec065f9f0b9c9872604fca01d7c0a3695255fd3d..5e8e93ae27dfd6eef99cec91e359a62b07d0822d 100644 --- a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/efecto/EfectoDetallesCompra.kt +++ b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/efecto/EfectoDetallesCompra.kt @@ -9,10 +9,9 @@ import com.example.ellegadodepintia.exploradoresDePintia.ModalDetallesCompra import com.example.ellegadodepintia.exploradoresDePintia.model.GameState import com.example.ellegadodepintia.exploradoresDePintia.model.GameState.context import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.Objeto -import com.example.ellegadodepintia.repositorios.RepositorioJugador -class EfectoDetallesCompra(private val coste : Int,private val objeto: Objeto) : Efecto(100) { +class EfectoDetallesCompra(private val objeto: Objeto) : Efecto(100) { override fun ejecutar(): String { val mensaje = "Has investigado el objeto que te estan ofreciendo" @@ -25,7 +24,6 @@ class EfectoDetallesCompra(private val coste : Int,private val objeto: Objeto) : } val modalDetallesFragment = ModalDetallesCompra().apply { this.objeto = this@EfectoDetallesCompra.objeto - this.coste = this@EfectoDetallesCompra.coste this.onDismissListener = { accionRealizada -> if (accionRealizada) { ejecutarCompra() @@ -47,11 +45,10 @@ class EfectoDetallesCompra(private val coste : Int,private val objeto: Objeto) : salto.start() } - if (GameState.jugador.monedas < coste){ + if (GameState.jugador.monedas < objeto.coste){ "¡No tienes suficientes monedas para comprar el objeto!".also { context!!.findViewById<TextView>(R.id.textoResultado).text = it } }else{ - GameState.jugador.actualizarMonedas(GameState.jugador.monedas - coste) - RepositorioJugador.setMonedas(GameState.jugador.monedas) + GameState.jugador.actualizarMonedas(GameState.jugador.monedas - objeto.coste) GameState.jugador.conseguirObjeto(objeto) GameState.eventoActual.actualizarFinalizado(true) "¡El objeto ha sido agregado a tu inventario!".also { context!!.findViewById<TextView>(R.id.textoResultado).text = it } diff --git a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/eventoFactory/TiendaFactory.kt b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/eventoFactory/TiendaFactory.kt index cf3ec6a4968b2d28484e1c0ab98076f120aa0245..6324b19c15dd59d9dc24d8eb61cab1fdb77c858d 100644 --- a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/eventoFactory/TiendaFactory.kt +++ b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/eventoFactory/TiendaFactory.kt @@ -16,7 +16,6 @@ class TiendaFactory : EventoFactory { descripcion = "Ver Objeto", atributoRequerida = Atributo.Nula, EfectoDetallesCompra( - 5, RepositorioObjetos.obtenerObjetoPorNombre("Elixir Menor de la Necrópolis")!! ) ), Opcion( @@ -32,7 +31,6 @@ class TiendaFactory : EventoFactory { descripcion = "Ver Objeto", atributoRequerida = Atributo.Nula, EfectoDetallesCompra( - 8, RepositorioObjetos.obtenerObjetoPorNombre("Elixir Mediano de la Necrópolis")!! ) ), Opcion( @@ -48,7 +46,6 @@ class TiendaFactory : EventoFactory { descripcion = "Ver Objeto", atributoRequerida = Atributo.Nula, EfectoDetallesCompra( - 15, RepositorioObjetos.obtenerObjetoPorNombre("Elixir Supremo de la Necrópolis")!! ) ), Opcion( @@ -64,7 +61,6 @@ class TiendaFactory : EventoFactory { descripcion = "Ver Objeto", atributoRequerida = Atributo.Nula, EfectoDetallesCompra( - 50, RepositorioObjetos.obtenerObjetoPorNombre("Escudo Caetrae")!! ) ), Opcion( @@ -80,7 +76,6 @@ class TiendaFactory : EventoFactory { descripcion = "Ver Objeto", atributoRequerida = Atributo.Nula, EfectoDetallesCompra( - 40, RepositorioObjetos.obtenerObjetoPorNombre("Casco Ceremonial")!! ) ), Opcion( diff --git a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/Objeto.kt b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/Objeto.kt index a00e7a8027d01d187d0ef033e9787ce70d05d0ab..2e975ce19a884809304da94a672068d2d6e90e38 100644 --- a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/Objeto.kt +++ b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/Objeto.kt @@ -5,6 +5,7 @@ import java.io.Serializable abstract class Objeto ( val nombre: String, val descripcion: String, - val imagen : Int): Serializable { + val imagen : Int, + val coste: Int): Serializable { abstract fun usar() } \ No newline at end of file diff --git a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoConsumible.kt b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoConsumible.kt index fe76c3577c7da906f05e5e5f7f30a793cdc4d02b..dbf03ed674a03f4c737323af3bedebef1c3cf803 100644 --- a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoConsumible.kt +++ b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoConsumible.kt @@ -5,8 +5,8 @@ import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.efectoObje class ObjetoConsumible( nombre: String, descripcion: String, - val efecto: EfectoObjeto, imagen: Int, -) : Objeto(nombre, descripcion, imagen) { + val efecto: EfectoObjeto, imagen: Int, coste : Int +) : Objeto(nombre, descripcion, imagen, coste) { override fun usar() { efecto.ejecutar() diff --git a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoDeValor.kt b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoDeValor.kt index c434380705674280cdd816e23dada73ec6e4acf8..b71990a4ca31ff6026e94f180a845b616b10d5a1 100644 --- a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoDeValor.kt +++ b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoDeValor.kt @@ -6,8 +6,8 @@ open class ObjetoDeValor( nombre: String, descripcion: String, imagen: Int, - val coste: Int -) : Objeto(nombre, descripcion, imagen) { + coste: Int, +) : Objeto(nombre, descripcion, imagen, coste) { private val efecto: EfectoVender = EfectoVender(coste) diff --git a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoEquipable.kt b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoEquipable.kt index ef1274c9161164e06ac54f3e05dc044c715d5be8..acbe1cfa1ff773cc683fbb0b14decfa2fff900cf 100644 --- a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoEquipable.kt +++ b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoEquipable.kt @@ -7,9 +7,9 @@ import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.efectoObje class ObjetoEquipable( nombre: String, descripcion: String, - val efecto: EfectoObjeto, imagen: Int, + val efecto: EfectoObjeto, imagen: Int, coste : Int - ) : Objeto(nombre, descripcion, imagen) { + ) : Objeto(nombre, descripcion, imagen, coste) { override fun usar() { efecto.ejecutar() diff --git a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoUtilidad.kt b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoUtilidad.kt index c1603bb9fa68c5ff85bc0a6159b665e01110d0af..555607175483060fdd8bac73ee2eb2972db17c21 100644 --- a/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoUtilidad.kt +++ b/app/src/main/java/com/example/ellegadodepintia/exploradoresDePintia/model/objeto/ObjetoUtilidad.kt @@ -5,8 +5,8 @@ class ObjetoUtilidad( nombre: String, descripcion: String, imagen: Int, - - ) : Objeto(nombre, descripcion, imagen) { + coste : Int + ) : Objeto(nombre, descripcion, imagen, coste) { override fun usar() { } diff --git a/app/src/main/java/com/example/ellegadodepintia/repositorios/RepositorioJugador.kt b/app/src/main/java/com/example/ellegadodepintia/repositorios/RepositorioJugador.kt index ba597e8f6b590e080ee0fa5cb1be3de203c860b7..22ad0ac7d1b49e551fb011db0b54696cde8f58c3 100644 --- a/app/src/main/java/com/example/ellegadodepintia/repositorios/RepositorioJugador.kt +++ b/app/src/main/java/com/example/ellegadodepintia/repositorios/RepositorioJugador.kt @@ -58,6 +58,11 @@ object RepositorioJugador { userRef.set(hashMapOf("objetosArmeria" to objetosArmeria), SetOptions.merge()) } + fun setNivelTaberna(nivelCiudad : Int) { + val userRef = db.collection("users").document(email) + userRef.set(hashMapOf("nivelCiudad" to nivelCiudad), SetOptions.merge()) + } + fun cargarJugadores(callback: (List<PlayerLeaderBoard>) -> Unit) { db.collection("users") .get() diff --git a/app/src/main/java/com/example/ellegadodepintia/repositorios/RepositorioObjetos.kt b/app/src/main/java/com/example/ellegadodepintia/repositorios/RepositorioObjetos.kt index 7f086a2bde645737fe2fdb02350b6698a0c665c0..fd9787c8a2a65bbbff6e41ec97970acbf4062eec 100644 --- a/app/src/main/java/com/example/ellegadodepintia/repositorios/RepositorioObjetos.kt +++ b/app/src/main/java/com/example/ellegadodepintia/repositorios/RepositorioObjetos.kt @@ -20,20 +20,24 @@ object RepositorioObjetos { nombre = "Espada de Hierro", descripcion = "Una espada de hierro sencilla y confiable perfecta para un aventurero novato. Otorga 1 de daño extra", efecto = EfectoEquipableAumento(1, Atributo.Ataque), + coste = 20, imagen = R.drawable.asi_objeto_espadadefault - ), - ObjetoEquipable( - nombre = "Casco Ceremonial", - descripcion = "Casco ceremonial de oro de los vacceos decorado con intrincados patrones que simboliza el estatus social. Aumenta tu vida máxima en 3 puntos", - efecto = EfectoEquipableAumento(3, Atributo.Vida), - imagen = R.drawable.asi_objeto_casco + ), ObjetoEquipable( nombre = "Escudo Caetrae", - descripcion = "La caetrae es un escudo redondo vacceo, forjado para la defensa en combate, que aumenta tu vida máxima en 5 puntos.", - efecto = EfectoEquipableAumento(5, Atributo.Vida), + descripcion = "La caetrae es un escudo redondo vacceo, forjado para la defensa en combate, que aumenta tu vida máxima en 10 puntos.", + efecto = EfectoEquipableAumento(10, Atributo.Vida), + coste = 50, imagen = R.drawable.asi_objeto_escudo ), + ObjetoEquipable( + nombre = "Casco Ceremonial", + descripcion = "Casco ceremonial de oro de los vacceos decorado con intrincados patrones que simboliza el estatus social. Aumenta tu vida máxima en 8 puntos", + efecto = EfectoEquipableAumento(8, Atributo.Vida), + coste = 40, + imagen = R.drawable.asi_objeto_casco + ), ObjetoEquipable( nombre = "Puñal Vacceo", descripcion = "Espada corta, tÃpica de diseño celtibérico. Mientras está equipada añade la habilidad \"Letalidad\" para su uso en combate.", @@ -45,6 +49,7 @@ object RepositorioObjetos { energia = 2 ) ), + coste = 10, imagen = R.drawable.asi_objeto_daga ), //********************************************** @@ -54,24 +59,28 @@ object RepositorioObjetos { nombre = "Elixir Menor de la Necrópolis", descripcion = "Un frasco pequeño con un lÃquido granate y brillante, que destella con un resplandor profundo, capaz de restaurar 3 puntos de vida al instante.", efecto = EfectoObjetoCura(3), + coste = 5, imagen = R.drawable.asi_objeto_pocima_vida_5 ), ObjetoConsumible( nombre = "Elixir Mediano de la Necrópolis", descripcion = "Un frasco robusto con un lÃquido amarillo brillante, que resplandece como el sol al mediodÃa, capaz de restaurar 5 puntos de vida al instante.", efecto = EfectoObjetoCura(5), + coste = 8, imagen = R.drawable.asi_objeto_pocima_vida_10 ), ObjetoConsumible( nombre = "Elixir Supremo de la Necrópolis", descripcion = "Frasco supremo forjado con los secretos de los vacceos, restaura toda tu vitalidad al instante, ¡la poción de cura más poderosa de Pintia!", efecto = EfectoObjetoCura(999), + coste = 15, imagen = R.drawable.asi_objeto_pocima_vida_all ), ObjetoConsumible( nombre = "Poción de Veneno II", descripcion = "Según las leyendas, los vacceos preparaban este brebaje para impregnar sus armas, asegurando que incluso un rasguño pudiera derrotar a un enemigo. Hace 2 de daño al enemigo.", efecto = EfectoObjetoAtacar(2), + coste = 15, imagen = R.drawable.asi_objeto_veneno2 ), //********************************** @@ -82,6 +91,7 @@ object RepositorioObjetos { descripcion = "Objeto de gran valor. Se convierte en 10 monedas si consigues completar la partida.", coste = 10, imagen = R.drawable.asi_exploradores_vasito +>>>>>>> app/src/main/java/com/example/ellegadodepintia/repositorios/RepositorioObjetos.kt ), ObjetoDeValor( nombre = "Jabonera de cerámica", @@ -125,16 +135,19 @@ object RepositorioObjetos { ObjetoUtilidad( nombre = "Pico Vacceo", descripcion = "Un pico viejo y oscuro con dibujos extraños que parecen brillar cerca de las piedras, como si estuviera esperando que lo uses para algo importante.", + coste = 20, imagen = R.drawable.asi_objeto_pico ), ObjetoUtilidad( nombre = "Ticket", descripcion = "Representa una invitación a un evento relacionado con la cultura vaccea, como una feria arqueológica o un festival cultural", + coste = 20, imagen = R.drawable.asi_objeto_ticket ), ObjetoUtilidad( nombre = "Pala Vaccea", descripcion = "Una antigua pala con marcas de uso, forjada con madera resistente y un metal desgastado por el tiempo. Parece estar llena de historia.", + coste = 20, imagen = R.drawable.asi_objeto_pala ) ).associateBy { it.nombre } diff --git a/app/src/main/res/layout/activity_taberna.xml b/app/src/main/res/layout/activity_taberna.xml index 3908fb1317fbc5aa98f0f1653525338caf58f726..23dcc7b21da799ec172b494c08767118f3378984 100644 --- a/app/src/main/res/layout/activity_taberna.xml +++ b/app/src/main/res/layout/activity_taberna.xml @@ -32,7 +32,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="18dp" - android:text="Nivel Ciudad: 1" + android:text="Nivel actual: 1" android:textSize="30sp" android:fontFamily="@font/pixeled" android:layout_below="@id/tituloJuego" @@ -45,7 +45,7 @@ app:layout_constraintTop_toBottomOf="@id/tituloJuego"/> <TextView - android:id="@+id/textoNivelActual" + android:id="@+id/textoDescripcion" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginEnd="20dp" @@ -59,38 +59,48 @@ android:background="@drawable/style_texto_border" android:textColor="@color/pintiaTitleText" android:textStyle="bold" - android:layout_marginTop="80dp" + android:layout_marginTop="40dp" android:layout_centerHorizontal="true" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/nivelActual"/> - - <LinearLayout - android:layout_width="wrap_content" + <TextView + android:id="@+id/textoInformacion" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/style_confirmar_gradiente" + android:textAlignment="center" + android:layout_marginTop="40dp" + android:padding="18dp" + android:text="Aquà se informará al usuario" + android:textSize="16sp" + android:fontFamily="@font/pixeled" + android:layout_below="@id/tituloJuego" + android:background="@drawable/style_texto_border" + android:textColor="@color/pintiaTitleText" + android:textStyle="bold" + android:layout_centerHorizontal="true" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - android:layout_marginBottom="45dp" - android:layout_marginTop="80dp" - app:layout_constraintBottom_toTopOf="@id/bottom_navigation" - > - <Button - android:id="@+id/botonMejorar" - android:layout_width="350dp" - android:layout_height="wrap_content" - android:padding="18dp" - android:text="Mejorar" - android:textColor="@color/pintiaTitleText" - android:textSize="30sp" - android:background="@android:color/transparent" - android:fontFamily="@font/pixeled" - android:textStyle="bold" - /> - </LinearLayout> + app:layout_constraintTop_toBottomOf="@id/textoDescripcion" /> + <Button + android:id="@+id/botonMejorar" + android:layout_width="350dp" + android:layout_height="wrap_content" + android:layout_marginTop="40dp" + android:padding="18dp" + android:text="Mejorar" + android:textColor="@color/pintiaTitleText" + android:textSize="30sp" + android:backgroundTint="@color/pintiaButton" + android:fontFamily="@font/pixeled" + android:textStyle="bold" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/textoInformacion"/> + <LinearLayout android:id="@+id/bottom_navigation" style="?android:attr/buttonBarStyle" diff --git a/app/src/main/res/layout/modal_confirmacion.xml b/app/src/main/res/layout/modal_confirmacion.xml new file mode 100644 index 0000000000000000000000000000000000000000..cc304fe59e5502b2fd3e7cc799e056537d36a088 --- /dev/null +++ b/app/src/main/res/layout/modal_confirmacion.xml @@ -0,0 +1,107 @@ +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/style_background_gradiente" + android:padding="10dp" + tools:context=".exploradoresDePintia.ExploradoresDePintia" + tools:ignore="HardcodedText, UseCompoundDrawables,ButtonStyle" + > + + <LinearLayout + android:id="@+id/mainArea" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center" + android:orientation="vertical" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + <TextView + android:id="@+id/textoTitulo" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:fontFamily="@font/pixeled" + android:textAlignment="center" + android:text="Subida de nivel" + android:textColor="#6A0000" + android:layout_marginTop="10dp" + android:layout_marginBottom="10dp" + android:textSize="24sp" + android:textStyle="bold" + android:shadowColor="#000000" + android:shadowDx="2" + android:shadowDy="2" + android:shadowRadius="4" /> + + <View + android:layout_width="match_parent" + android:layout_height="1dp" + android:layout_marginBottom="10dp" + android:background="#000000" /> + + <TextView + android:id="@+id/textoInformacion" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:fontFamily="@font/pixeled" + android:text="Vas a mejorar la taberna por el coste de 50 monedas. ¿Estás seguro?" + android:textAlignment="center" + android:textColor="#000000" + android:layout_marginTop="10dp" + android:padding="8dp" + android:textSize="15sp" /> + + + + <LinearLayout + android:id="@+id/slotsInventario" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" + android:layout_marginTop="20dp" + android:orientation="horizontal"> + + <Button + android:id="@+id/botonMejorar" + android:layout_width="135dp" + android:layout_height="wrap_content" + android:backgroundTint="@color/pintiaButton" + android:textColor="@color/pintiaButtonText" + android:text="Mejorar" + android:fontFamily="@font/pixeled" + android:layout_marginEnd="10dp" + android:textStyle="bold"/> + + <Button + android:id="@+id/botonCancelar" + android:layout_width="135dp" + android:layout_height="wrap_content" + android:backgroundTint="#c44841" + android:textColor="@color/pintiaButtonText" + android:text="Cancelar" + android:fontFamily="@font/pixeled" + tools:ignore="HardcodedText" + android:textStyle="bold"/> + + </LinearLayout> + + <TextView + android:id="@+id/textoResultadoUso" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:fontFamily="@font/pixeled" + android:text="" + android:textAlignment="center" + android:textColor="#000000" + android:layout_marginTop="10dp" + android:padding="8dp" + android:textSize="15sp" /> + + + + </LinearLayout> + +</androidx.constraintlayout.widget.ConstraintLayout>