playercharacter.js 661 B

1234567891011121314151617181920212223242526272829303132333435
  1. var Mobile = require('./mobile');
  2. function PlayerCharacter(game) {
  3. this.inventory = [];
  4. this.maxInventory = 10;
  5. this.id = 0;
  6. this.mobile = null;
  7. this.init = function(mobileId, socketKey, playerData) {
  8. this.mobile = new Mobile();
  9. this.mobile.id = mobileId;
  10. this.id = mobileId;
  11. this.mobile.socketKey = socketKey;
  12. this.mobile.name = "Player " + mobileId;
  13. for(var key in this.mobile) {
  14. if(playerData.hasOwnProperty(key)) {
  15. this.mobile[key] = playerData[key];
  16. }
  17. }
  18. this.mobile.type = "player";
  19. this.inventory = [];
  20. return this.mobile;
  21. };
  22. this.update = function(delta, game) {
  23. };
  24. };
  25. module.exports = PlayerCharacter;