player.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. Core(function(scope) {
  2. function Player(options)
  3. {
  4. options = options || {},
  5. this.name = options.name,
  6. this.position = options.position,
  7. this.noSkin = options.noSkin,
  8. this.skin = options.skin || scope.SKIN_NAMES[$.rand(0, scope.SKIN_NAMES.length - 1)],
  9. console.log(this.position);
  10. this.$el = $("#Player-" + this.position),
  11. this.$page = $("#Kakaranet-12-maxim"),
  12. this.elements = {
  13. $timer: "#Timer",
  14. $name: "#Name",
  15. $nameWrapper: "#Name rect",
  16. $nameText: "#Name text" },
  17. this.proxies = [ "loadSkin" ],
  18. this.__super__.constructor.call(this),
  19. this.$el.show(),
  20. this.$timer.hide(),
  21. this.$name.show(),
  22. setPlayerName("Player-" + this.position, this.name);
  23. this.initTimer(),
  24. "Me" == this.position || this.noSkin || $.load("svg/" + [ "Person", this.position, this.skin ].join("-") + ".svg", this.loadSkin);
  25. }
  26. $.inherit(Player, scope.Controller);
  27. $.extend(Player.prototype, {
  28. loadSkin: function(result) {
  29. var $result = $("<g/>").html(result);
  30. this.$page.append($result[0].firstChild),
  31. this.unselect(); },
  32. initTimer: function() {
  33. this.timer = new scope.Timer(this.$timer, { duration: 30 }); },
  34. select: function() {
  35. this.$nameWrapper.attr({ fill: "#517ECE" }),
  36. this.$nameText.attr({ fill: "#FFFFFF" }),
  37. this.$timer.show(),
  38. this.$("#Selection").show(),
  39. this.timer.start(); },
  40. unselect: function() {
  41. this.$nameWrapper.attr({ fill: "#FFFFFF" }),
  42. this.$nameText.attr({ fill: "#48AF5E" }),
  43. this.$timer.hide(),
  44. this.$("#Selection").hide(),
  45. this.timer.reset(); }
  46. });
  47. scope.Player = Player;
  48. });