Last active
August 27, 2024 03:27
-
-
Save diego-novoa/42080ce5f08bc37a0981a81a7c8d985f to your computer and use it in GitHub Desktop.
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"], | |
| }; | |
| let contadorPuntosJug1 = 0; | |
| let contadorPuntosJug2 = 0; | |
| let ganador; | |
| //ataque | |
| if (jugadorUno.habilidades.ataque > jugadorDos.habilidades.ataque) { | |
| contadorPuntosJug1 = contadorPuntosJug1 + 1; | |
| } else if (jugadorUno.habilidades.ataque < jugadorDos.habilidades.ataque) { | |
| contadorPuntosJug2++; | |
| } else { | |
| contadorPuntosJug1++; | |
| contadorPuntosJug2++; | |
| } | |
| // velocidad | |
| if (jugadorUno.habilidades.velocidad > jugadorDos.habilidades.velocidad) { | |
| contadorPuntosJug1 = contadorPuntosJug1 + 1; | |
| } else if ( | |
| jugadorUno.habilidades.velocidad < jugadorDos.habilidades.velocidad | |
| ) { | |
| contadorPuntosJug2++; | |
| } else { | |
| contadorPuntosJug1++; | |
| contadorPuntosJug2++; | |
| } | |
| // vida | |
| if (jugadorUno.habilidades.vida > jugadorDos.habilidades.vida) { | |
| contadorPuntosJug1 = contadorPuntosJug1 + 1; | |
| } else if (jugadorUno.habilidades.vida < jugadorDos.habilidades.vida) { | |
| contadorPuntosJug2++; | |
| } else { | |
| contadorPuntosJug1++; | |
| contadorPuntosJug2++; | |
| } | |
| // magia | |
| if (jugadorUno.habilidades.magia > jugadorDos.habilidades.magia) { | |
| contadorPuntosJug1 = contadorPuntosJug1 + 1; | |
| } else if (jugadorUno.habilidades.magia < jugadorDos.habilidades.magia) { | |
| contadorPuntosJug2++; | |
| } else { | |
| contadorPuntosJug1++; | |
| contadorPuntosJug2++; | |
| } | |
| //articulos | |
| if (jugadorUno.articulos.length > jugadorDos.articulos.length) { | |
| contadorPuntosJug1 = contadorPuntosJug1 + 1; | |
| } else if (jugadorUno.articulos.length < jugadorDos.articulos.length) { | |
| contadorPuntosJug2++; | |
| } else { | |
| contadorPuntosJug1++; | |
| contadorPuntosJug2++; | |
| } | |
| //Ganador | |
| if (contadorPuntosJug1 > contadorPuntosJug2) { | |
| winnerName = jugadorUno.nombre; | |
| } else if (contadorPuntosJug2 > contadorPuntosJug1) { | |
| winnerName = jugadorDos.nombre; | |
| } else { | |
| winnerName = "Empate"; | |
| } | |
| var resultado = { | |
| [jugadorUno.nombre]: contadorPuntosJug1, | |
| [jugadorDos.nombre]: contadorPuntosJug2, | |
| ganador: winnerName, | |
| }; | |
| console.log(resultado); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment