Created
March 28, 2017 18:59
-
-
Save indie-rok/b840a8a2189f34777038b75c0ea3382d to your computer and use it in GitHub Desktop.
This file contains 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
function Pokemon(nombre,color,puntosAtaque){ | |
this.nombre = nombre; | |
this.color = color; | |
this.nivelDeAmistad = 0; | |
this.vida = 100; | |
this.puntosAtaque = puntosAtaque; | |
this.saludar = function(){ | |
console.log("Hola, me llamo " + this.nombre) | |
}; | |
this.pelear = function(pokemonObjeto){ | |
pokemonObjeto.vida = pokemonObjeto.vida - this.puntosAtaque | |
} | |
this.beber = function(tipoAlcohol){ | |
if(tipoAlcohol == "chelas"){ | |
this.nivelDeAmistad += 80 | |
} | |
else if (tipoAlcohol == "vodka") { | |
this.nivelDeAmistad += 10 | |
} | |
}; | |
} | |
var pikachu = new Pokemon("Pikachu","amarillo",80); | |
var charmander = new Pokemon("Charmander","rojo",30); | |
console.log(pikachu) | |
console.log(charmander) | |
pikachu.pelear(charmander) | |
console.log(charmander.vida) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment