-
-
Save wdhwg001/9f83c9c21754d538886e 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
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