Skip to content

Instantly share code, notes, and snippets.

@Tim-Machine
Created August 15, 2015 13:36
Show Gist options
  • Select an option

  • Save Tim-Machine/321bc775a99d2f48edd2 to your computer and use it in GitHub Desktop.

Select an option

Save Tim-Machine/321bc775a99d2f48edd2 to your computer and use it in GitHub Desktop.
function MedievalSoldier(type, weapon, attack) {
//properties:
this.type = type;
this.weapon = weapon; // some type of modifer
this.damage = 5;
this.level = 1;
//methods:
this.attack = null;
}
var mySolider = new MedievalSoldier("pikeman", "spear");
mysolider.protype.attack = function(){
return {
damage: 5 * (this.level + this.damage);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment