Extracted classes from server.js
This commit is contained in:
19
Webservice/Hunter.js
Normal file
19
Webservice/Hunter.js
Normal file
@@ -0,0 +1,19 @@
|
||||
class Hunter {
|
||||
constructor() {
|
||||
this.position = 0;
|
||||
}
|
||||
|
||||
move(amount) {
|
||||
this.position += amount;
|
||||
}
|
||||
|
||||
hunt(playerArray) {
|
||||
for (let i = 0; i < playerArray.length; i++) {
|
||||
if (playerArray[i].position <= this.position) {
|
||||
playerArray[i].isAlive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Hunter;
|
||||
Reference in New Issue
Block a user