From e7559df6f7966dcf9cbac3b029fae4d06182d9b6 Mon Sep 17 00:00:00 2001 From: exane Date: Sat, 13 Jun 2015 21:36:02 +0200 Subject: [PATCH] update2 --- assets/data/abilities.js | 110 ++++++++++++++++++++ assets/data/cards.js | 206 ++++++++++++++++++++++++++++++++++++ assets/data/deck.js | 30 ++++++ package.json | 8 +- public/index.html | 9 +- public/js/Gwent.js | 200 ----------------------------------- public/js/client-lobby.js | 40 +++++++ public/js/client.js | 212 ++++++++++++++++++++++++++++++++++++++ public/js/main.js | 6 +- server/Battle.js | 46 ++++----- server/Battleside.js | 45 ++++++-- server/Card.js | 91 ++++++++++++++++ server/Deck.js | 114 ++++++++++++++++++++ server/Hand.js | 60 +++++++++++ server/Room.js | 61 ++++++++--- server/Socket.js | 47 +++++---- 16 files changed, 1016 insertions(+), 269 deletions(-) create mode 100644 assets/data/abilities.js create mode 100644 assets/data/cards.js create mode 100644 assets/data/deck.js delete mode 100644 public/js/Gwent.js create mode 100644 public/js/client-lobby.js create mode 100644 public/js/client.js create mode 100644 server/Card.js create mode 100644 server/Deck.js create mode 100644 server/Hand.js diff --git a/assets/data/abilities.js b/assets/data/abilities.js new file mode 100644 index 0000000..58b9ee8 --- /dev/null +++ b/assets/data/abilities.js @@ -0,0 +1,110 @@ +module.exports = { + + "agile": { + + }, + "medic": { + + }, + "morale_boost": { + onAfterPlace: function(card) { + var field = this.getYourside().getField(card.getType()); + var cards = field.getCards(); + + cards.forEach(function(_card) { + _card.boost(1); + }) + } + }, + "muster": { + onAfterPlace: function(card){ + var name = card.getName(); + var self = this; + + var cards = this.getDeck().find("name", name); + cards.forEach(function(_card) { + self.getDeck().removeFromDeck(_card.getId()); + this._placeCard(_card); + }) + } + }, + "tight_bond": { + onAfterPlace: function(card){ + var field = this.getYourside().getField(card.getType()); + var cards = field.getCards(); + var lastInsert = cards.length; + + if(lastInsert < 2) return; + + if(cards[lastInsert - 2].getName() == cards[lastInsert - 1].getName()){ + cards[lastInsert - 2].boost(+cards[lastInsert - 2].getPower()); + cards[lastInsert - 1].boost(+cards[lastInsert - 1].getPower()); + } + } + }, + "spy": { + changeSide: true, + onAfterPlace: function(card){ + this.drawCards(2); + } + }, + "weather_fog": { + onEachTurn: function(card) { + var targetRow = card.constructor.TYPE.RANGED; + var forcedPower = 1; + var field1 = this.getYourside().getField(targetRow).getCards(); + var field2 = this.getOtherside().getField(targetRow).getCards(); + + var field = field1.concat(field2); + + field.forEach(function(_card) { + if(_card.getRawAbility() == "hero") return; + _card.setForcedPower(forcedPower); + }); + + } + }, + "weather_rain": { + onEachTurn: function(card) { + var targetRow = card.constructor.TYPE.SIEGE; + var forcedPower = 1; + var field1 = this.getYourside().getField(targetRow).getCards(); + var field2 = this.getOtherside().getField(targetRow).getCards(); + + var field = field1.concat(field2); + + field.forEach(function(_card) { + if(_card.getRawAbility() == "hero") return; + _card.setForcedPower(forcedPower); + }); + + } + }, + "weather_frost": { + onEachTurn: function(card) { + var targetRow = card.constructor.TYPE.CLOSE_COMBAT; + var forcedPower = 1; + var field1 = this.getYourside().getField(targetRow).getCards(); + var field2 = this.getOtherside().getField(targetRow).getCards(); + + var field = field1.concat(field2); + + field.forEach(function(_card) { + if(_card.getRawAbility() == "hero") return; + _card.setForcedPower(forcedPower); + }); + + } + }, + "clear_weather": { + onAfterPlace: function(card) { + var targetRow = card.constructor.TYPE.WEATHER; + var field = this.getYourside().getField(targetRow).getCards(); + + //todo: remove weather cards + } + }, + "decoy": { + replaceWith: true + } +} \ No newline at end of file diff --git a/assets/data/cards.js b/assets/data/cards.js new file mode 100644 index 0000000..3ac689b --- /dev/null +++ b/assets/data/cards.js @@ -0,0 +1,206 @@ + +/** + * types + * 0 close combat + * 1 ranged + * 2 siege + * 3 leader + * 4 special (decoy) + * 5 weather + */ + + +module.exports = { + "redanian_foot_soldier": { + name: "Redanian Foot Soldier", + power: 1, + ability: null, + img: "foot_soldier1", + faction: "Northern Realm", + type: 0 + }, + "poor_fucking_infantry": { + name: "Poor Fucking Infantry", + power: 1, + ability: "tight_bond", + img: "infantry", + faction: "Northern Realm", + type: 0 + }, + "yarpen_zigrin": { + name: "Yarpen Zigrin", + power: 1, + ability: null, + img: "yarpen", + faction: "Northern Realm", + type: 0 + }, + "blue_stripes_commando": { + name: "Blue Stripes Commando", + power: 4, + ability: "tight_bond", + img: "commando", + faction: "Northern Realm", + type: 0 + }, + "sigismunt_dijkstra": { + name: "Sigismunt Dijkstra", + power: 4, + ability: "spy", + img: "dijkstra", + faction: "Northern Realm", + type: 0 + }, + "prince_stennis": { + name: "Prince Stennis", + power: 5, + ability: "spy", + img: "stennis", + faction: "Northern Realm", + type: 0 + }, + "siegfried_of_denesle": { + name: "Siegfried of Denesle", + power: 5, + ability: null, + img: "siegfried", + faction: "Northern Realm", + type: 0 + }, + "ves": { + name: "Ves", + power: 5, + ability: null, + img: "ves", + faction: "Northern Realm", + type: 0 + }, + "vernon_roche": { + name: "Vernon Roche", + power: 10, + ability: "hero", + img: "roche", + faction: "Northern Realm", + type: 0 + }, + "john_natalis": { + name: "John Natalis", + power: 10, + ability: "hero", + img: "natalis", + faction: "Northern Realm", + type: 0 + }, + "sheldon_skaggs": { + name: "Sheldon Skaggs", + power: 4, + ability: null, + img: "skaggs", + faction: "Northern Realm", + type: 1 + }, + "sabrina_glevissig": { + name: "Sabrina Glevissig", + power: 4, + ability: null, + img: "sabrina", + faction: "Northern Realm", + type: 1 + }, + "crinfrid_reavers_dragon_hunter": { + name: "Crinfrid Reaver's Dragon Hunter", + power: 5, + ability: "tight_bond", + img: "crinfrid", + faction: "Northern Realm", + type: 1 + }, + "sile_de_tansarville": { + name: "Síle de Tansarville", + power: 5, + ability: null, + img: "sile", + faction: "Northern Realm", + type: 1 + }, + "keira_metz": { + name: "Keira Metz", + power: 5, + ability: null, + img: "keira", + faction: "Northern Realm", + type: 1 + }, + "dethmold": { + name: "Dethmold", + power: 6, + ability: null, + img: "dethmold", + faction: "Northern Realm", + type: 1 + }, + "kaedweni_siege_expert": { + name: "Kaedweni Siege Expert", + power: 1, + ability: "morale_boost", + img: "siege_expert1", + faction: "Northern Realm", + type: 2 + }, + "dun_banner_medic": { + name: "Dun Banner Medic", + power: 5, + ability: "medic", + img: "medic", + faction: "Northern Realm", + type: 2 + }, + "ballista": { + name: "Ballista", + power: 6, + ability: null, + img: "ballista1", + faction: "Northern Realm", + type: 2 + }, + "trebuchet": { + name: "Trebuchet", + power: 6, + ability: null, + img: "trebuchet1", + faction: "Northern Realm", + type: 2 + }, + "thaler": { + name: "Thaler", + power: 1, + ability: "spy", + img: "thaler", + faction: "Northern Realm", + type: 2 + }, + "foltest_king_of_temeria": { + name: "Foltest: King of Temeria", + power: 0, + ability: "foltest_leader1", + img: "foltest_king", + faction: "Northern Realm", + type: 3 + }, + "decoy": { + name: "Decoy", + power: 0, + ability: "decoy", + img: "decoy", + faction: null, + type: 4 + }, + "impenetrable_fog": { + name: "Impenetrable Fog", + power: 0, + ability: "weather_fog", + img: "fog", + faction: null, + type: 5 + } +} diff --git a/assets/data/deck.js b/assets/data/deck.js new file mode 100644 index 0000000..2f861ca --- /dev/null +++ b/assets/data/deck.js @@ -0,0 +1,30 @@ +module.exports = { + + "test": [ + "redanian_foot_soldier", + "poor_fucking_infantry", + "redanian_foot_soldier", + "poor_fucking_infantry", + "yarpen_zigrin", + "blue_stripes_commando", + "sigismunt_dijkstra", + "prince_stennis", + "siegfried_of_denesle", + "ves", + "vernon_roche", + "john_natalis", + "sheldon_skaggs", + "sabrina_glevissig", + "crinfrid_reavers_dragon_hunter", + "sile_de_tansarville", + "keira_metz", + "dethmold", + "kaedweni_siege_expert", + "dun_banner_medic", + "ballista", + "trebuchet", + "thaler", + "foltest_king_of_temeria", + "decoy", + "impenetrable_fog"] +} \ No newline at end of file diff --git a/package.json b/package.json index 61bb868..3afc68a 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,16 @@ "socket.io-client": "^1.3.5" }, "devDependencies": { + "babelify": "^6.1.2", + "browserify": "^10.2.4", + "gulp": "^3.9.0", + "gulp-livereload": "^3.8.0", + "gulp-sass": "^2.0.1", "handlebars": "^3.0.3", "jquery": "^2.1.4", "promise": "^7.0.1", - "shortid": "^2.2.2" + "shortid": "^2.2.2", + "vinyl-source-stream": "^1.1.0" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/public/index.html b/public/index.html index fc0ccee..5954982 100644 --- a/public/index.html +++ b/public/index.html @@ -8,7 +8,7 @@ -
+