Last active
March 17, 2017 06:39
-
-
Save MarcoWorms/4e63ab42d70cf955ae7254b93c3814ab to your computer and use it in GitHub Desktop.
Closure 4
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 player (forca, stamina, agilidade) { | |
var hp = stamina * 10 | |
function umaFuncaoPrivadaGrande (que, recebe, varios, parametros) { | |
// essa função é um método privado de um objeto. | |
// você pode chamar ela quando precisar ou até torná-la pública | |
} | |
return { | |
umaFuncaoPublicaGrande: umaFuncaoPrivadaGrande, | |
tomarDano: function (dano) { | |
hp -= dano | |
}, | |
danoEmBatalha: function () { | |
return forca * 2 | |
}, | |
chanceDeEsquiva: function () { | |
return agilidade/100 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment