Created
June 25, 2025 18:29
-
-
Save alexmktdev/6ec40bf9864dc9368eddefc06afcb583 to your computer and use it in GitHub Desktop.
Entrega desafio Modulo 0 APX School
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jugadorUno = { | |
nombre: "Marce", | |
habilidades: { | |
ataque: 70, | |
velocidad: 30, | |
vida: 60, | |
magia: 120, | |
}, | |
articulos: ["espada", "escudo", "varita"], | |
}; | |
const jugadorDos = { | |
nombre: "Flor", | |
habilidades: { | |
ataque: 73, | |
velocidad: 30, | |
vida: 80, | |
magia: 100, | |
}, | |
articulos: ["escudo", "varita", "capa", "pocion"], | |
}; | |
// contador de puntaje de ambos jugadores | |
let contadorPuntosJug1 = 0; | |
let contadorPuntosJug2 = 0; | |
//Ganador: | |
let ganador; | |
// comparacion por ataque | |
if (jugadorUno.habilidades.ataque > jugadorDos.habilidades.ataque) { | |
contadorPuntosJug1 = contadorPuntosJug1 + 1; | |
} else if (jugadorDos.habilidades.ataque > jugadorUno.habilidades.ataque) { | |
contadorPuntosJug2++; | |
} else { | |
contadorPuntosJug1++; | |
contadorPuntosJug2++; | |
} | |
// comparacion por velocidad | |
if (jugadorUno.habilidades.velocidad > jugadorDos.habilidades.velocidad) { | |
contadorPuntosJug1 = contadorPuntosJug1 + 1; | |
} else if (jugadorDos.habilidades.velocidad > jugadorUno.habilidades.velocidad) { | |
contadorPuntosJug2++; | |
} else { | |
contadorPuntosJug1++; | |
contadorPuntosJug2++; | |
} | |
// comparacion por nivel de vida | |
if (jugadorUno.habilidades.vida > jugadorDos.habilidades.vida) { | |
contadorPuntosJug1 = contadorPuntosJug1 + 1; | |
} else if (jugadorDos.habilidades.vida > jugadorUno.habilidades.vida) { | |
contadorPuntosJug2++; | |
} else { | |
contadorPuntosJug1++; | |
contadorPuntosJug2++; | |
} | |
// comparacion por magia | |
if (jugadorUno.habilidades.magia> jugadorDos.habilidades.magia) { | |
contadorPuntosJug1 = contadorPuntosJug1 + 1; | |
} else if (jugadorDos.habilidades.magia > jugadorUno.habilidades.magia) { | |
contadorPuntosJug2++; | |
} else { | |
contadorPuntosJug1++; | |
contadorPuntosJug2++; | |
} | |
// comparacion por cantidad de articulos | |
if(jugadorUno.articulos.length > jugadorDos.articulos.length){ | |
contadorPuntosJug1++; | |
} else if (jugadorDos.articulos.length > jugadorUno.articulos.length){ | |
contadorPuntosJug2++; | |
} else { | |
contadorPuntosJug1++; | |
contadorPuntosJug2++; | |
} | |
// comparacion final de puntos | |
if(contadorPuntosJug1 > contadorPuntosJug2){ | |
var resultado = { | |
[jugadorUno.nombre]: contadorPuntosJug1, | |
[jugadorDos.nombre]: contadorPuntosJug2, | |
ganador: jugadorUno.nombre | |
} | |
} else if(contadorPuntosJug2 > contadorPuntosJug1){ | |
var resultado = { | |
[jugadorUno.nombre]:contadorPuntosJug1, | |
[jugadorDos.nombre]: contadorPuntosJug2, | |
ganador: jugadorDos.nombre | |
} | |
} else { | |
var resultado = { | |
[jugadorUno.nombre]: contadorPuntosJug1, | |
[jugadorDos.nombre]: contadorPuntosJug2, | |
ganador: "empate" | |
} | |
} | |
console.log(resultado); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment