From d4fc3b0404daf869a4018755c547b39060182a9b Mon Sep 17 00:00:00 2001 From: exane Date: Mon, 22 Jun 2015 18:48:08 +0200 Subject: [PATCH] update stuff --- assets/data/abilities.js | 61 +++++++--------------------------------- client/js/client.js | 5 ++-- server/Battle.js | 8 +++--- server/Battleside.js | 50 +++++++++++++++++++++++--------- server/Card.js | 32 +++++++++++++++------ 5 files changed, 78 insertions(+), 78 deletions(-) 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 a22f3ff..f5f5a96 100644 --- a/client/js/client.js +++ b/client/js/client.js @@ -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/server/Battle.js b/server/Battle.js index 8a91f17..5c916dd 100644 --- a/server/Battle.js +++ b/server/Battle.js @@ -62,12 +62,12 @@ var Battle = (function(){ this.p1.draw(10); this.p2.draw(10); this.p1.hand.add(Card("commanders_horn")); - this.p2.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.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.p1.hand.add(Card("milva")); this.p2.hand.add(Card("milva")); this.p1.hand.add(Card("havekar_healer")); this.p2.hand.add(Card("havekar_healer")); @@ -76,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")); 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