Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions js/models/Attack.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,13 @@ var Attack = Backbone.Model.extend({
resoView.model.set("energyTotal", energy - damage);
}
});
},
undoDamage: function () {
var dpr = this.get("damagePerResonator");
_.each(resonatorViews, function (resoView, i) {
var energy = resoView.model.get("energyTotal");
var damage = dpr[i].damage;
resoView.model.set("energyTotal", energy + damage);
});
}
});
13 changes: 11 additions & 2 deletions js/models/AttackCollection.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
var AttackCollection = Backbone.Collection.extend({
model: Attack
});
model: Attack,
add: function(model, options) {
// attack.attack();
return Backbone.Collection.prototype.add.call(this, model, options);
},
pop: function(options) {
var popd = Backbone.Collection.prototype.pop.call(this, options);
popd.undoDamage();
return popd;
}
});
13 changes: 11 additions & 2 deletions js/views/AttackInfoView.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var AttackInfoView = Backbone.View.extend({
events: {
"mouseover": "showPosition",
"mouseout": "hidePosition"
"mouseout": "hidePosition",
"click .undo": "undoAttack"
},
showPosition: function () {
playerView.model.set({x: this.model.get("x"), y: this.model.get("y")});
Expand All @@ -21,7 +22,15 @@ var AttackInfoView = Backbone.View.extend({
var energyPortalMax = this.model.get("energyPortalMax");
var percentage = Math.round(energyPortal / energyPortalMax * 1000) / 10;
html += 'Dmg: ' + Math.round(damageTotal / 1000 * 10) / 10 + 'K, Portal: ' + Math.round(energyPortal / 1000 * 10) / 10 + 'K/' + energyPortalMax / 1000 + 'K (' + percentage + '%)';
if(this.model.collection.indexOf(this.model) == this.model.collection.length-1)
html += '&nbsp;-&nbsp;<span style="cursor: pointer" class="undo">undo</span>';
this.$el.html(html);
return this;
},
undoAttack: function() {
if(this.model.collection.indexOf(this.model) == this.model.collection.length-1) {
this.model.collection.pop();
playerView.hide();
}
}
});
});
8 changes: 4 additions & 4 deletions js/views/AttackListView.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var AttackListView = Backbone.View.extend({
initialize: function () {
_.bindAll(this, "addOne", "render");
this.listenTo(this.collection, "add", this.addOne);
this.listenTo(this.collection, "reset", this.render)
//this.listenTo(this.collection, "add", this.addOne);
this.listenTo(this.collection, "add remove reset", this.render);
},
addOne: function (at) {
var av = new AttackInfoView({
Expand All @@ -14,6 +14,6 @@ var AttackListView = Backbone.View.extend({
this.$el.html("");
this.collection.each(function (at, i) {
this.addOne(at);
});
}, this);
}
});
});
13 changes: 10 additions & 3 deletions js/views/AttackSummaryView.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
var AttackSummaryView = Backbone.View.extend({
initialize: function () {
_.bindAll(this, "render");
this.listenTo(this.collection, "add change reset", this.render);
this.listenTo(this.collection, "add change remove reset", this.render);
this.render();
},
events: {
"click .reset": "reset"
"click .reset": "reset",
"click .undo": "undo"
},
render: function () {
var burstercount = [];
Expand All @@ -22,10 +23,16 @@ var AttackSummaryView = Backbone.View.extend({
htmls.push(b + 'x <span style="color:' + level_color[i + 1] + '">L' + (i + 1) + '</span>');
}
}
this.$el.html(htmls.join(", ") + ' <span style="cursor: pointer" class="reset">Reset</span>');
var resetSpan = ' <span style="cursor: pointer" class="reset">Reset</span>';
var undoSpan = ' <span style="cursor: pointer" class="undo">Undo</span>';
this.$el.html(htmls.join(", ") + resetSpan + " - " + undoSpan);
},
reset: function () {
this.collection.reset();
portal.reset();
},
undo: function () {
if(this.collection.length > 0)
this.collection.pop();
}
});
2 changes: 1 addition & 1 deletion js/views/DamageHeatMapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var DamageHeatMapView = Backbone.View.extend({
initialize: function () {
_.bindAll(this, "render", "createDataset");
this.listenTo(this.model, 'change', this.check);
this.listenTo(attacks, 'add', this.check);
this.listenTo(attacks, 'add remove', this.check);
},
check: function (a) {
if (this.model.get("heatmap")) {
Expand Down