wingbase/server/game/player.js
2016-03-21 23:45:27 +00:00

27 lines
734 B
JavaScript

'use strict';
const fruit = ['Apple', 'Banana', 'Pear', 'Plum', 'Pineapple', 'Peach', 'Apricot', 'Orange', 'Triangle', 'Kiwi', 'Mango', 'Strawberry', 'Lemon', 'Blueberry', 'Raspberry', 'Grape', 'Dragonfruit', 'Watermelon', 'Honeymelon', 'Pomegranate', 'Cherry', 'Avocado'];
class Player {
constructor(connection) {
this.room = false;
this.ship = false;
this.team = false;
this.kickCount = 0;
this.connection = connection;
this.name = `Stupid ${fruit[Math.random() * fruit.length | 0]}`;
this.delta = {};
}
disconnect() {
this.room.remove(this);
}
sendUpdate() {
if (Object.keys(this.delta).length == 0) return;
this.connection.send('update', this.delta);
this.delta = {};
}
}
module.exports = Player;