diff --git a/assets/data/abilities.js b/assets/data/abilities.js index 29db2aa..b3c7389 100644 --- a/assets/data/abilities.js +++ b/assets/data/abilities.js @@ -1,7 +1,19 @@ module.exports = { "agile": { - + cancelPlacement: true, + onBeforePlace: function(card) { + var self = this; + this.send("played:agile", {cardID: card.getID()}, true); + this.on("agile:setField", function(type) { + self.off("agile:setField"); + card.changeType(type) + self.placeCard(card, { + disabled: true + }); + self.hand.remove(card); + }) + } }, "medic": { waitResponse: true, diff --git a/assets/data/cards.js b/assets/data/cards.js index 314b617..cd908eb 100644 --- a/assets/data/cards.js +++ b/assets/data/cards.js @@ -353,8 +353,7 @@ module.exports = { "mahakaman_defender": { name: "Mahakaman Defender", power: 5, - ability: "muster", - musterType: "defender", + ability: null, img: "defender2", faction: "Scoia'tael", type: 0 diff --git a/assets/data/deck.js b/assets/data/deck.js index 58810fa..fe0e7bc 100644 --- a/assets/data/deck.js +++ b/assets/data/deck.js @@ -99,9 +99,9 @@ module.exports = { "grave_hag", //"vampire_katakan", "crone_whispess", + "crone_brewess", + "crone_brewess", "crone_whispess", - "crone_brewess", - "crone_brewess", "crone_weavess", "crone_weavess", "arachas_behemoth", diff --git a/package.json b/package.json index 6688180..3590683 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "shortid": "^2.2.2", "serve-static": "1.8.0", "minimist": "1.1.0", + "underscore": "^1.8.3", "socketcluster-client": "2.2.x" }, "devDependencies": { @@ -21,7 +22,6 @@ "handlebars": "^3.0.3", "jquery": "^2.1.4", "promise": "^7.0.1", - "underscore": "^1.8.3", "vinyl-source-stream": "^1.1.0" }, "scripts": { diff --git a/public/index.html b/public/index.html index 7967776..b4d536e 100644 --- a/public/index.html +++ b/public/index.html @@ -106,11 +106,11 @@
-
+
0
-
+
0
diff --git a/public/js/client.js b/public/js/client.js index ae2c3b5..e0a7628 100644 --- a/public/js/client.js +++ b/public/js/client.js @@ -220,6 +220,7 @@ var BattleView = Backbone.View.extend({ this.listenTo(user, "change:waiting", this.render); this.listenTo(user, "change:passing", this.render); this.listenTo(user, "change:openDiscard", this.render); + this.listenTo(user, "change:setAgile", this.render); this.$hand = this.$el.find(".field-hand"); this.$preview = this.$el.find(".card-preview"); @@ -242,7 +243,7 @@ var BattleView = Backbone.View.extend({ "mouseover .card": "onMouseover", "mouseleave .card": "onMouseleave", "click .field-hand": "onClick", - "click .battleside.player": "onClickDecoy", + "click .battleside.player": "onClickFieldCard", "click .button-pass": "onPassing", "click .field-discard": "openDiscard", "click .field-leader": "clickLeader" @@ -262,6 +263,14 @@ var BattleView = Backbone.View.extend({ var id = $card.data("id"); var key = $card.data("key"); + if(!!this.user.get("setAgile")){ + if(id === this.user.get("setAgile")){ + this.user.set("setAgile", false); + this.app.send("cancel:agile"); + this.render(); + } + return; + } if(!!this.user.get("waitForDecoy")){ if(id === this.user.get("waitForDecoy")){ this.user.set("waitForDecoy", false); @@ -281,15 +290,25 @@ var BattleView = Backbone.View.extend({ this.render(); } }, - onClickDecoy: function(e){ - if(!this.user.get("waitForDecoy")) return; - console.log("replacement card found: "); - var $card = $(e.target).closest(".card"); - var _id = $card.data("id"); - this.app.send("decoy:replaceWith", { - cardID: _id - }) - this.user.set("waitForDecoy", false); + onClickFieldCard: function(e){ + if(this.user.get("waitForDecoy")){ + var $card = $(e.target).closest(".card"); + var _id = $card.data("id"); + this.app.send("decoy:replaceWith", { + cardID: _id + }) + this.user.set("waitForDecoy", false); + } + if(this.user.get("setAgile")) { + var $field = $(e.target).closest(".field.active").find(".field-close, .field-range"); + + console.log($field); + var target = $field.hasClass("field-close") ? 0 : 1; + this.app.send("agile:field", { + field: target + }); + this.user.set("setAgile", false); + } }, onMouseover: function(e){ var target = $(e.target).closest(".card"); @@ -316,8 +335,8 @@ var BattleView = Backbone.View.extend({ render: function(){ var self = this; this.$el.html(this.template({ - cards: self.handCards/*, - preview: self.user.get("showPreview")*/ + cards: self.handCards, + agile: self.user.get("setAgile") })); if(!(this.otherSide && this.yourSide)) return; this.otherSide.render(); @@ -332,7 +351,10 @@ var BattleView = Backbone.View.extend({ var modal = new MedicModal({model: this.user}); this.$el.prepend(modal.render().el); } - + if(this.user.get("setAgile")){ + var id = this.user.get("setAgile"); + this.$el.find("[data-id='" + id + "']").addClass("activeCard"); + } if(this.user.get("waitForDecoy")){ var id = this.user.get("waitForDecoy"); this.$el.find("[data-id='" + id + "']").addClass("activeCard"); @@ -482,6 +504,10 @@ var User = Backbone.Model.extend({ }); }) + app.receive("played:agile", function(data){ + console.log("played agile"); + self.set("setAgile", data.cardID); + }) app.on("createRoom", this.createRoom, this); app.on("joinRoom", this.joinRoom, this); diff --git a/public/scss/main.scss b/public/scss/main.scss index b30cc86..cef1200 100644 --- a/public/scss/main.scss +++ b/public/scss/main.scss @@ -20,6 +20,11 @@ $game-height: 800px; width: 100%; height: 100px; border: 1px solid black; + + &.active { + box-shadow: 0px 0px 15px #ffbb0b; + + } } .field:hover, .field-single:hover { diff --git a/server/Battle.js b/server/Battle.js index b7a4663..ae6b891 100644 --- a/server/Battle.js +++ b/server/Battle.js @@ -57,15 +57,19 @@ var Battle = (function(){ r.start = function(){ this.p1.setLeadercard(); this.p2.setLeadercard(); - this.p1.draw(5); - this.p2.draw(5); + this.p1.draw(10); + this.p2.draw(10); + + this.p1.hand.add(Card("harpy")); + this.p2.hand.add(Card("harpy")); + /* this.p1.hand.add(Card("dun_banner_medic")); this.p2.hand.add(Card("dun_banner_medic")); this.p1.hand.add(Card("isengrim_faoiltiarnah")); - this.p2.hand.add(Card("isengrim_faoiltiarnah")); + this.p2.hand.add(Card("isengrim_faoiltiarnah"));*/ - this.p1.addToDiscard([Card("kaedweni_siege_expert")]); - this.p2.addToDiscard([Card("kaedweni_siege_expert")]); + /*this.p1.addToDiscard([Card("kaedweni_siege_expert")]); + this.p2.addToDiscard([Card("kaedweni_siege_expert")]);*/ /* this.p1.hand.add(Card("decoy")); this.p1.hand.add(Card("impenetrable_fog")); diff --git a/server/Battleside.js b/server/Battleside.js index 37a59a2..3f9ee0e 100644 --- a/server/Battleside.js +++ b/server/Battleside.js @@ -88,6 +88,14 @@ Battleside = (function(){ self.playCard(card); }) + this.receive("agile:field", function(data) { + var fieldType = data.field; + self.runEvent("agile:setField", null, [fieldType]); + self.runEvent("NextTurn", null, [self.foe]); + }) + this.receive("cancel:agile", function(){ + self.off("agile:setField"); + }) this.on("Turn" + this.getID(), this.onTurnStart, this); @@ -269,7 +277,7 @@ Battleside = (function(){ obj = _.extend({}, obj); this.checkAbilities(card, obj); - if(obj._canclePlacement) return 0; + if(obj._cancelPlacement) return 0; var field = obj.targetSide.field[card.getType()]; field.add(card); @@ -295,6 +303,7 @@ Battleside = (function(){ r.checkAbilities = function(card, obj, __flag){ var self = this; obj.targetSide = this; + if(obj.disabled) return; var ability = Array.isArray(__flag) || card.getAbility(); if(Array.isArray(ability) && ability.length){ @@ -309,6 +318,12 @@ Battleside = (function(){ } if(ability && !Array.isArray(ability)){ + if(ability.onBeforePlace) { + ability.onBeforePlace.apply(this, [card]); + } + if(ability.cancelPlacement) { + obj._cancelPlacement = true; + } if(ability.waitResponse){ obj._waitResponse = true; } @@ -316,7 +331,7 @@ Battleside = (function(){ obj.targetSide = this.foe; } if(ability.replaceWith){ - obj._canclePlacement = true; + 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 69f07b7..7dc17df 100644 --- a/server/Card.js +++ b/server/Card.js @@ -32,6 +32,7 @@ var Card = (function(){ r._boost = null; r._forcedPower = null; r._disabled = null; + r._changedType = null; Card.__id = 0; Card.TYPE = { CLOSE_COMBAT: 0, @@ -95,7 +96,10 @@ var Card = (function(){ return this._data.musterType || null; } r.getType = function(){ - return this._data.type; + return typeof this._changedType === "undefined" ? this._data.type : this._changedType; + } + r.changeType = function(type) { + this._changedType = type; } r.getKey = function(){ return this._key; @@ -124,6 +128,7 @@ var Card = (function(){ } r.resetBoost = function() { + this._changedType = null; this._boost = 0; }