Created
June 22, 2019 04:31
-
-
Save jsmanifest/55726260275d3f23516676618865bd70 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const characters = [] | |
const Warrior = function createWarrior(name) { | |
this.name = name | |
this.hp = 100 | |
this.mp = 100 | |
this.defence = 60 | |
return { | |
// Slash the enemy, decreasing their hp down by 35 | |
slash(target) { | |
target.hp -= 35 | |
return target | |
}, | |
// Increases the warrior's defence by 100 for 40 seconds. | |
// Each second will decrement their defence by 1 as the time runs out. | |
battleCry() { | |
this.defence += 100 | |
this.battleCryInterval = setInterval(() => { | |
this.defence -= 1 | |
}, 1000) | |
this.battleCryTimeout = setTimeout(() => { | |
this.defence = 60 | |
}, 40000) | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment