mirror of
https://github.com/exane/not-gwent-online
synced 2024-11-20 11:26:54 +00:00
add some abilities
This commit is contained in:
parent
b2aa796aad
commit
21a92f69f3
@ -4,7 +4,19 @@ module.exports = {
|
||||
|
||||
},
|
||||
"medic": {
|
||||
waitResponse: true,
|
||||
onAfterPlace: function(card) {
|
||||
var discard = this.getDiscard();
|
||||
|
||||
discard = this.filter(discard, {
|
||||
"ability": "hero",
|
||||
"type": card.constructor.TYPE.SPECIAL
|
||||
})
|
||||
|
||||
this.send("played:medic", {
|
||||
cards: JSON.stringify(discard)
|
||||
}, true);
|
||||
}
|
||||
},
|
||||
"morale_boost": {
|
||||
onAfterPlace: function(card) {
|
||||
@ -19,14 +31,25 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
"muster": {
|
||||
name: "muster",
|
||||
onAfterPlace: function(card){
|
||||
var name = card.getName();
|
||||
var musterType = card.getMusterType();
|
||||
var self = this;
|
||||
|
||||
var cards = this.deck.find("name", name);
|
||||
cards.forEach(function(_card) {
|
||||
var cardsDeck = this.deck.find("musterType", musterType);
|
||||
var cardsHand = this.hand.find("musterType", musterType);
|
||||
|
||||
cardsDeck.forEach(function(_card) {
|
||||
self.deck.removeFromDeck(_card);
|
||||
this.placeCard(_card);
|
||||
self.placeCard(_card, {
|
||||
suppress: "muster"
|
||||
});
|
||||
})
|
||||
cardsHand.forEach(function(_card) {
|
||||
self.hand.remove(_card);
|
||||
self.placeCard(_card, {
|
||||
suppress: "muster"
|
||||
});
|
||||
})
|
||||
}
|
||||
},
|
||||
@ -128,5 +151,32 @@ module.exports = {
|
||||
var card = this.deck.removeFromDeck(cards[0]);
|
||||
this.placeCard(card);
|
||||
}
|
||||
},
|
||||
"francesca_leader1": {
|
||||
|
||||
},
|
||||
"francesca_leader2": {
|
||||
|
||||
},
|
||||
"francesca_leader3": {
|
||||
|
||||
},
|
||||
"francesca_leader4": {
|
||||
|
||||
},
|
||||
"eredin_leader1": {
|
||||
|
||||
},
|
||||
"eredin_leader2": {
|
||||
|
||||
},
|
||||
"eredin_leader3": {
|
||||
|
||||
},
|
||||
"eredin_leader4": {
|
||||
|
||||
},
|
||||
"hero": {
|
||||
|
||||
}
|
||||
}
|
@ -204,7 +204,6 @@ module.exports = {
|
||||
},
|
||||
|
||||
|
||||
|
||||
"francesca_pureblood_elf": {
|
||||
name: "Francesca, Pureblood Elf",
|
||||
power: -1,
|
||||
@ -273,7 +272,7 @@ module.exports = {
|
||||
name: "Havekar Healer",
|
||||
power: 0,
|
||||
ability: "morale_boost",
|
||||
img: "healerr",
|
||||
img: "healer",
|
||||
faction: "Scoia'tael",
|
||||
type: 1
|
||||
},
|
||||
@ -297,6 +296,7 @@ module.exports = {
|
||||
name: "Elven Skirmisher",
|
||||
power: 2,
|
||||
ability: "muster",
|
||||
musterType: "skirmisher",
|
||||
img: "elven_skirmisher2",
|
||||
faction: "Scoia'tael",
|
||||
type: 1
|
||||
@ -305,6 +305,7 @@ module.exports = {
|
||||
name: "Dwarven Skirmisher",
|
||||
power: 3,
|
||||
ability: "muster",
|
||||
musterType: "skirmisher",
|
||||
img: "skirmisher2",
|
||||
faction: "Scoia'tael",
|
||||
type: 0
|
||||
@ -353,6 +354,7 @@ module.exports = {
|
||||
name: "Mahakaman Defender",
|
||||
power: 5,
|
||||
ability: "muster",
|
||||
musterType: "defender",
|
||||
img: "defender2",
|
||||
faction: "Scoia'tael",
|
||||
type: 0
|
||||
@ -423,13 +425,12 @@ module.exports = {
|
||||
},
|
||||
|
||||
|
||||
|
||||
"eredin_commander_of_the_red_riders": {
|
||||
name: "Eredin, Commander of the Red Riders",
|
||||
power: -1,
|
||||
ability: "eredin_leader1",
|
||||
img: "eredin_commander",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 3
|
||||
},
|
||||
"eredin_bringer_of_death": {
|
||||
@ -437,7 +438,7 @@ module.exports = {
|
||||
power: -1,
|
||||
ability: "eredin_leader2",
|
||||
img: "eredin_bringer",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 3
|
||||
},
|
||||
"eredin_destroyer_of_worlds": {
|
||||
@ -445,7 +446,7 @@ module.exports = {
|
||||
power: -1,
|
||||
ability: "eredin_leader3",
|
||||
img: "eredin_destroyer",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 3
|
||||
},
|
||||
"eredin_king_of_the_wild_hunt": {
|
||||
@ -453,7 +454,7 @@ module.exports = {
|
||||
power: -1,
|
||||
ability: "eredin_leader4",
|
||||
img: "eredin_king",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 3
|
||||
},
|
||||
"kayran": {
|
||||
@ -461,7 +462,7 @@ module.exports = {
|
||||
power: 8,
|
||||
ability: ["hero", "morale_boost"],
|
||||
img: "kayran",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 1
|
||||
},
|
||||
"leshen": {
|
||||
@ -469,7 +470,7 @@ module.exports = {
|
||||
power: 10,
|
||||
ability: "hero",
|
||||
img: "leshen",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 1
|
||||
},
|
||||
"imlerith": {
|
||||
@ -477,7 +478,7 @@ module.exports = {
|
||||
power: 10,
|
||||
ability: "hero",
|
||||
img: "imlerith",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"draug": {
|
||||
@ -485,23 +486,25 @@ module.exports = {
|
||||
power: 10,
|
||||
ability: "hero",
|
||||
img: "draug",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"ghoul": {
|
||||
name: "Ghoul",
|
||||
power: 1,
|
||||
ability: "muster",
|
||||
musterType: "ghoul",
|
||||
img: "ghoul1",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"nekker": {
|
||||
name: "Nekker",
|
||||
power: 2,
|
||||
ability: "muster",
|
||||
musterType: "nekker",
|
||||
img: "nekker",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"wyvern": {
|
||||
@ -509,7 +512,7 @@ module.exports = {
|
||||
power: 2,
|
||||
ability: null,
|
||||
img: "wyvern",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 1
|
||||
},
|
||||
"foglet": {
|
||||
@ -517,7 +520,7 @@ module.exports = {
|
||||
power: 2,
|
||||
ability: null,
|
||||
img: "foglet",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"celaeno_harpy": {
|
||||
@ -525,7 +528,7 @@ module.exports = {
|
||||
power: 2,
|
||||
ability: null,
|
||||
img: "celaeno_harpy",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 1
|
||||
},
|
||||
"gargoyle": {
|
||||
@ -533,7 +536,7 @@ module.exports = {
|
||||
power: 2,
|
||||
ability: null,
|
||||
img: "gargoyle",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 1
|
||||
},
|
||||
"cockatrice": {
|
||||
@ -541,7 +544,7 @@ module.exports = {
|
||||
power: 2,
|
||||
ability: null,
|
||||
img: "cockatrice",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 1
|
||||
},
|
||||
"harpy": {
|
||||
@ -549,7 +552,7 @@ module.exports = {
|
||||
power: 2,
|
||||
ability: "agile",
|
||||
img: "harpy",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 1
|
||||
},
|
||||
"endrega": {
|
||||
@ -557,47 +560,52 @@ module.exports = {
|
||||
power: 2,
|
||||
ability: null,
|
||||
img: "endrega",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 1
|
||||
},
|
||||
"vampire_bruxa": {
|
||||
name: "Vampire: Bruxa",
|
||||
power: 4,
|
||||
ability: "muster",
|
||||
musterType: "vampire",
|
||||
img: "vampire_bruxa",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"vampire_fleder": {
|
||||
name: "Vampire: Fleder",
|
||||
power: 4,
|
||||
ability: "muster",
|
||||
musterType: "vampire",
|
||||
img: "vampire_fleder",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"vampire_garkain": {
|
||||
name: "Vampire: Garkain",
|
||||
power: 4,
|
||||
ability: "muster",
|
||||
musterType: "vampire",
|
||||
img: "vampire_garkain",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"vampire_ekimmara": {
|
||||
name: "Vampire: Ekimmara",
|
||||
power: 4,
|
||||
ability: "muster",
|
||||
musterType: "vampire",
|
||||
img: "vampire_ekimmara",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"arachas": {
|
||||
name: "Arachas",
|
||||
power: 4,
|
||||
ability: "muster",
|
||||
musterType: "arachas",
|
||||
img: "arachas1",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"botchling": {
|
||||
@ -605,7 +613,7 @@ module.exports = {
|
||||
power: 4,
|
||||
ability: null,
|
||||
img: "botchling",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"forktail": {
|
||||
@ -613,7 +621,7 @@ module.exports = {
|
||||
power: 5,
|
||||
ability: null,
|
||||
img: "forktail",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"plague_maiden": {
|
||||
@ -621,7 +629,7 @@ module.exports = {
|
||||
power: 5,
|
||||
ability: null,
|
||||
img: "forktail",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"griffin": {
|
||||
@ -629,7 +637,7 @@ module.exports = {
|
||||
power: 5,
|
||||
ability: null,
|
||||
img: "griffin",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"werewolf": {
|
||||
@ -637,7 +645,7 @@ module.exports = {
|
||||
power: 5,
|
||||
ability: null,
|
||||
img: "werewolf",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"frightener": {
|
||||
@ -645,7 +653,7 @@ module.exports = {
|
||||
power: 5,
|
||||
ability: null,
|
||||
img: "frightener",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"ice_giant": {
|
||||
@ -653,7 +661,7 @@ module.exports = {
|
||||
power: 5,
|
||||
ability: null,
|
||||
img: "ice_giant",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 2
|
||||
},
|
||||
"grave_hag": {
|
||||
@ -661,47 +669,52 @@ module.exports = {
|
||||
power: 5,
|
||||
ability: null,
|
||||
img: "grave_hag",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 1
|
||||
},
|
||||
/*"vampire_katakan": {
|
||||
name: "Vampire: Katakan",
|
||||
power: 5,
|
||||
ability: "muster",
|
||||
musterType: "vampire",
|
||||
img: "vampire_katakan",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},*/
|
||||
"crone_whispess": {
|
||||
name: "Crone: Whispess",
|
||||
power: 6,
|
||||
ability: "muster",
|
||||
musterType: "crone",
|
||||
img: "crone_whispess",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"crone_brewess": {
|
||||
name: "Crone: Brewess",
|
||||
power: 6,
|
||||
ability: "muster",
|
||||
musterType: "crone",
|
||||
img: "crone_brewess",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"crone_weavess": {
|
||||
name: "Crone: Weavess",
|
||||
power: 6,
|
||||
ability: "muster",
|
||||
musterType: "crone",
|
||||
img: "crone_weavess",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"arachas_behemoth": {
|
||||
name: "Arachas Behemoth",
|
||||
power: 6,
|
||||
ability: "muster",
|
||||
musterType: "arachas",
|
||||
img: "arachas_behemoth",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 2
|
||||
},
|
||||
"fire_elemental": {
|
||||
@ -709,7 +722,7 @@ module.exports = {
|
||||
power: 6,
|
||||
ability: null,
|
||||
img: "fire_elemental",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 2
|
||||
},
|
||||
"fiend": {
|
||||
@ -717,7 +730,7 @@ module.exports = {
|
||||
power: 6,
|
||||
ability: null,
|
||||
img: "fiend",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 0
|
||||
},
|
||||
"earth_elemental": {
|
||||
@ -725,7 +738,7 @@ module.exports = {
|
||||
power: 6,
|
||||
ability: null,
|
||||
img: "earth_elemental",
|
||||
faction: "Monster",
|
||||
faction: "monster",
|
||||
type: 2
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
module.exports = {
|
||||
|
||||
"test": [
|
||||
"northern_realm": [
|
||||
"redanian_foot_soldier",
|
||||
"poor_fucking_infantry",
|
||||
"redanian_foot_soldier",
|
||||
@ -29,11 +29,8 @@ module.exports = {
|
||||
"impenetrable_fog"
|
||||
],
|
||||
|
||||
"Scoia'tael": [
|
||||
"francesca_pureblood_elf",
|
||||
"francesca_the_beautiful",
|
||||
"scoiatael": [
|
||||
"francesca_daisy_of_the_valley",
|
||||
"francesca_queen_of_dol_blathanna",
|
||||
"saesenthessis",
|
||||
"iorveth",
|
||||
"isengrim_faoiltiarnah",
|
||||
@ -41,17 +38,22 @@ module.exports = {
|
||||
"havekar_healer",
|
||||
"riordain",
|
||||
"toruviel",
|
||||
"decoy",
|
||||
"decoy",
|
||||
"impenetrable_fog",
|
||||
"elven_skirmisher",
|
||||
"elven_skirmisher",
|
||||
"dwarven_skirmisher",
|
||||
"dwarven_skirmisher",
|
||||
"ciaran_aep_easnillien",
|
||||
"vrihedd_brigade_recruit",
|
||||
"dol_blathanna_archer",
|
||||
//"hav_caaren_medic",
|
||||
"havekar_smuggler",
|
||||
"mahakaman_defender",
|
||||
"vrihedd_brigade_veteran",
|
||||
"dennis_cranmer",
|
||||
"filavandrel_aen_fidhail",
|
||||
"filavandrel_aen_fidhail",
|
||||
"ida_emean_aep_sivney",
|
||||
"yaevinn",
|
||||
"barclay_els",
|
||||
@ -60,15 +62,15 @@ module.exports = {
|
||||
],
|
||||
|
||||
"monster": [
|
||||
"eredin_commander_of_the_red_riders",
|
||||
"eredin_bringer_of_death",
|
||||
"eredin_destroyer_of_worlds",
|
||||
"eredin_king_of_the_wild_hunt",
|
||||
"kayran",
|
||||
"leshen",
|
||||
"imlerith",
|
||||
"draug",
|
||||
"ghoul",
|
||||
"decoy",
|
||||
"decoy",
|
||||
"nekker",
|
||||
"nekker",
|
||||
"wyvern",
|
||||
"foglet",
|
||||
@ -76,10 +78,15 @@ module.exports = {
|
||||
"gargoyle",
|
||||
"cockatrice",
|
||||
"harpy",
|
||||
"impenetrable_fog",
|
||||
"endrega",
|
||||
"vampire_bruxa",
|
||||
"vampire_bruxa",
|
||||
"vampire_fleder",
|
||||
"vampire_fleder",
|
||||
"vampire_garkain",
|
||||
"vampire_garkain",
|
||||
"vampire_ekimmara",
|
||||
"vampire_ekimmara",
|
||||
"arachas",
|
||||
"botchling",
|
||||
@ -92,7 +99,10 @@ module.exports = {
|
||||
"grave_hag",
|
||||
//"vampire_katakan",
|
||||
"crone_whispess",
|
||||
"crone_whispess",
|
||||
"crone_brewess",
|
||||
"crone_brewess",
|
||||
"crone_weavess",
|
||||
"crone_weavess",
|
||||
"arachas_behemoth",
|
||||
"fire_elemental",
|
||||
|
17
gulpfile.js
17
gulpfile.js
@ -40,9 +40,24 @@ gulp.task('sass', function(){
|
||||
}));
|
||||
});
|
||||
|
||||
gulp.task("unit tests", function(){
|
||||
browserify('./test/spec/mainSpec.js', {standalone: "app", debug: true})
|
||||
.transform(babelify)
|
||||
.bundle().on("error", function(err){
|
||||
console.log(err);
|
||||
})
|
||||
.pipe(source('spec.js').on("error", function(err){
|
||||
console.log(err);
|
||||
}))
|
||||
.pipe(gulp.dest('./test/spec/').on("error", function(err){
|
||||
console.log(err);
|
||||
}));
|
||||
})
|
||||
|
||||
gulp.task("watch", function(){
|
||||
gulp.watch("./public/js/*", ["browserify"]);
|
||||
gulp.watch("./public/scss/*", ["sass"]);
|
||||
gulp.watch("./test/spec/*", ["unit tests"]);
|
||||
})
|
||||
|
||||
gulp.task("default", ["watch", "browserify", "sass"]);
|
||||
gulp.task("default", ["watch", "browserify", "sass", "unit tests"]);
|
||||
|
@ -160,6 +160,11 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<input type="text" class="name-input" value="{{name}}">
|
||||
<select id="deckChoice">
|
||||
<option value="northern_realm">Deck: Northern Realms</option>
|
||||
<option value="scoiatael">Deck: Scoia'tael</option>
|
||||
<option value="monster">Deck: Monster</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -213,6 +218,21 @@
|
||||
<div class="bbm-button bbm-close">close</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/template" id="modal-medic-template">
|
||||
<div class="bbm-modal__topbar">
|
||||
<h3 class="bbm-modal__title">Choose one card from your discard</h3>
|
||||
</div>
|
||||
<div class="bbm-modal__section">
|
||||
{{#each medicDiscard.cards}}
|
||||
<div class="card" data-key="{{_key}}" data-id="{{_id}}">
|
||||
<img src="../assets/cards/{{_data.img}}.png">
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class="bbm-modal__bottombar">
|
||||
<div class="bbm-button bbm-close">close</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/template" id="preview-template">
|
||||
<img src="{{src}}">
|
||||
</script>
|
||||
|
@ -18,10 +18,12 @@ var Lobby = Backbone.View.extend({
|
||||
events: {
|
||||
"click .create-room": "createRoom",
|
||||
"click .join-room": "joinRoom",
|
||||
"blur .name-input": "changeName"
|
||||
"blur .name-input": "changeName",
|
||||
"change #deckChoice": "setDeck"
|
||||
},
|
||||
render: function(){
|
||||
this.$el.html(this.template(this.app.user.attributes));
|
||||
//this.$el.find("#deckChoice option[value='" + this.app.user.get("setDeck") + "']").attr("selected", "selected")
|
||||
return this;
|
||||
},
|
||||
createRoom: function(){
|
||||
@ -30,6 +32,10 @@ var Lobby = Backbone.View.extend({
|
||||
joinRoom: function(){
|
||||
this.app.send("request:joinRoom");
|
||||
},
|
||||
setDeck: function(e){
|
||||
var val = $(e.target).val();
|
||||
this.app.user.setDeck(val);
|
||||
},
|
||||
changeName: function(e){
|
||||
var name = $(e.target).val();
|
||||
this.app.user.setName(name);
|
||||
|
@ -304,7 +304,8 @@ var BattleView = Backbone.View.extend({
|
||||
var side;
|
||||
if($discard.parent().hasClass("player")){
|
||||
side = this.yourSide;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
side = this.otherSide;
|
||||
}
|
||||
this.user.set("openDiscard", {
|
||||
@ -327,6 +328,10 @@ var BattleView = Backbone.View.extend({
|
||||
var modal = new Modal({model: this.user});
|
||||
this.$el.prepend(modal.render().el);
|
||||
}
|
||||
if(this.user.get("medicDiscard")){
|
||||
var modal = new MedicModal({model: this.user});
|
||||
this.$el.prepend(modal.render().el);
|
||||
}
|
||||
|
||||
if(this.user.get("waitForDecoy")){
|
||||
var id = this.user.get("waitForDecoy");
|
||||
@ -402,9 +407,29 @@ var Modal = Backbone.Modal.extend({
|
||||
}
|
||||
});
|
||||
|
||||
var MedicModal = Modal.extend({
|
||||
template: Handlebars.compile($("#modal-medic-template").html()),
|
||||
events: {
|
||||
"click .card": "onCardClick"
|
||||
},
|
||||
onCardClick: function(e){
|
||||
console.log($(e.target).closest(".card"));
|
||||
var id = $(e.target).closest(".card").data().id;
|
||||
this.model.get("app").send("medic:chooseCardFromDiscard", {
|
||||
cardID: id
|
||||
})
|
||||
this.model.set("medicDiscard", false);
|
||||
},
|
||||
cancel: function(){
|
||||
this.model.get("app").send("medic:chooseCardFromDiscard")
|
||||
this.model.set("medicDiscard", false);
|
||||
}
|
||||
});
|
||||
|
||||
var User = Backbone.Model.extend({
|
||||
defaults: {
|
||||
name: ""
|
||||
name: "",
|
||||
deckKey: "northern_realm"
|
||||
},
|
||||
initialize: function(){
|
||||
var self = this;
|
||||
@ -449,10 +474,19 @@ var User = Backbone.Model.extend({
|
||||
$(".container").prepend('<div class="alert alert-danger">Your foe left the battle!</div>')
|
||||
})
|
||||
|
||||
app.receive("played:medic", function(data){
|
||||
var cards = JSON.parse(data.cards);
|
||||
console.log("played medic");
|
||||
self.set("medicDiscard", {
|
||||
cards: cards
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
app.on("createRoom", this.createRoom, this);
|
||||
app.on("joinRoom", this.joinRoom, this);
|
||||
app.on("setName", this.setName, this);
|
||||
app.on("setDeck", this.setDeck, this);
|
||||
|
||||
|
||||
app.send("request:name", this.get("name") == "unnamed" ? null : {name: this.get("name")});
|
||||
@ -470,6 +504,11 @@ var User = Backbone.Model.extend({
|
||||
},
|
||||
setName: function(name){
|
||||
this.get("app").send("request:name", {name: name});
|
||||
},
|
||||
setDeck: function(deckKey){
|
||||
console.log("deck: ", deckKey);
|
||||
this.set("deckKey", deckKey);
|
||||
this.get("app").send("set:deck", {deck: deckKey});
|
||||
}
|
||||
});
|
||||
|
||||
@ -490,10 +529,12 @@ var Lobby = Backbone.View.extend({
|
||||
events: {
|
||||
"click .create-room": "createRoom",
|
||||
"click .join-room": "joinRoom",
|
||||
"blur .name-input": "changeName"
|
||||
"blur .name-input": "changeName",
|
||||
"change #deckChoice": "setDeck"
|
||||
},
|
||||
render: function(){
|
||||
this.$el.html(this.template(this.user.attributes));
|
||||
/*this.$el.find("#deckChoice option[value='" + this.app.user.get("setDeck") + "']").attr("selected", "selected")*/
|
||||
return this;
|
||||
},
|
||||
createRoom: function(){
|
||||
@ -502,6 +543,11 @@ var Lobby = Backbone.View.extend({
|
||||
joinRoom: function(){
|
||||
this.app.trigger("joinRoom");
|
||||
},
|
||||
setDeck: function(e){
|
||||
var val = $(e.target).val();
|
||||
this.app.trigger("setDeck", val);
|
||||
this.$el.find("#deckChoice option[value='" + val + "']").attr("selected", "selected")
|
||||
},
|
||||
changeName: function(e){
|
||||
var name = $(e.target).val();
|
||||
this.app.trigger("setName", name);
|
||||
|
@ -39,7 +39,8 @@ var Battle = (function(){
|
||||
|
||||
r.init = function(){
|
||||
/*PubSub.subscribe("update", this.update.bind(this));*/
|
||||
this.on("Update", this.update);
|
||||
this.on("Update", this.update);/*
|
||||
this.on("AfterPlace", this.checkAbilityOnAfterPlace)*/
|
||||
|
||||
|
||||
this.channel = this.socket.subscribe(this._id);
|
||||
@ -56,13 +57,20 @@ var Battle = (function(){
|
||||
r.start = function(){
|
||||
this.p1.setLeadercard();
|
||||
this.p2.setLeadercard();
|
||||
this.p1.draw(10);
|
||||
this.p2.draw(10);
|
||||
this.p1.draw(5);
|
||||
this.p2.draw(5);
|
||||
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.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"));
|
||||
this.p2.hand.add(Card("decoy"));
|
||||
this.p2.hand.add(Card("impenetrable_fog"));
|
||||
this.p2.hand.add(Card("impenetrable_fog"));*/
|
||||
|
||||
this.update();
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
var io = global.io;
|
||||
var DeckData = require("../assets/data/deck");
|
||||
var Deck = require("./Deck");
|
||||
var Hand = require("./Hand");
|
||||
var Card = require("./Card");
|
||||
var Field = require("./Field");
|
||||
var _ = require("underscore");
|
||||
|
||||
|
||||
var Battleside;
|
||||
@ -16,6 +16,7 @@ Battleside = (function(){
|
||||
* constructor here
|
||||
*/
|
||||
|
||||
var deck = user.getDeck();
|
||||
var self = this;
|
||||
this._isWaiting = true;
|
||||
this.socket = user.socket;
|
||||
@ -28,7 +29,7 @@ Battleside = (function(){
|
||||
this._name = name;
|
||||
this.battle = battle;
|
||||
this.hand = Hand();
|
||||
this.deck = Deck(DeckData["test"]);
|
||||
this.deck = Deck(DeckData[deck]);
|
||||
this._discard = [];
|
||||
|
||||
this.runEvent = this.battle.runEvent.bind(this.battle);
|
||||
@ -74,6 +75,20 @@ Battleside = (function(){
|
||||
self.update();
|
||||
self.runEvent("NextTurn", null, [self.foe]);
|
||||
})
|
||||
this.receive("medic:chooseCardFromDiscard", function(data){
|
||||
if(!data){
|
||||
self.runEvent("NextTurn", null, [self.foe]);
|
||||
return;
|
||||
}
|
||||
var cardID = data.cardID;
|
||||
var card = self.getCardFromDiscard(cardID);
|
||||
if(card === -1) throw new Error("medic:chooseCardFromDiscard | unknown card: ", card);
|
||||
|
||||
self.removeFromDiscard(card);
|
||||
|
||||
self.playCard(card);
|
||||
})
|
||||
|
||||
|
||||
this.on("Turn" + this.getID(), this.onTurnStart, this);
|
||||
};
|
||||
@ -115,6 +130,19 @@ Battleside = (function(){
|
||||
var card = field.getCard(id);
|
||||
if(card !== -1) return card;
|
||||
}
|
||||
/*
|
||||
for(var i = 0; i < this._discard.length; i++) {
|
||||
var c = this._discard[i];
|
||||
if(c.getID() === id) return c;
|
||||
}*/
|
||||
return -1;
|
||||
}
|
||||
|
||||
r.getCardFromDiscard = function(id){
|
||||
for(var i = 0; i < this._discard.length; i++) {
|
||||
var c = this._discard[i];
|
||||
if(c.getID() === id) return c;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -237,8 +265,8 @@ Battleside = (function(){
|
||||
this.runEvent("NextTurn", null, [this.foe]);
|
||||
}
|
||||
|
||||
r.placeCard = function(card){
|
||||
var obj = {};
|
||||
r.placeCard = function(card, obj){
|
||||
obj = _.extend({}, obj);
|
||||
|
||||
this.checkAbilities(card, obj);
|
||||
if(obj._canclePlacement) return 0;
|
||||
@ -246,13 +274,21 @@ Battleside = (function(){
|
||||
var field = obj.targetSide.field[card.getType()];
|
||||
field.add(card);
|
||||
|
||||
//PubSub.publish("onEachCardPlace");
|
||||
this.runEvent("OnEachCardPlace");
|
||||
|
||||
this.checkAbilityOnAfterPlace(card);
|
||||
this.runEvent("EachCardPlace");
|
||||
|
||||
this.checkAbilityOnAfterPlace(card, obj);
|
||||
/*
|
||||
this.runEvent("AfterPlace", this, [card, obj]);*/
|
||||
|
||||
this.update();
|
||||
|
||||
if(obj._waitResponse){
|
||||
this.hand.remove(card);
|
||||
this.update();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -260,6 +296,7 @@ Battleside = (function(){
|
||||
var self = this;
|
||||
obj.targetSide = this;
|
||||
var ability = Array.isArray(__flag) || card.getAbility();
|
||||
|
||||
if(Array.isArray(ability) && ability.length){
|
||||
var ret = ability.slice();
|
||||
ret = ret.splice(0, 1);
|
||||
@ -267,8 +304,14 @@ Battleside = (function(){
|
||||
ability = ability[0];
|
||||
}
|
||||
|
||||
if(ability && !Array.isArray(ability)){/*
|
||||
var ability = card.getAbility();*/
|
||||
if(ability && ability.name === obj.suppress){
|
||||
this.update();
|
||||
}
|
||||
|
||||
if(ability && !Array.isArray(ability)){
|
||||
if(ability.waitResponse){
|
||||
obj._waitResponse = true;
|
||||
}
|
||||
if(ability.changeSide){
|
||||
obj.targetSide = this.foe;
|
||||
}
|
||||
@ -307,9 +350,13 @@ Battleside = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
r.checkAbilityOnAfterPlace = function(card){
|
||||
r.checkAbilityOnAfterPlace = function(card, obj){
|
||||
var ability = card.getAbility();
|
||||
if(ability){
|
||||
if(ability.name && ability.name === obj.suppress){
|
||||
this.update();
|
||||
return;
|
||||
}
|
||||
if(ability.onAfterPlace){
|
||||
ability.onAfterPlace.call(this, card)
|
||||
}
|
||||
@ -332,6 +379,17 @@ Battleside = (function(){
|
||||
});
|
||||
}
|
||||
|
||||
r.removeFromDiscard = function(card){
|
||||
for(var i = 0; i < this._discard.length; i++) {
|
||||
var c = this._discard[i];
|
||||
if(c.getID() === card.getID()){
|
||||
|
||||
this._discard.splice(i, 1);
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
r.getDiscard = function(json){
|
||||
if(json){
|
||||
return JSON.stringify(this._discard);
|
||||
@ -344,6 +402,38 @@ Battleside = (function(){
|
||||
this.setPassing(false);
|
||||
}
|
||||
|
||||
r.filter = function(arrCards, opt){
|
||||
var arr = arrCards.slice();
|
||||
|
||||
for(var key in opt) {
|
||||
var res = [];
|
||||
var prop = key, val = opt[key];
|
||||
|
||||
|
||||
arrCards.forEach(function(card){
|
||||
var property = card.getProperty(prop);
|
||||
if(_.isArray(property)){
|
||||
var _f = false;
|
||||
for(var i = 0; i < property.length; i++) {
|
||||
if(property[i] === val) {
|
||||
_f = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!_f){
|
||||
res.push(card);
|
||||
}
|
||||
}
|
||||
else if(card.getProperty(prop) !== val){
|
||||
res.push(card);
|
||||
}
|
||||
})
|
||||
arr = _.intersection(arr, res);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
return Battleside;
|
||||
})();
|
||||
|
||||
|
@ -91,6 +91,9 @@ var Card = (function(){
|
||||
r.getFaction = function(){
|
||||
return this._data.faction;
|
||||
}
|
||||
r.getMusterType = function() {
|
||||
return this._data.musterType || null;
|
||||
}
|
||||
r.getType = function(){
|
||||
return this._data.type;
|
||||
}
|
||||
@ -116,9 +119,14 @@ var Card = (function(){
|
||||
}
|
||||
|
||||
r.getProperty = function(prop){
|
||||
if(!this._data[prop]) return {};
|
||||
return this._data[prop];
|
||||
}
|
||||
|
||||
r.resetBoost = function() {
|
||||
this._boost = 0;
|
||||
}
|
||||
|
||||
return Card;
|
||||
})();
|
||||
|
||||
|
@ -78,11 +78,6 @@ var Deck = (function(){
|
||||
var n = this.length();
|
||||
|
||||
for(var i = 0; i < n; i++) {
|
||||
/*var cardID = this.getDeck()[i];
|
||||
if(id == cardID){
|
||||
this.getDeck().splice(i, 1);
|
||||
return id;
|
||||
}*/
|
||||
var c = this.getDeck()[i];
|
||||
if(c.getID() === card.getID()){
|
||||
return this.getDeck().splice(i, 1)[0];
|
||||
|
@ -51,6 +51,7 @@ var Field = (function(){
|
||||
r.replaceWith = function(oldCard, newCard){
|
||||
var index = this.getPosition(oldCard);
|
||||
this._cards[index] = newCard;
|
||||
oldCard.resetBoost();
|
||||
return oldCard;
|
||||
}
|
||||
|
||||
@ -64,6 +65,9 @@ var Field = (function(){
|
||||
|
||||
r.removeAll = function() {
|
||||
var tmp = this._cards.slice();
|
||||
tmp.forEach(function(card) {
|
||||
card.resetBoost();
|
||||
})
|
||||
this._cards = [];
|
||||
return tmp;
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ var Hand = (function(){
|
||||
if(this._hand[i].getID() != id) continue;
|
||||
return this._hand.splice(i, 1);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -65,6 +66,16 @@ var Hand = (function(){
|
||||
return this._hand.length;
|
||||
}
|
||||
|
||||
r.find = function(key, val) {
|
||||
var res = [];
|
||||
this._hand.forEach(function(card){
|
||||
if(card.getProperty(key) == val){
|
||||
res.push(card);
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
return Hand;
|
||||
})();
|
||||
|
@ -74,6 +74,15 @@ var User = (function(){
|
||||
return this._rooms[0];
|
||||
}
|
||||
|
||||
r.setDeck = function(deck) {
|
||||
console.log("set deck: ", deck);
|
||||
this._deck = deck;
|
||||
}
|
||||
|
||||
r.getDeck = function() {
|
||||
return this._deck || "northern_realm";
|
||||
}
|
||||
|
||||
r.addRoom = function(room) {
|
||||
this._rooms.push(room);
|
||||
}
|
||||
|
@ -35,6 +35,13 @@ module.exports.run = function(worker){
|
||||
socket.emit("response:name", {name: user.getName()});
|
||||
})
|
||||
|
||||
socket.on("set:deck", function(data) {
|
||||
console.log(data);
|
||||
if(data && data.deck){
|
||||
user.setDeck(data.deck);
|
||||
}
|
||||
})
|
||||
|
||||
socket.on("request:gameLoaded", function(data){
|
||||
console.log(data);
|
||||
connections.roomCollection[data._roomID].setReady(user);
|
||||
|
@ -17,6 +17,7 @@
|
||||
<!-- include spec files here... -->
|
||||
<script src="spec/SpecHelper.js"></script>
|
||||
<script src="spec/PubSubSpec.js"></script>
|
||||
<script src="spec/spec.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
|
33
test/spec/filterSpec.js
Normal file
33
test/spec/filterSpec.js
Normal file
@ -0,0 +1,33 @@
|
||||
var Card = require("../../server/Card");
|
||||
var Battleside = require("../../server/Battleside");
|
||||
var data = require("../../assets/data/abilities");
|
||||
|
||||
|
||||
describe("filter", function(){
|
||||
var card, side, filter, cards;
|
||||
beforeEach(function(){
|
||||
filter = Battleside.prototype.filter;
|
||||
cards = [];
|
||||
cards.push(Card("iorveth"));
|
||||
cards.push(Card("toruviel"));
|
||||
cards.push(Card("isengrim_faoiltiarnah"));
|
||||
cards.push(Card("decoy"));
|
||||
})
|
||||
|
||||
it("it should filter heroes out", function(){
|
||||
var res = filter(cards, {
|
||||
"ability": "hero"
|
||||
})
|
||||
expect(res.length).toBe(2);
|
||||
})
|
||||
|
||||
it("it should filter hero and special cards out", function(){
|
||||
var res = filter(cards, {
|
||||
"ability": "hero",
|
||||
"type": Card.TYPE.SPECIAL
|
||||
})
|
||||
expect(res.length).toBe(1);
|
||||
})
|
||||
|
||||
|
||||
})
|
5
test/spec/mainSpec.js
Normal file
5
test/spec/mainSpec.js
Normal file
@ -0,0 +1,5 @@
|
||||
require("./filterSpec");
|
||||
|
||||
(function main(){
|
||||
|
||||
})();
|
3360
test/spec/spec.js
Normal file
3360
test/spec/spec.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user