From b460cf6cd7723f02515f59b2f51c1e1e541d2f4f Mon Sep 17 00:00:00 2001 From: exane Date: Thu, 25 Jun 2015 17:51:21 +0200 Subject: [PATCH] performance tweaks --- client/js/client.js | 63 ++++++++++++++++++----------- client/templates/battle.handlebars | 65 +++--------------------------- client/templates/info.handlebars | 49 ++++++++++++---------- server/Battle.js | 19 +++++++++ server/Battleside.js | 4 +- 5 files changed, 95 insertions(+), 105 deletions(-) diff --git a/client/js/client.js b/client/js/client.js index ceab1fa..83126c2 100644 --- a/client/js/client.js +++ b/client/js/client.js @@ -1,23 +1,38 @@ var socket = require("socket.io-client"); var Backbone = require("backbone"); require("./backbone.modal-min"); -var Handlebars = require("handlebars"); +var Handlebars = require('handlebars/runtime').default; var $ = require("jquery"); window.$ = $; +Handlebars.registerPartial("card", require("../templates/cards.handlebars")); +Handlebars.registerHelper("health", function(lives){ + var out = ""; + + for(var i = 0; i < 2; i++) { + out += "
-
-
-
-
-
Points:
-
0
-
-
-
Hand:
-
0
-
-
-
- - -
-
-
-
Passed
-
-
field
-
{{name}}
-
-
-
-
Points:
-
{{score}}
-
-
-
Hand:
-
{{hand}}
-
-
-
- -
-
-
-
Passed
-
-
-
- -
-
+
@@ -97,32 +53,23 @@
- {{#each cards}} -
- -
+ {{#each cards as |val key|}} + {{>card val}} {{/each}}
-
+
-
-
+
discard deck
-
- main deck -
-
+
discard deck
-
- main deck -
\ No newline at end of file diff --git a/client/templates/info.handlebars b/client/templates/info.handlebars index b5f06fd..b08724a 100644 --- a/client/templates/info.handlebars +++ b/client/templates/info.handlebars @@ -1,23 +1,30 @@ -
-
{{name}}
-
-
-
-
Points:
-
{{score}}
-
-
-
Hand:
-
{{hand}}
-
-
-
- {{#health}} - {{/health}} -
-
-
-
Passed
+
{{data.name}}
+
{{>card leader}}
+
+
+
Points:
+
{{data.score}}
+
+
+
Hand:
+
{{data.hand}}
+
+
+
Deck:
+
{{data.deck}}
+
+
+
+ {{#health data.lives}} + {{/health}}
-
\ No newline at end of file +
+
{{#if data.passing}}Passed{{/if}}
+
+
+{{#if passBtn}} +
+ +
+{{/if}} \ No newline at end of file diff --git a/server/Battle.js b/server/Battle.js index 570d193..bad196f 100644 --- a/server/Battle.js +++ b/server/Battle.js @@ -53,6 +53,25 @@ var Battle = (function(){ this.p2.foe = this.p1; this.p1.setUpWeatherFieldWith(this.p2); + this.p1.hand.add(Card("poor_fucking_infantry")); + this.p2.hand.add(Card("poor_fucking_infantry")); + this.p1.hand.add(Card("poor_fucking_infantry")); + this.p2.hand.add(Card("poor_fucking_infantry")); + this.p1.hand.add(Card("poor_fucking_infantry")); + this.p2.hand.add(Card("poor_fucking_infantry")); + this.p1.hand.add(Card("poor_fucking_infantry")); + this.p2.hand.add(Card("poor_fucking_infantry")); + this.p1.hand.add(Card("poor_fucking_infantry")); + this.p2.hand.add(Card("poor_fucking_infantry")); + this.p1.hand.add(Card("poor_fucking_infantry")); + this.p2.hand.add(Card("poor_fucking_infantry")); + this.p1.hand.add(Card("poor_fucking_infantry")); + this.p2.hand.add(Card("poor_fucking_infantry")); + this.p1.hand.add(Card("poor_fucking_infantry")); + this.p2.hand.add(Card("poor_fucking_infantry")); + this.p1.hand.add(Card("poor_fucking_infantry")); + this.p2.hand.add(Card("poor_fucking_infantry")); + this.start(); } diff --git a/server/Battleside.js b/server/Battleside.js index 6426288..98c78fe 100644 --- a/server/Battleside.js +++ b/server/Battleside.js @@ -78,7 +78,7 @@ Battleside = (function(){ }) this.receive("set:passing", function(){ self.setPassing(true); - //self.update(); + self.update(); self.runEvent("NextTurn", null, [self.foe]); }) this.receive("medic:chooseCardFromDiscard", function(data){ @@ -226,6 +226,7 @@ Battleside = (function(){ lives: this._rubies, score: this.calcScore(), hand: this.hand.length(), + deck: this.deck.length(), discard: this.getDiscard(true), passing: this._passing } @@ -452,6 +453,7 @@ Battleside = (function(){ self.hand.add(replaceCard); self.hand.remove(card); + self.update(); self.runEvent("NextTurn", null, [self.foe]); }) }