2021-06-17 06:45:45 +00:00
|
|
|
class Hunter {
|
|
|
|
constructor() {
|
|
|
|
this.position = 0;
|
2021-07-10 14:00:38 +00:00
|
|
|
this.isAlive = false;
|
2021-06-17 06:45:45 +00:00
|
|
|
}
|
|
|
|
|
2021-07-12 11:18:31 +00:00
|
|
|
getPosition() {
|
|
|
|
return this.position;
|
|
|
|
}
|
|
|
|
|
2021-06-17 16:33:16 +00:00
|
|
|
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;
|