var io = require("socket.io-client")/*("http://localhost:16918")*/; var Backbone = require("backbone"); var Handlebars = require("handlebars"); var $ = require("jquery"); //var Lobby = require("./client-lobby"); window.$ = $; Handlebars.registerHelper("health", function(lives, options){ var out = ""; for(var i = 0; i < 2; i++) { out += "'), templateCards: Handlebars.compile('{{#each this}}' + '
' + '' + '
' + '{{/each}}'), initialize: function(options){ var self = this; this.side = options.side; this.app = options.app; this.battleView = options.battleView; this.infoData = this.infoData || {}; this.leader = this.leader || {}; this.field = this.field || {}; }, render: function(){ this.renderInfo(); this.renderCloseField(); this.renderRangeField(); this.renderSiegeField(); return this; }, renderInfo: function(){ var d = this.infoData; var l = this.leader; this.$info = this.$el.find(".game-info" + this.side); this.$info.find(".info-name").html(d.name); this.$info.find(".score").html(d.score); this.$info.find(".hand-card").html(d.hand); this.$info.find(".gwent-lives").html(this.lives(d.lives)); this.$info.find(".field-leader").html(this.template(l)) if(this.app.user.get("waiting") && this.side === ".player"){ this.$info.addClass("removeBackground"); } if(!this.app.user.get("waiting") && this.side === ".foe"){ this.$info.addClass("removeBackground"); } }, renderCloseField: function(){ if(!this.field.close) return; this.$fields = this.$el.find(".battleside" + this.side); var $field = this.$fields.find(".field-close").parent(); var cards = this.field.close._cards; var score = this.field.close._score; var html = this.templateCards(cards); $field.find(".field-close").html(html) $field.find(".large-field-counter").html(score) }, renderRangeField: function(){ if(!this.field.ranged) return; this.$fields = this.$el.find(".battleside" + this.side); var $field = this.$fields.find(".field-range").parent(); var cards = this.field.ranged._cards; var score = this.field.ranged._score; var html = this.templateCards(cards); $field.find(".field-range").html(html) $field.find(".large-field-counter").html(score) }, renderSiegeField: function(){ if(!this.field.siege) return; this.$fields = this.$el.find(".battleside" + this.side); var $field = this.$fields.find(".field-siege").parent(); var cards = this.field.siege._cards; var score = this.field.siege._score; var html = this.templateCards(cards); $field.find(".field-siege").html(html) $field.find(".large-field-counter").html(score) }, lives: function(lives){ var out = ""; for(var i = 0; i < 2; i++) { out += "