Projektmanagement-Game/Webservice/Hunter.js

24 lines
466 B
JavaScript
Raw Permalink Normal View History

2021-06-17 06:45:45 +00:00
class Hunter {
constructor() {
this.position = 0;
this.isAlive = false;
2021-06-17 06:45:45 +00:00
}
2021-07-12 11:18:31 +00:00
getPosition() {
return this.position;
}
move_by(amount) {
2021-06-17 06:45:45 +00:00
this.position += amount;
}
hunt(playerArray) {
for (let i = 0; i < playerArray.length; i++) {
2021-07-12 11:18:31 +00:00
if (playerArray[i].position <= this.position - 1) {
2021-06-17 06:45:45 +00:00
playerArray[i].isAlive = false;
}
}
}
}
module.exports = Hunter;