Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • diegval/el-legado-de-pintia
1 result
Show changes
Commits on Source (39)
Showing
with 382 additions and 59 deletions
......@@ -4,6 +4,14 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-11-24T14:04:03.259758866Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=RF8N1192C6J" />
</handle>
</Target>
</DropdownSelection>
<DialogSelection />
</SelectionState>
</selectionStates>
</component>
......
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -37,6 +37,7 @@
<activity android:name=".TabernaActivity" android:exported="true"/>
<activity android:name=".TiendaActivity" android:exported="true"/>
<activity android:name=".ArmeriaActivity" android:exported="true"/>
<activity android:name=".minijuego4.Minijuego4" android:exported="true"/>
</application>
</manifest>
\ No newline at end of file
......@@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity
import com.example.ellegadodepintia.minijuego1.InicioMinijuego1
import com.example.ellegadodepintia.minijuego2.Minijuego2
import com.example.ellegadodepintia.minijuego3.Minijuego3
import com.example.ellegadodepintia.minijuego4.Minijuego4
import com.example.ellegadodepintia.minijuegoInvestigacion.MinijuegoInvestigar
import com.example.ellegadodepintia.ruleta.Ruleta
import com.example.ellegadodepintia.minijuegoReparacion.MinijuegoReparacion
......@@ -27,6 +28,8 @@ class ListaMinijuegos : AppCompatActivity(){
val minijuego2Layout = findViewById<FrameLayout>(R.id.minijuego2)
minijuego2Layout.setOnClickListener {
val intent = Intent(this, Minijuego2::class.java)
val flag = true
intent.putExtra("FLAG_KEY", flag)
startActivity(intent)
}
......@@ -36,6 +39,7 @@ class ListaMinijuegos : AppCompatActivity(){
val intent = Intent(this, Minijuego3::class.java)
startActivity(intent)
}
// Minijuego Investigar
val minijuegoInvestigarLayout = findViewById<FrameLayout>(R.id.minijuegoInvestigar)
minijuegoInvestigarLayout.setOnClickListener {
......@@ -58,5 +62,12 @@ class ListaMinijuegos : AppCompatActivity(){
intent.putExtra("FLAG_KEY", flag)
startActivity(intent)
}
// Minijuego 4
val minijuego4Layout = findViewById<FrameLayout>(R.id.minijuego4)
minijuego4Layout.setOnClickListener {
val intent = Intent(this, Minijuego4::class.java)
startActivity(intent)
}
}
}
\ No newline at end of file
package com.example.ellegadodepintia.exploradoresDePintia
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.AnimationDrawable
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.MotionEvent
import android.view.View
import android.widget.GridLayout
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.ProgressBar
import android.widget.TextView
import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.example.ellegadodepintia.R
import com.example.ellegadodepintia.exploradoresDePintia.model.Atributo
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState
import com.example.ellegadodepintia.exploradoresDePintia.model.GeneradorDeEventos
import com.example.ellegadodepintia.exploradoresDePintia.model.LayoutUtils
import com.example.ellegadodepintia.exploradoresDePintia.model.GestorDeEventos
import com.example.ellegadodepintia.repositorios.RepositorioObjetos
import com.example.ellegadodepintia.soundManager.SoundManager
import java.lang.ref.WeakReference
class ExploradoresDePintia : AppCompatActivity() {
private lateinit var soundManager: SoundManager
private var dificultad = 0
private lateinit var startForResult: ActivityResultLauncher<Intent>
......@@ -29,12 +42,15 @@ class ExploradoresDePintia : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_exploradores_de_pintia)
startForResult = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val mensajeResultado = result.data?.getStringExtra("resultado")
println("Volvemos del mini-juego: $mensajeResultado")
soundManager = SoundManager(this)
//soundManager.playSoundLoop(R.raw.sound_exploradores_idle,100)
startForResult =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val mensajeResultado = result.data?.getStringExtra("resultado")
println("Volvemos del mini-juego: $mensajeResultado")
}
}
}
GameState.fragmentManager = supportFragmentManager
......@@ -69,6 +85,8 @@ class ExploradoresDePintia : AppCompatActivity() {
LayoutUtils.actualizarMonedas()
GeneradorDeEventos.generarEvento(dificultad)
GestorDeEventos.gestionar()
ListenerBarras()
}
@Deprecated("Deprecated in Java")
......@@ -77,9 +95,57 @@ class ExploradoresDePintia : AppCompatActivity() {
if (requestCode == 100 && resultCode == RESULT_OK) {
val resultado = data?.getStringExtra("resultado")
Toast.makeText(this, resultado, Toast.LENGTH_SHORT).show()
// Aquí puedes realizar acciones según el resultado
} else if (requestCode == 102 && resultCode == RESULT_OK) {
val puntuacion = data?.getStringExtra("PUNTUACION")!!.toInt()
GameState.jugador.actualizarAtributo(Atributo.Energia, puntuacion/3)
GameState.jugador.actualizarAtributo(Atributo.Vida, puntuacion/3)
} else if (requestCode == 103 && resultCode == RESULT_OK) {
val tiempo = data?.getStringExtra("TIEMPO")!!.toInt()
if (tiempo >= 1000){
GameState.jugador.actualizarMonedas(GameState.jugador.monedas.plus(tiempo/1000))
}else if (GameState.jugador.inventario.size == 0){
if (GameState.jugador.atributos[Atributo.Energia] == 1){
GameState.jugador.actualizarAtributo(Atributo.Energia, -1)
}else{
GameState.jugador.actualizarAtributo(Atributo.Energia, -GameState.jugador.atributos[Atributo.Energia]!!/2)
}
}else{
GameState.jugador.destruirObjetoRandom()
}
}else if (requestCode == 104 && resultCode == RESULT_OK) {
val puntosHuesos = data?.getStringExtra("PUNTOS_HUESOS")!!.toInt()
val objeto= RepositorioObjetos.obtenerObjetoPorCoste(puntosHuesos)
if (objeto != null){
GameState.jugador.conseguirObjeto(objeto)
}
}
}
override fun onDestroy() {
super.onDestroy()
soundManager.stopSound()
}
@SuppressLint("ClickableViewAccessibility")
private fun ListenerBarras() {
val barras: LinearLayout = findViewById(R.id.barras)
val estadisticas: GridLayout = findViewById(R.id.estadisticas)
barras.setOnTouchListener { v, event ->
when (event.action) {
MotionEvent.ACTION_DOWN -> {
Handler(Looper.getMainLooper()).postDelayed({
estadisticas.visibility = View.VISIBLE
}, 500) // 500 ms para que se registre como toque largo
}
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
// Ocultar el GridLayout si se termina el toque
estadisticas.visibility = View.GONE
}
}
true
}
}
}
......@@ -47,7 +47,7 @@ class ModalDetallesEnemigo : DialogFragment() {
}
}
if(GameState.jugador.atributos[Atributo.Investigacion]!! >= GameState.eventoActual.resistenciaMax){
if(GameState.jugador.atributos[Atributo.Investigacion]!! >= GameState.eventoActual.resistenciaActual/2){
view.findViewById<TextView>(R.id.textoVidaMaxima).text = buildString {
append("Vida: ")
append(GameState.eventoActual.resistenciaActual)
......
......@@ -5,5 +5,6 @@ enum class Atributo {
Ataque,
Investigacion,
Energia,
Nula
Nula,
Critico
}
\ No newline at end of file
......@@ -8,29 +8,88 @@ import com.example.ellegadodepintia.exploradoresDePintia.model.GameState.context
import com.example.ellegadodepintia.exploradoresDePintia.model.eventoFactory.Evento
import com.example.ellegadodepintia.exploradoresDePintia.model.eventoFactory.EventoCombate
import com.example.ellegadodepintia.exploradoresDePintia.model.eventoFactory.EventoFactorySelector
import kotlin.random.Random
object GeneradorDeEventos {
private const val CANTIDAD = 6 // Numero de eventos generados
private const val CANTIDAD = 10 // Numero de eventos generados
private var eventos = ArrayList<Evento>()
private fun crearEvento(): Evento {
val factory = EventoFactorySelector.obtenerFactory()
return factory.generarEvento()
}
private val pesosBase = mutableMapOf(
TipoEvento.Reliquia to 0.20,
TipoEvento.Tienda to 0.1,
TipoEvento.Riesgo to 0.2,
TipoEvento.Trampa to 0.1,
TipoEvento.Combate to 0.20,
TipoEvento.Descanso to 0.0,
TipoEvento.Ladron to 0.1,
TipoEvento.Desenterrar to 0.1
)
private var historialTipos = mutableListOf<TipoEvento>()
fun generarEventos() {
val eventosGenerados = ArrayList<Evento>()
historialTipos = mutableListOf()
while (eventosGenerados.size < CANTIDAD) {
val nuevoEvento = crearEvento()
val tipoSeleccionado = seleccionarTipoEvento()
println(historialTipos)
/*if (historialTipos.isNotEmpty() && tipoSeleccionado == historialTipos.last()) {
continue
}*/
val nuevoEvento = EventoFactorySelector.obtenerFactory(tipoSeleccionado).generarEvento()
if (!eventosGenerados.contains(nuevoEvento)) {
eventosGenerados.add(nuevoEvento)
historialTipos.add(tipoSeleccionado)
}
}
eventos = eventosGenerados
}
private fun seleccionarTipoEvento(): TipoEvento {
val pesosActuales = pesosBase.toMutableMap()
// 20% Descanso tras dos riegsos en los últimos 3 eventos
val recientes = historialTipos.takeLast(3)
if (recientes.count { it == TipoEvento.Riesgo } >= 2) {
pesosActuales[TipoEvento.Tienda] = pesosActuales[TipoEvento.Tienda]!! + 0.2
// 25% Ladron si 2 reliquias
}else if(recientes.count{it == TipoEvento.Reliquia} >= 2){
pesosActuales[TipoEvento.Ladron] = 0.25
}
// 35% Prob de descanso tras combate 20% Tienda 10% Combate
val ultimoTipo = historialTipos.lastOrNull()
if (ultimoTipo == TipoEvento.Combate) {
pesosActuales[TipoEvento.Descanso] = 0.35
pesosActuales[TipoEvento.Tienda] = 0.2
pesosActuales[TipoEvento.Combate] = 0.1
// 30% Prob de combate tras desenterrar
}else if (ultimoTipo == TipoEvento.Desenterrar){
pesosActuales[TipoEvento.Combate] = 0.3
}
val totalPesos = pesosActuales.values.sum()
val probabilidadesNormalizadas = pesosActuales.mapValues { it.value / totalPesos }
val acumulado = probabilidadesNormalizadas.entries.fold(mutableListOf<Pair<Double, TipoEvento>>()) { acc, entry ->
val sumaAcumulada = acc.lastOrNull()?.first ?: 0.0
acc.add(Pair(sumaAcumulada + entry.value, entry.key))
acc
}
val random = Random.nextDouble()
val tipoSeleccionado = acumulado.first { random <= it.first }.second
return tipoSeleccionado
}
fun comprobarEventoDisponible() : Boolean{
return eventos.size >= 1
}
......@@ -66,7 +125,13 @@ object GeneradorDeEventos {
private fun filtrarEventosPorDificultad(eventos: ArrayList<Evento>, dificultad: Int): Evento {
val eventosFiltrados = eventos.filter { it.dificultad == dificultad }
return eventosFiltrados[eventosFiltrados.indices.random()]
return eventosFiltrados[eventosFiltrados.indices.first]
}
fun insertarCombate() {
val nuevoCombate = EventoFactorySelector.obtenerFactory(TipoEvento.Combate).generarEvento()
eventos.add(0, nuevoCombate)
historialTipos.add(0, TipoEvento.Combate)
}
......
package com.example.ellegadodepintia.exploradoresDePintia.model
import android.animation.ObjectAnimator
import android.graphics.drawable.AnimationDrawable
import android.os.Handler
import android.os.Looper
......@@ -10,12 +11,14 @@ import com.example.ellegadodepintia.R
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState.context
import com.example.ellegadodepintia.exploradoresDePintia.model.efecto.Efecto
import com.example.ellegadodepintia.exploradoresDePintia.model.efecto.EfectoInvestigarEnemigo
import com.example.ellegadodepintia.exploradoresDePintia.model.efecto.EfectoRegeneracionEnemigo
import com.example.ellegadodepintia.exploradoresDePintia.model.efecto.EfectoRevivirEnemigo
import com.example.ellegadodepintia.exploradoresDePintia.model.eventoFactory.EventoCombate
import com.example.ellegadodepintia.exploradoresDePintia.model.habilidad.efectoHabilidad.EfectoHabilidad
object GestorCombate {
lateinit var evento : EventoCombate
lateinit var evento: EventoCombate
private var turnoJugador = true
fun cargarAnimacionesAtaqueProtagonista() {
......@@ -62,10 +65,28 @@ object GestorCombate {
}, ataqueDuracion.toLong())
}
fun calcularAtaque(ataqueBase: Int): Int {
fun cargarAnimacionsRegeneracionEnemigo() {
val imagenEvento = context!!.findViewById<ImageView>(R.id.imagenEvento)
val imagenEfecto = context!!.findViewById<ImageView>(R.id.imagenEfectoEvento)
imagenEvento?.let {
val salto = ObjectAnimator.ofFloat(it, "translationY", 0f, -40f, 0f)
salto.duration = 300
salto.start()
imagenEfecto?.setImageResource(R.drawable.effect_regeneracion_animation)
val efectoAnimacion = imagenEfecto?.drawable as? AnimationDrawable
efectoAnimacion?.start()
Handler(Looper.getMainLooper()).postDelayed({
imagenEfecto?.setImageDrawable(null)
}, 600)
}
}
fun calcularAtaque(ataqueBase: Int, probabilidadCritico: Int): Int {
val ataqueFinal: Int
val resultadoTirada = (0..100).random()
ataqueFinal = if (resultadoTirada <= 8) {
ataqueFinal = if (resultadoTirada <= probabilidadCritico) {
ataqueBase * 2
} else {
ataqueBase
......@@ -79,14 +100,35 @@ object GestorCombate {
accionEnemigo()
}, 800)
} else {
evento.actualizarFinalizado(true)
turnoJugador = true
"¡Enhorabuena has acabado con el monstruo!".also {
context!!.findViewById<TextView>(R.id.textoResultado).text = it
if (revivirEnemigo() == "Fallo") {
evento.actualizarFinalizado(true)
if (evento.resistenciaActual <= 0) {
GameState.jugador.conseguirObjeto(evento.recompensa)
Handler(Looper.getMainLooper()).postDelayed({
"¡Enhorabuena has acabado con el monstruo!\n Te das cuenta que defendía un/una ${evento.recompensa.nombre}".also {
context!!.findViewById<TextView>(R.id.textoResultado).text = it
}
}, 200)
}
}
}
}
private fun revivirEnemigo(): String {
var mensaje = "Fallo"
val tieneRevivir = evento.acciones.any { it is EfectoRevivirEnemigo }
if (tieneRevivir) {
mensaje = evento.acciones.filterIsInstance<EfectoRevivirEnemigo>().first().ejecutar()
Handler(Looper.getMainLooper()).postDelayed({
val textoResultado = context!!.findViewById<TextView>(R.id.textoResultado)
"${textoResultado.text} \n\n $mensaje".also { textoResultado.text = it }
}, 200)
}
return mensaje
}
fun accionProtagonista(efecto: Efecto): String {
val mensaje: String
if (turnoJugador) {
......@@ -104,36 +146,50 @@ object GestorCombate {
fun habilidadProtagonista(nombre: String, efecto: EfectoHabilidad, energia: Int) {
val textoResultado = context!!.findViewById<TextView>(R.id.textoResultado)
if(GameState.jugador.atributos[Atributo.Energia]!! >= energia){
if (GameState.jugador.atributos[Atributo.Energia]!! >= energia) {
turnoJugador = false
"${textoResultado.text} \n\n Se ha utilizado $nombre".also { textoResultado.text = it }
restarTurnoBuffos()
efecto.ejecutar()
GameState.jugador.actualizarAtributo(Atributo.Energia, -energia)
comenzarAccionEnemigo()
}else{
} else {
"${textoResultado.text} \n\n Energía insuficiente".also { textoResultado.text = it }
}
}
private fun restarTurnoBuffos(){
private fun restarTurnoBuffos() {
for (buffo in GameState.jugador.buffos) {
buffo.pasarTurno()
buffo.pasarTurno()
}
}
private fun accionEnemigo(){
val textoResultado = context!!.findViewById<TextView>(R.id.textoResultado)
val efectoAtaque = evento.acciones.random().ejecutar()
if(GameState.jugador.atributos[Atributo.Vida]!! <= 0){
Handler(Looper.getMainLooper()).postDelayed({
turnoJugador = true
}, 2000)
} else {
private fun accionEnemigo() {
val textoResultado = context!!.findViewById<TextView>(R.id.textoResultado)
val efectoAtaque = seleccionarAccionEnemigo().ejecutar()
if (GameState.jugador.atributos[Atributo.Vida]!! <= 0) {
Handler(Looper.getMainLooper()).postDelayed({
turnoJugador = true
"${textoResultado.text} \n\n $efectoAtaque".also { textoResultado.text = it }
}
}, 2000)
} else {
turnoJugador = true
"${textoResultado.text} \n\n $efectoAtaque".also { textoResultado.text = it }
}
}
private fun seleccionarAccionEnemigo(): Efecto {
val tieneRecuperacion = evento.acciones.any { it is EfectoRegeneracionEnemigo }
val porcentajeVida =
GameState.eventoActual.resistenciaActual / GameState.eventoActual.resistenciaMax.toDouble()
return if (tieneRecuperacion && porcentajeVida <= 0.3) {
evento.acciones.filterNot { it is EfectoRevivirEnemigo }.random()
} else {
evento.acciones.filterNot {
it is EfectoRegeneracionEnemigo ||
it is EfectoRevivirEnemigo
}.random()
}
}
}
\ No newline at end of file
......@@ -126,5 +126,4 @@ object GestorDeEventos{
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import com.example.ellegadodepintia.exploradoresDePintia.model.habilidad.efectoH
import com.example.ellegadodepintia.exploradoresDePintia.model.habilidad.efectoHabilidad.EfectoBuffo
import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.Objeto
import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.ObjetoEquipable
import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.ObjetoUtilidad
import com.example.ellegadodepintia.repositorios.RepositorioJugador
import com.example.ellegadodepintia.repositorios.RepositorioObjetos
......@@ -35,6 +36,9 @@ class Jugador {
atributos[Atributo.Ataque] = 1
atributos[Atributo.Investigacion] = 1
atributos[Atributo.Energia] = 10
atributos[Atributo.Critico] = 8
inventario.add(RepositorioObjetos.obtenerObjetoPorNombre("Puñal Vacceo")!!)
habilidades.add(
Habilidad(
......@@ -53,7 +57,6 @@ class Jugador {
3
)
)
/*habilidades.add(
Habilidad(
nombre = "Revitalización Floral",
......@@ -78,6 +81,12 @@ class Jugador {
fun actualizarAtributo(atributo: Atributo, valor: Int) {
atributos[atributo] = atributos[atributo]!!.plus(valor)
if (atributo == Atributo.Vida && atributos[atributo]!! >= vidaMax){
atributos[atributo] = vidaMax
}
if (atributo == Atributo.Energia && atributos[atributo]!! >= energiaMax){
atributos[atributo] = energiaMax
}
notifyObservers()
if (atributo == Atributo.Vida && atributos[atributo]!! <= 0) {
"¡Has sido derrotado!".also {
......@@ -178,4 +187,10 @@ class Jugador {
actualizarObjetosTienda(nivelCiudad*2)
}
fun destruirObjetoRandom(){
val randomIndex = (0..inventario.size.minus(1)).random()
inventario.removeAt(randomIndex)
notifyObservers()
}
}
......@@ -12,7 +12,7 @@ import com.example.ellegadodepintia.R
import com.example.ellegadodepintia.exploradoresDePintia.ModalDetallesFragment
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState.context
import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.Objeto
import android.animation.ObjectAnimator
object LayoutUtils {
......@@ -20,49 +20,63 @@ object LayoutUtils {
fun actualizarEstadisticasMain() {
if (context is Activity) {
val barraVida = context!!.findViewById<ProgressBar>(R.id.barraVida)
val barraEnergia = context!!.findViewById<ProgressBar>(R.id.barraEnergia)
val ataqueText = context!!.findViewById<TextView>(R.id.ataqueText)
val investigacionText = context!!.findViewById<TextView>(R.id.investigacionText)
val vidaText = context!!.findViewById<TextView>(R.id.vidaText)
val energiaText = context!!.findViewById<TextView>(R.id.EnergiaText)
actualizarJugador(barraVida, ataqueText, investigacionText, vidaText, energiaText)
actualizarJugador(barraVida, ataqueText, investigacionText, vidaText, energiaText, barraEnergia)
}
}
fun actualizarEstadisticasInventario(view: View) {
val barraVida = view.findViewById<ProgressBar>(R.id.barraVida)
val barraEnergia = context!!.findViewById<ProgressBar>(R.id.barraEnergia)
val ataqueText = view.findViewById<TextView>(R.id.ataqueText)
val investigacionText = view.findViewById<TextView>(R.id.investigacionText)
val vidaText = view.findViewById<TextView>(R.id.vidaText)
val energiaText = view.findViewById<TextView>(R.id.EnergiaText)
actualizarJugador(barraVida, ataqueText, investigacionText, vidaText, energiaText)
actualizarJugador(barraVida, ataqueText, investigacionText, vidaText, energiaText, barraEnergia)
}
private fun actualizarJugador(
barraVida: ProgressBar,
ataqueText: TextView,
investigacionText: TextView,
vidaText: TextView,
energiaText: TextView
energiaText: TextView,
barraEnergia: ProgressBar
) {
barraVida.max = GameState.jugador.vidaMax
barraVida.progress = GameState.jugador.atributos[Atributo.Vida]!!
val vidaMax = GameState.jugador.vidaMax
val vidaActual = GameState.jugador.atributos[Atributo.Vida]!!
if (barraVida.progress != vidaActual) {
ObjectAnimator.ofInt(barraVida, "progress", barraVida.progress, vidaActual).apply {
duration = 1000
start()
}
}
barraVida.max = vidaMax
ataqueText.text = "${GameState.jugador.atributos[Atributo.Ataque]}"
investigacionText.text = "${GameState.jugador.atributos[Atributo.Investigacion]}"
val vidaInfo =
"${GameState.jugador.atributos[Atributo.Vida]}/${GameState.jugador.vidaMax}"
val vidaInfo = "$vidaActual/$vidaMax"
vidaText.text = vidaInfo
val energiaInfo =
"${GameState.jugador.atributos[Atributo.Energia]}/${GameState.jugador.energiaMax}"
val energiaMax = GameState.jugador.energiaMax
val energiaActual = GameState.jugador.atributos[Atributo.Energia]!!
if (barraEnergia.progress != energiaActual) {
ObjectAnimator.ofInt(barraEnergia, "progress", barraEnergia.progress, energiaActual).apply {
duration = 500
start()
}
}
barraEnergia.max = energiaMax
val energiaInfo = "$energiaActual/$energiaMax"
energiaText.text = energiaInfo
}
fun actualizarEstadisticasEvento() {
val barraEvento = context!!.findViewById<ProgressBar>(R.id.barraEvento)
barraEvento.max = GameState.eventoActual.resistenciaMax
barraEvento.progress = GameState.eventoActual.resistenciaActual
......
......@@ -6,11 +6,15 @@ enum class TipoEvento {
Tienda,
Trampa,
Riesgo,
Descanso,
Ladron,
Desenterrar
}
/*Trampa,
/*
Aliado,
Misterio,
Magia,
Puzzle,
Enfermedad,
EleccionMoral,*/
}
EleccionMoral,*/
\ No newline at end of file
......@@ -14,7 +14,7 @@ class EfectoAtaqueEnemigo(probabilidadExito: Int) : Efecto(probabilidadExito) {
GestorCombate.cargarAnimacionesAtaqueEnemigo()
if (probabilidadEnemigo <= probabilidadExito) {
val ataqueReal = GestorCombate.calcularAtaque(evento.ataque)
val ataqueReal = GestorCombate.calcularAtaque(evento.ataque, evento.probCritico)
GameState.jugador.actualizarAtributo(Atributo.Vida, -ataqueReal)
......
......@@ -11,11 +11,11 @@ class EfectoAtaqueProtagonista(probabilidadExito: Int) : Efecto(probabilidadExit
if (probabilidadPersonaje <= probabilidadExito) {
GestorCombate.cargarAnimacionesAtaqueProtagonista()
val ataqueReal = GestorCombate.calcularAtaque(GameState.jugador.atributos[Atributo.Ataque]!!)
val ataqueReal = GestorCombate.calcularAtaque(GameState.jugador.atributos[Atributo.Ataque]!!, GameState.jugador.atributos[Atributo.Critico]!!)
GameState.eventoActual.actualizarResistencia(-ataqueReal)
mensaje = "¡Ataque realizado con éxito has hecho $ataqueReal de daño"
} else {
mensaje = "El enemigo ha aguantado el golpe, recibe 0 de daño"
mensaje = "Has fallado el golpe, recibe 0 de daño"
}
return mensaje
}
......
package com.example.ellegadodepintia.exploradoresDePintia.model.efecto
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState
import com.example.ellegadodepintia.exploradoresDePintia.model.GestorCombate
import com.example.ellegadodepintia.exploradoresDePintia.model.Atributo
import com.example.ellegadodepintia.exploradoresDePintia.model.eventoFactory.EventoCombate
class EfectoCriticoAutomaticoEnemigo(private val stringExito: String) :
Efecto(100) {
override fun ejecutar(): String {
val evento = GameState.eventoActual as? EventoCombate ?: return "No es un evento de combate"
GestorCombate.cargarAnimacionesAtaqueEnemigo()
val ataqueReal = GestorCombate.calcularAtaque(evento.ataque, 35)
GameState.jugador.actualizarAtributo(Atributo.Vida, -ataqueReal)
return stringExito
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import com.example.ellegadodepintia.R
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState.context
import com.example.ellegadodepintia.exploradoresDePintia.model.Atributo
import com.example.ellegadodepintia.exploradoresDePintia.model.GeneradorDeEventos
import com.example.ellegadodepintia.exploradoresDePintia.model.objeto.ObjetoDeValor
//TODO() Agregar inventario con restos de la reliquia
......@@ -42,7 +43,13 @@ class EfectoDestruir(probabilidadExito: Int) : Efecto(probabilidadExito) {
coste = 5
)
)
"¡Qué has hecho, la reliquia se ha roto por completo!. Has conseguido un fragmento de la reliquia"
val probabilidadCombate = (0..1).random()
if(probabilidadCombate <= 60){
GeneradorDeEventos.insertarCombate()
"¡Qué has hecho, la reliquia se ha roto por completo!. Has conseguido un fragmento de la reliquia. Parece que un enemigo te ha visto, ¡el próximo evento será un combate!"
}else{
"¡Qué has hecho, la reliquia se ha roto por completo!. Has conseguido un fragmento de la reliquia"
}
}
} else {
"La reliquia ha resistido el golpe con éxito."
......
package com.example.ellegadodepintia.exploradoresDePintia.model.efecto
import android.content.Intent
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState.context
import com.example.ellegadodepintia.minijuego3.Minijuego3
class EfectoLadron() : Efecto(100) {
override fun ejecutar(): String {
val intent = Intent(context, Minijuego3::class.java)
context!!.startActivityForResult(intent, 103)
GameState.eventoActual.actualizarFinalizado(true)
return "Si has logrado completar el minijuego, habrás obtenido monedas. Si no, el ladrón se habrá llevado un objeto de tu inventario y, si no poseías ninguno, tu energía se ha reducido a la mitad"
}
}
\ No newline at end of file
package com.example.ellegadodepintia.exploradoresDePintia.model.efecto
import android.content.Intent
import com.example.ellegadodepintia.exploradoresDePintia.model.Atributo
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState.context
import com.example.ellegadodepintia.minijuego2.Minijuego2
class EfectoNubeVaccea() : Efecto(100) {
override fun ejecutar(): String {
if (GameState.jugador.atributos[Atributo.Energia] == GameState.jugador.energiaMax &&
GameState.jugador.atributos[Atributo.Vida] == GameState.jugador.vidaMax){
return "Tienes la vida y la energía al máximo. ¡No necesitas descansar!"
}
val intent = Intent(context, Minijuego2::class.java)
context!!.startActivityForResult(intent, 102)
GameState.eventoActual.actualizarFinalizado(true)
return "Has descansado"
}
}
\ No newline at end of file
package com.example.ellegadodepintia.exploradoresDePintia.model.efecto
import com.example.ellegadodepintia.exploradoresDePintia.model.GameState
import com.example.ellegadodepintia.exploradoresDePintia.model.GestorCombate
class EfectoRegeneracionEnemigo(private val mensajeCuracion: String,private val cantidad: Int) : Efecto(100) {
override fun ejecutar(): String {
GestorCombate.cargarAnimacionsRegeneracionEnemigo()
GameState.eventoActual.actualizarResistencia(cantidad)
return mensajeCuracion
}
}
\ No newline at end of file