Skip to content

Instantly share code, notes, and snippets.

@wdhwg001
Last active October 22, 2015 04:14
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 wdhwg001/9f83c9c21754d538886e to your computer and use it in GitHub Desktop.
Save wdhwg001/9f83c9c21754d538886e to your computer and use it in GitHub Desktop.
Class.Monster = function(){
private.health;
public.attack = 300;
constructor = function(value){
health = value;
};
public.isAlive = function(){
return health > 0;
};
damaged = function(value){
health -= value;
if (health > 0){
return false;
}else{
revive();
return true;
}
};
private.revive = function(){
health = 500;
console.log('Monster Revived!');
};
attack = function(target) {
console.log('The monster attacks ' + target);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment