Player.js 561 B

1234567891011121314151617181920212223
  1. /** @constructor */
  2. function Player(data) {
  3. /** @const @type {string} */
  4. this.id = data["name"];
  5. /** @const @type {string} */
  6. this.idEncoded = encodeURIComponent(data["name"]);
  7. /** @type {number} */
  8. this.score = data["score"];
  9. var pos = data["name"].indexOf('|');
  10. /** @const @type {string} */
  11. this.name = data["name"].substr(0, pos);
  12. /** @const @type {string} */
  13. this.color = '#' +data["name"].substr(pos +1);
  14. }
  15. Player.prototype.update = function(data) {
  16. this.score = data["score"];
  17. return data["v"];
  18. };