Skip to content

Instantly share code, notes, and snippets.

@indie-rok
Created March 28, 2017 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indie-rok/b840a8a2189f34777038b75c0ea3382d to your computer and use it in GitHub Desktop.
Save indie-rok/b840a8a2189f34777038b75c0ea3382d to your computer and use it in GitHub Desktop.
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