diff --git a/assets/data/deck.js b/assets/data/deck.js index 6c9f904..2051978 100644 --- a/assets/data/deck.js +++ b/assets/data/deck.js @@ -1,124 +1,169 @@ module.exports = { - "northern": [ - "redanian_foot_soldier", - "redanian_foot_soldier", - "poor_fucking_infantry", - "redanian_foot_soldier", - "poor_fucking_infantry", - "yarpen_zigrin", - "blue_stripes_commando", - "sigismund_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_siegemaster", - "biting_frost", - "torrential_rain", - "clear_weather", - "impenetrable_fog", - "commanders_horn", - "commanders_horn", - "decoy" - ], + "northern": { + faction: "northern", + data: [ + "redanian_foot_soldier", + "redanian_foot_soldier", + "poor_fucking_infantry", + "redanian_foot_soldier", + "poor_fucking_infantry", + "yarpen_zigrin", + "blue_stripes_commando", + "sigismund_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_siegemaster", + "biting_frost", + "torrential_rain", + "clear_weather", + "impenetrable_fog", + "commanders_horn", + "commanders_horn", + "decoy" + ] + }, + "nilfgaardian": { //test only + faction: "nilfgaardian", + data: [ + "redanian_foot_soldier", + "redanian_foot_soldier", + "poor_fucking_infantry", + "redanian_foot_soldier", + "poor_fucking_infantry", + "yarpen_zigrin", + "blue_stripes_commando", + "sigismund_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_siegemaster", + "biting_frost", + "torrential_rain", + "clear_weather", + "impenetrable_fog", + "commanders_horn", + "commanders_horn", + "decoy" + ] + }, + "scoiatael": { + faction: "scoiatael", + data: [ + "francesca_the_beautiful", + "commanders_horn", + "commanders_horn", + "saesenthessis", + "iorveth", + "isengrim_faoiltiarnah", + "eithne", + "havekar_healer", + "riordain", + "havekar_smuggler", + "havekar_smuggler", + "havekar_smuggler", + "toruviel", + "decoy", + "decoy", + "biting_frost", + "torrential_rain", + "clear_weather", + "impenetrable_fog", + "elven_skirmisher", + "elven_skirmisher", + "dwarven_skirmisher", + "dwarven_skirmisher", + "ciaran_aep_easnillien", + "vrihedd_brigade_recruit", + "dol_blathanna_archer", + "havekar_smuggler", + "mahakaman_defender", + "vrihedd_brigade_veteran", + "dennis_cranmer", + "filavandrel_aen_fidhail", + "filavandrel_aen_fidhail", + "ida_emean_aep_sivney", + "yaevinn", + "barclay_els", + "dol_blathanna_scout", + "milva" + ] + }, - "scoiatael": [ - "francesca_the_beautiful", - "commanders_horn", - "commanders_horn", - "saesenthessis", - "iorveth", - "isengrim_faoiltiarnah", - "eithne", - "havekar_healer", - "riordain", - "havekar_smuggler", - "havekar_smuggler", - "havekar_smuggler", - "toruviel", - "decoy", - "decoy", - "biting_frost", - "torrential_rain", - "clear_weather", - "impenetrable_fog", - "elven_skirmisher", - "elven_skirmisher", - "dwarven_skirmisher", - "dwarven_skirmisher", - "ciaran_aep_easnillien", - "vrihedd_brigade_recruit", - "dol_blathanna_archer", - "havekar_smuggler", - "mahakaman_defender", - "vrihedd_brigade_veteran", - "dennis_cranmer", - "filavandrel_aen_fidhail", - "filavandrel_aen_fidhail", - "ida_emean_aep_sivney", - "yaevinn", - "barclay_els", - "dol_blathanna_scout", - "milva" - ], - - "monster": [ - "eredin_king_of_the_wild_hunt", - "kayran", - "leshen", - "imlerith", - "draug", - "ghoul", - "decoy", - "nekker", - "nekker", - "wyvern", - "foglet", - "celaeno_harpy", - "gargoyle", - "cockatrice", - "harpy", - "biting_frost", - "torrential_rain", - "clear_weather", - "impenetrable_fog", - "endrega", - "vampire_bruxa", - "vampire_fleder", - "vampire_garkain", - "vampire_ekimmara", - "commanders_horn", - "commanders_horn", - "vampire_ekimmara", - "arachas", - "botchling", - "forktail", - "plague_maiden", - "griffin", - "werewolf", - "frightener", - "ice_giant", - "grave_hag", - //"vampire_katakan", - "crone_whispess", - "crone_brewess", - "crone_weavess", - "arachas_behemoth", - "fire_elemental", - "fiend", - "earth_elemental" - ] + "monster": { + faction: "monster", + data: [ + "eredin_king_of_the_wild_hunt", + "kayran", + "leshen", + "imlerith", + "draug", + "ghoul", + "decoy", + "nekker", + "nekker", + "wyvern", + "foglet", + "celaeno_harpy", + "gargoyle", + "cockatrice", + "harpy", + "biting_frost", + "torrential_rain", + "clear_weather", + "impenetrable_fog", + "endrega", + "vampire_bruxa", + "vampire_fleder", + "vampire_garkain", + "vampire_ekimmara", + "commanders_horn", + "commanders_horn", + "vampire_ekimmara", + "arachas", + "botchling", + "forktail", + "plague_maiden", + "griffin", + "werewolf", + "frightener", + "ice_giant", + "grave_hag", + //"vampire_katakan", + "crone_whispess", + "crone_brewess", + "crone_weavess", + "arachas_behemoth", + "fire_elemental", + "fiend", + "earth_elemental" + ] + } } \ No newline at end of file diff --git a/client/js/client.js b/client/js/client.js index 9588ca1..51f69db 100644 --- a/client/js/client.js +++ b/client/js/client.js @@ -274,6 +274,7 @@ let BattleView = Backbone.View.extend({ this.listenTo(user, "change:setAgile", this.render); this.listenTo(user, "change:setHorn", this.render); this.listenTo(user, "change:isReDrawing", this.render); + this.listenTo(user, "change:chooseSide", this.render); /*this.listenTo(user, "change:handCards", this.render);*/ this.$hand = this.$el.find(".field-hand"); @@ -437,11 +438,14 @@ let BattleView = Backbone.View.extend({ let modal = new ReDrawModal({model: this.user}); this.$el.prepend(modal.render().el); } - - if(this.user.get("openDiscard")){ + if(this.user.get("openDiscard")) { let modal = new Modal({model: this.user}); this.$el.prepend(modal.render().el); } + if(this.user.get("chooseSide")){ + let modal = new ChooseSideModal({model: this.user}); + this.$el.prepend(modal.render().el); + } if(this.user.get("medicDiscard")){ let modal = new MedicModal({model: this.user}); this.$el.prepend(modal.render().el); @@ -621,6 +625,29 @@ let ReDrawModal = Modal.extend({ let WinnerModal = Modal.extend({ template: require("../templates/modal.winner.handlebars") }); +let ChooseSideModal = Modal.extend({ + template: require("../templates/modal.side.handlebars"), + events: { + "click .btn": "onBtnClick" + }, + beforeCancel: function() { + return false; + }, + onBtnClick: function(e) { + var id = $(e.target).closest(".btn").data().id; + + this.model.set("chooseSide", false); + if(id === "you") { + //this.model.set("chosenSide", this.model.get("roomSide")); + this.model.chooseSide(this.model.get("roomSide")); + this.remove(); + return; + } + //this.model.set("chosenSide", this.model.get("roomFoeSide")); + this.model.chooseSide(this.model.get("roomFoeSide")); + this.remove(); + } +}); let User = Backbone.Model.extend({ defaults: { @@ -632,6 +659,8 @@ let User = Backbone.Model.extend({ let user = this; let app = user.get("app"); + self.set("chooseSide", false); + this.listenTo(this.attributes, "change:room", this.subscribeRoom); app.receive("response:name", function(data){ @@ -641,17 +670,13 @@ let User = Backbone.Model.extend({ app.receive("init:battle", function(data){ //console.log("opponent found!"); self.set("roomSide", data.side); + self.set("roomFoeSide", data.foeSide); /* self.set("channel:battle", app.socket.subscribe(self.get("room")));*/ //app.navigate("battle", {trigger: true}); app.battleRoute(); }) - /*app.receive("response:createRoom", function(roomID){ - self.set("room", roomID); - console.log("room created", roomID); - });*/ - app.receive("response:joinRoom", function(roomID){ self.set("room", roomID); //console.log("room id", self.get("room")); @@ -717,6 +742,9 @@ let User = Backbone.Model.extend({ let modal = new WinnerModal({model: new model({winner: winner})}); $("body").prepend(modal.render().el); }) + app.receive("request:chooseWhichSideBegins", function() { + self.set("chooseSide", true); + }) app.on("startMatchmaking", this.startMatchmaking, this); app.on("joinRoom", this.joinRoom, this); @@ -746,6 +774,11 @@ let User = Backbone.Model.extend({ //console.log("deck: ", deckKey); this.set("deckKey", deckKey); this.get("app").send("set:deck", {deck: deckKey}); + }, + chooseSide: function(roomSide) { + this.get("app").send("response:chooseWhichSideBegins", { + side: roomSide + }) } }); diff --git a/client/templates/lobby.handlebars b/client/templates/lobby.handlebars index 6c03416..8fb82c0 100644 --- a/client/templates/lobby.handlebars +++ b/client/templates/lobby.handlebars @@ -9,6 +9,7 @@ + diff --git a/client/templates/modal.side.handlebars b/client/templates/modal.side.handlebars new file mode 100644 index 0000000..545b3e0 --- /dev/null +++ b/client/templates/modal.side.handlebars @@ -0,0 +1,10 @@ +
+