diff --git a/assets/data/abilities.js b/assets/data/abilities.js
index 354e7a3..f6e6a30 100644
--- a/assets/data/abilities.js
+++ b/assets/data/abilities.js
@@ -209,58 +209,12 @@ module.exports = {
replaceWith: true
},
"commanders_horn": {
- commandersHorn: true/*,
- onEachCardPlace: function(card){
- var field = this.field[card.getType()];
- var id = "commanders_horn";
-
- if(!field.isOnField(card)){
- field.get().forEach(function(_card){
- if(_card.getID() == id) return;
- if(_card.getType() != card.getType()) return;
- if(_card.hasAbility("hero")) return;
- _card.setBoost(id, 0);
- })
- this.off("EachCardPlace", card.getUidEvents("EachCardPlace"));
- return;
- }
-
- field.get().forEach(function(_card){
- if(_card.getID() == id) return;
- if(_card.getType() != card.getType()) return;
- if(_card.hasAbility("hero")) return;
- _card.setBoost(id, 0);
- _card.setBoost(id, _card.getPower());
- })
- }*/
+ commandersHorn: true
},
"commanders_horn_card": {
cancelPlacement: true,
commandersHorn: true,
- isCommandersHornCard: true/*,
- onEachCardPlace: function(card){
- var field = this.field[card.getType()];
- var id = "commanders_horn";
-
- if(!field.isOnField(card)){
- field.get().forEach(function(_card){
- if(_card.getID() == id) return;
- if(_card.getType() != card.getType()) return;
- if(_card.hasAbility("hero")) return;
- _card.setBoost(id, 0);
- })
- this.off("EachCardPlace", card.getUidEvents("EachCardPlace"));
- return;
- }
-
- field.get().forEach(function(_card){
- if(_card.getID() == id) return;
- if(_card.getType() != card.getType()) return;
- if(_card.hasAbility("hero")) return;
- _card.setBoost(id, 0);
- _card.setBoost(id, _card.getPower());
- })
- }*/
+ isCommandersHornCard: true
},
"foltest_leader1": {
onActivate: function(){
@@ -277,12 +231,17 @@ module.exports = {
},
"foltest_leader3": {
onActivate: function(){
- var siegeCards = this.field[2].get();
+ var field = this.field[2];
//todo: unless there is commanders horn active
- siegeCards.forEach(function(card){
+ /*siegeCards.forEach(function(card){
card.setBoost("foltest_leader3", card.getPower());
- })
+ })*/
+ /*field.add(Card("commanders_horn", true));*/
+ /*this.placeCard("commanders_horn", {
+ forceField: field
+ });*/
+ this.setHorn("commanders_horn", 2);
}
},
"foltest_leader4": {
diff --git a/client/js/client.js b/client/js/client.js
index f8bb2a2..f5f5a96 100644
--- a/client/js/client.js
+++ b/client/js/client.js
@@ -4,7 +4,6 @@ var Backbone = require("backbone");
require("./backbone.modal-min");
var Handlebars = require("handlebars");
var $ = require("jquery");
-//var Lobby = require("./client-lobby");
window.$ = $;
@@ -307,6 +306,7 @@ var BattleView = Backbone.View.extend({
onClickFieldCard: function(e){
if(this.user.get("waitForDecoy")){
var $card = $(e.target).closest(".card");
+ if(!$card.length) return;
var _id = $card.data("id");
if($card.parent().hasClass("field-horn")) return;
@@ -405,9 +405,10 @@ var BattleView = Backbone.View.extend({
},
clickLeader: function(e){
var $card = $(e.target).closest(".field-leader");
- console.log("click leader");
if(!$card.parent().hasClass("player")) return;
- if($card.hasClass("disabled")) return;
+ if($card.find(".card").hasClass("disabled")) return;
+
+ console.log("click leader");
this.app.send("activate:leader")
diff --git a/client/templates/battle.handlebars b/client/templates/battle.handlebars
index 072c25b..9708466 100644
--- a/client/templates/battle.handlebars
+++ b/client/templates/battle.handlebars
@@ -89,7 +89,7 @@
-
+
diff --git a/gulpfile.js b/gulpfile.js
index afe405c..5f195b5 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -59,6 +59,7 @@ gulp.task("unit tests", function(){
gulp.task("watch", function(){
gulp.watch("./client/js/*", ["browserify"]);
+ gulp.watch("./client/templates/*", ["browserify"]);
gulp.watch("./client/scss/*", ["sass"]);
gulp.watch("./client/*.html", ["index"]);
gulp.watch("./test/src/*", ["unit tests"]);
diff --git a/server/Battle.js b/server/Battle.js
index c424190..5c916dd 100644
--- a/server/Battle.js
+++ b/server/Battle.js
@@ -61,8 +61,12 @@ var Battle = (function(){
this.p2.setLeadercard();
this.p1.draw(10);
this.p2.draw(10);
- /*this.p1.hand.add(Card("commanders_horn"));
- this.p2.hand.add(Card("commanders_horn"));
+ this.p1.hand.add(Card("commanders_horn"));
+ this.p2.hand.add(Card("commanders_horn"));/*
+ this.p1.hand.add(Card("ciaran_aep_easnillien"));
+ this.p2.hand.add(Card("ciaran_aep_easnillien"));*/
+ /*this.p1.hand.add(Card("decoy"));
+ this.p2.hand.add(Card("decoy"));*/
this.p1.hand.add(Card("milva"));
this.p2.hand.add(Card("milva"));
this.p1.hand.add(Card("havekar_healer"));
@@ -72,7 +76,7 @@ var Battle = (function(){
this.p1.hand.add(Card("vrihedd_brigade_recruit"));
this.p2.hand.add(Card("vrihedd_brigade_recruit"));
this.p1.hand.add(Card("impenetrable_fog"));
- this.p2.hand.add(Card("impenetrable_fog"));*/
+ this.p2.hand.add(Card("impenetrable_fog"));
/*
this.p1.hand.add(Card("commanders_horn"));
this.p1.hand.add(Card("commanders_horn"));
@@ -96,8 +100,7 @@ var Battle = (function(){
this.p2.hand.add(Card("ballista"));
this.p1.hand.add(Card("ballista"));
this.p2.hand.add(Card("ballista"));*/
- /*this.p1.hand.add(Card("decoy"));
- this.p2.hand.add(Card("decoy"));*/
+
/*
this.p1.hand.add(Card("dun_banner_medic"));
this.p2.hand.add(Card("dun_banner_medic"));
diff --git a/server/Battleside.js b/server/Battleside.js
index af0970a..1085d22 100644
--- a/server/Battleside.js
+++ b/server/Battleside.js
@@ -46,11 +46,11 @@ Battleside = (function(){
if(self._isWaiting) return;
if(self.isPassing()) return;
- console.log("leader activated");
var leaderCard = self.getLeader();
if(leaderCard.isDisabled()) return;
+ console.log("leader activated");
var ability = leaderCard.getAbility();
@@ -291,17 +291,25 @@ Battleside = (function(){
r.placeCard = function(card, obj){
obj = _.extend({}, obj);
+ if(typeof card === "string" ) {
+ card = Card(card);
+ }
+
this.checkAbilities(card, obj);
- if(obj._cancelPlacement) return 0;
+ if(obj._cancelPlacement && !obj.forceField) return 0;
- var field;
+ var field = obj.forceField || null;
if(typeof obj.isHorn !== "undefined"){
- field = obj.targetSide.field[obj.isHorn];
+ if(!field){
+ field = obj.targetSide.field[obj.isHorn];
+ }
field.add(card, true);
}
else {
- field = obj.targetSide.field[card.getType()];
+ if(!field){
+ field = obj.targetSide.field[card.getType()];
+ }
field.add(card);
}
@@ -321,8 +329,24 @@ Battleside = (function(){
return 1;
}
- r.setHorn = function(card) {
+ r.setHorn = function(card, field){
var self = this;
+ field = typeof field === "undefined" ? null : field;
+
+ if(typeof card === "string"){
+ card = Card(card);
+ }
+
+ if(typeof field === "number") {
+ card.changeType(field);
+ this.placeCard(card, {
+ isHorn: field,
+ forcePlace: true
+ });
+ self.hand.remove(card);
+ return;
+ }
+
this.send("played:horn", {cardID: card.getID()}, true)
this.on("horn:setField", function(type){
self.off("horn:setField");
@@ -335,11 +359,11 @@ Battleside = (function(){
})
}
- r.commanderHornAbility = function(card) {
+ r.commanderHornAbility = function(card){
var field = this.field[card.getType()];
var id = "commanders_horn";
- if(typeof field === "undefined") {
+ if(typeof field === "undefined"){
//console.log("field unknown | %s", card.getName());
return;
}
@@ -385,17 +409,17 @@ Battleside = (function(){
if(ability.onBeforePlace){
ability.onBeforePlace.apply(this, [card]);
}
- if(ability.isCommandersHornCard) {
+ if(ability.isCommandersHornCard && !obj.isHorn){
this.setHorn(card);
}
- if(ability.commandersHorn) {
+ if(ability.commandersHorn){
ability.onEachCardPlace = this.commanderHornAbility;
ability.onWeatherChange = this.commanderHornAbility;
}
- if(ability.cancelPlacement){
+ if(ability.cancelPlacement && !obj.forcePlace){
obj._cancelPlacement = true;
}
- if(ability.waitResponse){
+ if(ability.waitResponse && !obj.forcePlace){
obj._waitResponse = true;
}
if(ability.changeSide){
@@ -405,7 +429,7 @@ Battleside = (function(){
ability.onEachTurn = this.setWeather.bind(this, ability.weather);
ability.onEachCardPlace = this.setWeather.bind(this, ability.weather);
}
- if(ability.replaceWith){
+ if(ability.replaceWith && !obj.forcePlace){
obj._cancelPlacement = true;
this.on("Decoy:replaceWith", function(replaceCard){
if(replaceCard.getType() == Card.TYPE.LEADER ||
diff --git a/server/Card.js b/server/Card.js
index 9628582..12cb6ea 100644
--- a/server/Card.js
+++ b/server/Card.js
@@ -44,7 +44,7 @@ var Card = (function(){
r._uidEvents = null;
- r.getUidEvents = function(key) {
+ r.getUidEvents = function(key){
return this._uidEvents[key];
}
@@ -55,12 +55,22 @@ var Card = (function(){
r.getName = function(){
return this._data.name;
}
+
+ r.getBasePower = function() {
+ var base = this._data.power;
+ if(this._forcedPower > -1){
+ base = this._forcedPower > this._data.power ? this._data.power : this._forcedPower;
+ }
+ return base;
+ }
+
r.getPower = function(){
if(this._data.power === -1) return 0;
- if(this._forcedPower > -1){
+ return this.getBasePower() + this.getBoost();
+ /*if(this._forcedPower > -1){
return (this._forcedPower > this._data.power ? this._data.power : this._forcedPower) + this.getBoost();
}
- return this._data.power + this.getBoost();
+ return this._data.power + this.getBoost();*/
}
r.getRawPower = function(){
return this._data.power;
@@ -82,10 +92,10 @@ var Card = (function(){
}
return AbilityData[this._data.ability];
}
- r.hasAbility = function(ability) {
+ r.hasAbility = function(ability){
var a = this.getRawAbility();
- if(Array.isArray(a)) {
- for(var i=0; i