add methods to Game to access players by name

This commit is contained in:
Thorsten Rausch
2021-06-17 18:33:16 +02:00
parent be4968bb07
commit 8f30d63b03
4 changed files with 53 additions and 37 deletions

View File

@@ -1,13 +1,14 @@
class Player {
constructor(socketUsername) {
this.socketUsername = socketUsername;
constructor(name) {
this.name = name;
this.position = 0;
this.isAlive = true;
}
move(amount) {
move_by(amount) {
this.position += amount;
if (this.position === 15) {
//todo: move by 1 only on the last 3 fields
if (this.position >= 16) {
// todo: win
}
}