From 344f9cc29a1d9b6b1ca7a594e62cdb11a1b3e5e3 Mon Sep 17 00:00:00 2001 From: exane Date: Wed, 1 Jul 2015 10:40:57 +0200 Subject: [PATCH] tight bond fix --- assets/data/abilities.js | 13 +------------ server/Battle.js | 16 ++++++++++++---- server/Battleside.js | 31 +++++++++++++++++++++++++++++-- server/Card.js | 15 +++++++++++++-- 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/assets/data/abilities.js b/assets/data/abilities.js index ddc1b25..d8f298c 100644 --- a/assets/data/abilities.js +++ b/assets/data/abilities.js @@ -88,18 +88,7 @@ module.exports = { "tight_bond": { name: "tight_bond", description: "Tight Bond: Place next to a card with the name same to double the strength of both cards.", - onAfterPlace: function(card){ - var field = this.field[card.getType()]; - var cards = field.get(); - var lastInsert = cards.length; - - if(lastInsert < 2) return; - - if(cards[lastInsert - 2].getName() == cards[lastInsert - 1].getName()){ - cards[lastInsert - 2].setBoost(cards[lastInsert - 2].getID(), +cards[lastInsert - 2].getPower()); - cards[lastInsert - 1].setBoost(cards[lastInsert - 1].getID(), +cards[lastInsert - 1].getPower()); - } - } + tightBond: true }, "spy": { name: "spy", diff --git a/server/Battle.js b/server/Battle.js index ed77580..e7a7fd9 100644 --- a/server/Battle.js +++ b/server/Battle.js @@ -61,10 +61,18 @@ var Battle = (function(){ this.p1.draw(10); this.p2.draw(10); - /*this.p1.hand.add(this.p1.createCard("scorch")); - this.p2.hand.add(this.p2.createCard("scorch")); - this.p1.hand.add(this.p1.createCard("vernon_roche")); - this.p2.hand.add(this.p2.createCard("vernon_roche"));*/ + /*this.p1.hand.add(this.p1.createCard("blue_stripes_commando")); + this.p2.hand.add(this.p2.createCard("blue_stripes_commando")); + this.p1.hand.add(this.p1.createCard("blue_stripes_commando")); + this.p2.hand.add(this.p2.createCard("blue_stripes_commando")); + this.p1.hand.add(this.p1.createCard("blue_stripes_commando")); + this.p2.hand.add(this.p2.createCard("blue_stripes_commando")); + this.p1.hand.add(this.p1.createCard("blue_stripes_commando")); + this.p2.hand.add(this.p2.createCard("blue_stripes_commando")); + this.p1.hand.add(this.p1.createCard("blue_stripes_commando")); + this.p2.hand.add(this.p2.createCard("blue_stripes_commando")); + this.p1.hand.add(this.p1.createCard("dandelion")); + this.p2.hand.add(this.p2.createCard("dandelion"));*/ /*this.p1.placeCard("ves"); diff --git a/server/Battleside.js b/server/Battleside.js index d6935b3..3e17a59 100644 --- a/server/Battleside.js +++ b/server/Battleside.js @@ -446,6 +446,25 @@ Battleside = (function(){ }) } + r.setTightBond = function(card) { + var field = this.field[card.getType()]; + var pos = field.getPosition(card); + var cards = field.get(); + + if(pos < 0) return; + if(pos >= 1 && cards[pos-1].getName() === cards[pos].getName()) { + cards[pos].setBoost(cards[pos].getID()+"|left", "tight_bond"); + } else { + cards[pos].setBoost(cards[pos].getID()+"|left", 0); + } + + if(pos < cards.length-1 && cards[pos+1].getName() === cards[pos].getName()) { + cards[pos].setBoost(cards[pos].getID()+"|right", "tight_bond"); + } else { + cards[pos].setBoost(cards[pos].getID()+"|right", 0); + } + } + r.checkAbilities = function(card, obj, __flag){ var self = this; obj.targetSide = this; @@ -459,11 +478,12 @@ Battleside = (function(){ ability = ability[0]; } - if(ability && ability.name === obj.suppress){ + /*if(ability && ability.name === obj.suppress){ //this.update(); - } + }*/ if(ability && !Array.isArray(ability)){ + if(ability.onBeforePlace){ ability.onBeforePlace.apply(this, [card]); } @@ -480,6 +500,12 @@ Battleside = (function(){ if(ability.nextTurn){ obj._nextTurn = ability.nextTurn; } + if(ability.tightBond){ + //this.setTightBond(card); + ability.onAfterPlace = this.setTightBond; + ability.onEachCardPlace = this.setTightBond; + //ability.onWeatherChange = this.setTightBond; + } if(ability.scorch){ this.scorch(card); } @@ -536,6 +562,7 @@ Battleside = (function(){ } //this.update(); + } } diff --git a/server/Card.js b/server/Card.js index 17808cd..f9ae438 100644 --- a/server/Card.js +++ b/server/Card.js @@ -15,7 +15,7 @@ var Card = (function(){ this._uidEvents = {}; this.setDisabled(false); this._data = CardData[key] ? CardData[key] : CardData["none"]; - if(!(this._data = CardData[key])) { + if(!(this._data = CardData[key])){ this._data = CardData["none"]; key = "none"; } @@ -139,11 +139,22 @@ var Card = (function(){ r.getBoost = function(){ var res = 0; + var doubles = 0; for(var key in this._boost) { - if(key === "commanders_horn" || key === "commanders_horn_card") continue; + if(key === "commanders_horn" || key === "commanders_horn_card") continue + if(this._boost[key] === "tight_bond"){ + doubles++; + continue; + } res += this._boost[key]; } + if(doubles){ //tight bond + for(var i = 0; i < doubles; i++) { + res += res + this.getBasePower(); + } + } + if(this._boost["commanders_horn"] || this._boost["commanders_horn_card"]){ res += res + this.getBasePower(); }