mirror of
https://github.com/exane/not-gwent-online
synced 2024-11-23 19:36:53 +00:00
lot of stuff
This commit is contained in:
parent
66cc04d36c
commit
753f4e7a9c
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ test/spec
|
||||
/site/server/vendor
|
||||
/site/server/.env
|
||||
/site/client/node_modules
|
||||
/site/public/assets/js/bundle.js
|
@ -97,6 +97,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
"weather_fog": {
|
||||
weather: 1/*,
|
||||
onEachTurn: function(card){
|
||||
var targetRow = card.constructor.TYPE.RANGED;
|
||||
var forcedPower = 1;
|
||||
@ -122,10 +123,11 @@ module.exports = {
|
||||
if(_card.getRawAbility() == "hero") return;
|
||||
_card.setForcedPower(forcedPower);
|
||||
});
|
||||
}
|
||||
}*/
|
||||
},
|
||||
"weather_rain": {
|
||||
onEachTurn: function(card){
|
||||
weather: 2
|
||||
/*onEachTurn: function(card){
|
||||
var targetRow = card.constructor.TYPE.SIEGE;
|
||||
var forcedPower = 1;
|
||||
var field1 = this.field[targetRow].get();
|
||||
@ -137,10 +139,24 @@ module.exports = {
|
||||
if(_card.getRawAbility() == "hero") return;
|
||||
_card.setForcedPower(forcedPower);
|
||||
});
|
||||
},
|
||||
onEachCardPlace: function(card){
|
||||
var targetRow = card.constructor.TYPE.SIEGE;
|
||||
var forcedPower = 1;
|
||||
var field1 = this.field[targetRow].get();
|
||||
var field2 = this.foe.field[targetRow].get();
|
||||
|
||||
}
|
||||
var field = field1.concat(field2);
|
||||
|
||||
field.forEach(function(_card){
|
||||
if(_card.getRawAbility() == "hero") return;
|
||||
_card.setForcedPower(forcedPower);
|
||||
});
|
||||
}*/
|
||||
},
|
||||
"weather_frost": {
|
||||
weather: 0
|
||||
/*
|
||||
onEachTurn: function(card){
|
||||
var targetRow = card.constructor.TYPE.CLOSE_COMBAT;
|
||||
var forcedPower = 1;
|
||||
@ -153,20 +169,99 @@ module.exports = {
|
||||
if(_card.getRawAbility() == "hero") return;
|
||||
_card.setForcedPower(forcedPower);
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
"clear_weather": {
|
||||
onAfterPlace: function(card){
|
||||
var targetRow = card.constructor.TYPE.WEATHER;
|
||||
var field = this.field[targetRow].get();
|
||||
onEachCardPlace: function(card){
|
||||
var targetRow = card.constructor.TYPE.CLOSE_COMBAT;
|
||||
var forcedPower = 1;
|
||||
var field1 = this.field[targetRow].get();
|
||||
var field2 = this.foe.field[targetRow].get();
|
||||
|
||||
//todo: remove weather cards
|
||||
var field = field1.concat(field2);
|
||||
|
||||
field.forEach(function(_card){
|
||||
if(_card.getRawAbility() == "hero") return;
|
||||
_card.setForcedPower(forcedPower);
|
||||
});
|
||||
}*/
|
||||
},
|
||||
"weather_clear": {
|
||||
weather: 5
|
||||
/*onAfterPlace: function(card){
|
||||
var targetRow = card.constructor.TYPE.WEATHER;
|
||||
var field = this.field[targetRow];
|
||||
field.removeAll();
|
||||
|
||||
for(var i = card.constructor.TYPE.CLOSE_COMBAT; i < card.constructor.TYPE.SIEGE; i++) {
|
||||
var _field1, _field2, _field;
|
||||
_field1 = this.field[i].get();
|
||||
_field2 = this.foe.field[i].get();
|
||||
_field = _field1.concat(_field2);
|
||||
|
||||
_field.forEach(function(_card){
|
||||
if(_card.getRawAbility() == "hero") return;
|
||||
_card.setForcedPower(-1);
|
||||
});
|
||||
}
|
||||
|
||||
}*/
|
||||
},
|
||||
"decoy": {
|
||||
replaceWith: true
|
||||
},
|
||||
"commanders_horn": {
|
||||
commandersHorn: true/*,
|
||||
onEachCardPlace: function(card){
|
||||
var field = this.field[card.getType()];
|
||||
var id = "commanders_horn";
|
||||
|
||||
if(!field.isOnField(card)){
|
||||
field.get().forEach(function(_card){
|
||||
if(_card.getID() == id) return;
|
||||
if(_card.getType() != card.getType()) return;
|
||||
if(_card.hasAbility("hero")) return;
|
||||
_card.setBoost(id, 0);
|
||||
})
|
||||
this.off("EachCardPlace", card.getUidEvents("EachCardPlace"));
|
||||
return;
|
||||
}
|
||||
|
||||
field.get().forEach(function(_card){
|
||||
if(_card.getID() == id) return;
|
||||
if(_card.getType() != card.getType()) return;
|
||||
if(_card.hasAbility("hero")) return;
|
||||
_card.setBoost(id, 0);
|
||||
_card.setBoost(id, _card.getPower());
|
||||
})
|
||||
}*/
|
||||
},
|
||||
"commanders_horn_card": {
|
||||
cancelPlacement: true,
|
||||
commandersHorn: true,
|
||||
isCommandersHornCard: true/*,
|
||||
onEachCardPlace: function(card){
|
||||
var field = this.field[card.getType()];
|
||||
var id = "commanders_horn";
|
||||
|
||||
if(!field.isOnField(card)){
|
||||
field.get().forEach(function(_card){
|
||||
if(_card.getID() == id) return;
|
||||
if(_card.getType() != card.getType()) return;
|
||||
if(_card.hasAbility("hero")) return;
|
||||
_card.setBoost(id, 0);
|
||||
})
|
||||
this.off("EachCardPlace", card.getUidEvents("EachCardPlace"));
|
||||
return;
|
||||
}
|
||||
|
||||
field.get().forEach(function(_card){
|
||||
if(_card.getID() == id) return;
|
||||
if(_card.getType() != card.getType()) return;
|
||||
if(_card.hasAbility("hero")) return;
|
||||
_card.setBoost(id, 0);
|
||||
_card.setBoost(id, _card.getPower());
|
||||
})
|
||||
}*/
|
||||
},
|
||||
"foltest_leader1": {
|
||||
onActivate: function(){
|
||||
var cards = this.deck.find("key", "impenetrable_fog")
|
||||
@ -175,6 +270,26 @@ module.exports = {
|
||||
this.placeCard(card);
|
||||
}
|
||||
},
|
||||
"foltest_leader2": {
|
||||
onActivate: function(){
|
||||
this.setWeather(5);
|
||||
}
|
||||
},
|
||||
"foltest_leader3": {
|
||||
onActivate: function(){
|
||||
var siegeCards = this.field[2].get();
|
||||
|
||||
//todo: unless there is commanders horn active
|
||||
siegeCards.forEach(function(card){
|
||||
card.setBoost("foltest_leader3", card.getPower());
|
||||
})
|
||||
}
|
||||
},
|
||||
"foltest_leader4": {
|
||||
onActivate: function(){
|
||||
|
||||
}
|
||||
},
|
||||
"francesca_leader1": {
|
||||
onActivate: function(){
|
||||
}
|
||||
|
@ -186,6 +186,30 @@ module.exports = {
|
||||
faction: "Northern Realm",
|
||||
type: 3
|
||||
},
|
||||
"foltest_lord_commander": {
|
||||
name: "Foltest: Lord Commander",
|
||||
power: -1,
|
||||
ability: "foltest_leader2",
|
||||
img: "foltest_commander",
|
||||
faction: "Northern Realm",
|
||||
type: 3
|
||||
},
|
||||
"foltest_siegemaster": {
|
||||
name: "Foltest: The Siegemaster",
|
||||
power: -1,
|
||||
ability: "foltest_leader3",
|
||||
img: "foltest_siege",
|
||||
faction: "Northern Realm",
|
||||
type: 3
|
||||
},
|
||||
"foltest_forged": {
|
||||
name: "Foltest: The Steel-Forged",
|
||||
power: -1,
|
||||
ability: "foltest_leader4",
|
||||
img: "foltest_forged",
|
||||
faction: "Northern Realm",
|
||||
type: 3
|
||||
},
|
||||
"decoy": {
|
||||
name: "Decoy",
|
||||
power: -1,
|
||||
@ -194,6 +218,15 @@ module.exports = {
|
||||
faction: null,
|
||||
type: 4
|
||||
},
|
||||
"commanders_horn": {
|
||||
name: "Commander's Horn",
|
||||
power: -1,
|
||||
ability: "commanders_horn_card",
|
||||
img: "horn",
|
||||
faction: null,
|
||||
type: 4
|
||||
},
|
||||
|
||||
"impenetrable_fog": {
|
||||
name: "Impenetrable Fog",
|
||||
power: -1,
|
||||
@ -202,6 +235,30 @@ module.exports = {
|
||||
faction: null,
|
||||
type: 5
|
||||
},
|
||||
"biting_frost": {
|
||||
name: "Biting Frost",
|
||||
power: -1,
|
||||
ability: "weather_frost",
|
||||
img: "frost",
|
||||
faction: null,
|
||||
type: 5
|
||||
},
|
||||
"torrential_rain": {
|
||||
name: "Torrential Rain",
|
||||
power: -1,
|
||||
ability: "weather_rain",
|
||||
img: "rain",
|
||||
faction: null,
|
||||
type: 5
|
||||
},
|
||||
"clear_weather": {
|
||||
name: "Clear Weather",
|
||||
power: -1,
|
||||
ability: "weather_clear",
|
||||
img: "clear",
|
||||
faction: null,
|
||||
type: 5
|
||||
},
|
||||
|
||||
|
||||
"francesca_pureblood_elf": {
|
||||
|
@ -24,9 +24,12 @@ module.exports = {
|
||||
"ballista",
|
||||
"trebuchet",
|
||||
"thaler",
|
||||
"foltest_king_of_temeria",
|
||||
"decoy",
|
||||
"impenetrable_fog"
|
||||
"foltest_siegemaster",
|
||||
"biting_frost",
|
||||
"torrential_rain",
|
||||
"clear_weather",
|
||||
"impenetrable_fog",
|
||||
"decoy"
|
||||
],
|
||||
|
||||
"scoiatael": [
|
||||
@ -40,6 +43,9 @@ module.exports = {
|
||||
"toruviel",
|
||||
"decoy",
|
||||
"decoy",
|
||||
"biting_frost",
|
||||
"torrential_rain",
|
||||
"clear_weather",
|
||||
"impenetrable_fog",
|
||||
"elven_skirmisher",
|
||||
"elven_skirmisher",
|
||||
@ -78,6 +84,9 @@ module.exports = {
|
||||
"gargoyle",
|
||||
"cockatrice",
|
||||
"harpy",
|
||||
"biting_frost",
|
||||
"torrential_rain",
|
||||
"clear_weather",
|
||||
"impenetrable_fog",
|
||||
"endrega",
|
||||
"vampire_bruxa",
|
||||
|
@ -76,7 +76,6 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 gwent-lives">
|
||||
<!--<i class="ruby"></i>-->
|
||||
{{#health lives}}{{/health}}
|
||||
</div>
|
||||
</div>
|
||||
@ -92,30 +91,42 @@
|
||||
<div class="col-xs-6">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 battleside battleside-foe foe">
|
||||
<div class="col-xs-12 field">
|
||||
<div class="col-xs-2 field-horn field-horn-siege">
|
||||
</div>
|
||||
<div class="col-xs-10 field">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-siege"></div>
|
||||
</div>
|
||||
<div class="col-xs-12 field">
|
||||
<div class="col-xs-2 field-horn field-horn-range">
|
||||
</div>
|
||||
<div class="col-xs-10 field">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-range"></div>
|
||||
</div>
|
||||
<div class="col-xs-12 field">
|
||||
<div class="col-xs-2 field-horn field-horn-close">
|
||||
</div>
|
||||
<div class="col-xs-10 field">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-close"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 mid-line"></div>
|
||||
<div class="col-xs-12 battleside battleside-player player">
|
||||
<div class="col-xs-12 field{{#if agile}} active{{/if}}">
|
||||
<div class="col-xs-2 field-horn field-horn-close">
|
||||
</div>
|
||||
<div class="col-xs-10 field{{#if active.close}} active{{/if}}">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-close"></div>
|
||||
</div>
|
||||
<div class="col-xs-12 field{{#if agile}} active{{/if}}">
|
||||
<div class="col-xs-2 field-horn field-horn-range">
|
||||
</div>
|
||||
<div class="col-xs-10 field{{#if active.range}} active{{/if}}">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-range"></div>
|
||||
</div>
|
||||
<div class="col-xs-12 field">
|
||||
<div class="col-xs-2 field-horn field-horn-siege">
|
||||
</div>
|
||||
<div class="col-xs-10 field{{#if active.range}} active{{/if}}">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-siege"></div>
|
||||
</div>
|
||||
|
@ -21,16 +21,6 @@ Handlebars.registerHelper("health", function(lives, options){
|
||||
return out;
|
||||
});
|
||||
|
||||
/*
|
||||
var Config = {};
|
||||
|
||||
Config.Server = {
|
||||
"hostname": "localhost",
|
||||
"port": 16918,
|
||||
secure: false
|
||||
}
|
||||
*/
|
||||
|
||||
var App = Backbone.Router.extend({
|
||||
routes: {
|
||||
"lobby": "lobbyRoute",
|
||||
@ -137,7 +127,9 @@ var SideView = Backbone.View.extend({
|
||||
this.$info.find(".score").html(d.score);
|
||||
this.$info.find(".hand-card").html(d.hand);
|
||||
this.$info.find(".gwent-lives").html(this.lives(d.lives));
|
||||
if(l._key){
|
||||
this.$info.find(".field-leader").html(this.template(l))
|
||||
}
|
||||
|
||||
if(this.app.user.get("waiting") && this.side === ".player"){
|
||||
this.$info.addClass("removeBackground");
|
||||
@ -153,47 +145,61 @@ var SideView = Backbone.View.extend({
|
||||
if(!this.field.close) return;
|
||||
this.$fields = this.$el.find(".battleside" + this.side);
|
||||
var $field = this.$fields.find(".field-close").parent();
|
||||
var cards = this.field.close._cards;
|
||||
var score = this.field.close._score;
|
||||
var cards = this.field.close.cards;
|
||||
var score = this.field.close.score;
|
||||
var horn = this.field.close.horn;
|
||||
|
||||
|
||||
var html = this.templateCards(cards);
|
||||
|
||||
$field.find(".field-close").html(html)
|
||||
$field.find(".large-field-counter").html(score)
|
||||
if(horn){
|
||||
this.$fields.find(".field-horn-close").html(this.template(horn));
|
||||
}
|
||||
|
||||
calculateCardMargin($field.find(".card"), 433, 70, cards.length);
|
||||
calculateCardMargin($field.find(".card"), 351, 70, cards.length);
|
||||
},
|
||||
renderRangeField: function(){
|
||||
if(!this.field.ranged) return;
|
||||
this.$fields = this.$el.find(".battleside" + this.side);
|
||||
var $field = this.$fields.find(".field-range").parent();
|
||||
var cards = this.field.ranged._cards;
|
||||
var score = this.field.ranged._score;
|
||||
var cards = this.field.ranged.cards;
|
||||
var score = this.field.ranged.score;
|
||||
var horn = this.field.ranged.horn;
|
||||
|
||||
var html = this.templateCards(cards);
|
||||
|
||||
$field.find(".field-range").html(html)
|
||||
$field.find(".large-field-counter").html(score)
|
||||
calculateCardMargin($field.find(".card"), 433, 70, cards.length);
|
||||
if(horn){
|
||||
this.$fields.find(".field-horn-range").html(this.template(horn));
|
||||
}
|
||||
|
||||
calculateCardMargin($field.find(".card"), 351, 70, cards.length);
|
||||
},
|
||||
renderSiegeField: function(){
|
||||
if(!this.field.siege) return;
|
||||
this.$fields = this.$el.find(".battleside" + this.side);
|
||||
var $field = this.$fields.find(".field-siege").parent();
|
||||
var cards = this.field.siege._cards;
|
||||
var score = this.field.siege._score;
|
||||
var cards = this.field.siege.cards;
|
||||
var score = this.field.siege.score;
|
||||
var horn = this.field.siege.horn;
|
||||
|
||||
var html = this.templateCards(cards);
|
||||
|
||||
$field.find(".field-siege").html(html)
|
||||
$field.find(".large-field-counter").html(score)
|
||||
calculateCardMargin($field.find(".card"), 433, 70, cards.length);
|
||||
if(horn){
|
||||
this.$fields.find(".field-horn-siege").html(this.template(horn));
|
||||
}
|
||||
|
||||
calculateCardMargin($field.find(".card"), 351, 70, cards.length);
|
||||
},
|
||||
renderWeatherField: function(){
|
||||
if(!this.field.weather) return;
|
||||
var $weatherField = this.$el.find(".field-weather");
|
||||
var cards = this.field.weather._cards;
|
||||
var cards = this.field.weather.cards;
|
||||
$weatherField.html(this.templateCards(cards));
|
||||
|
||||
return this;
|
||||
@ -214,7 +220,7 @@ var SideView = Backbone.View.extend({
|
||||
var calculateCardMargin = function($selector, totalWidth, cardWidth, n){
|
||||
var w = totalWidth, c = cardWidth;
|
||||
var res;
|
||||
if(n < 7)
|
||||
if(n < 6)
|
||||
res = 0;
|
||||
else {
|
||||
res = -((w - c) / (n - 1) - c) + 1
|
||||
@ -240,6 +246,7 @@ var BattleView = Backbone.View.extend({
|
||||
this.listenTo(user, "change:passing", this.render);
|
||||
this.listenTo(user, "change:openDiscard", this.render);
|
||||
this.listenTo(user, "change:setAgile", this.render);
|
||||
this.listenTo(user, "change:setHorn", this.render);
|
||||
|
||||
this.$hand = this.$el.find(".field-hand");
|
||||
this.$preview = this.$el.find(".card-preview");
|
||||
@ -290,6 +297,14 @@ var BattleView = Backbone.View.extend({
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(!!this.user.get("setHorn")){
|
||||
if(id === this.user.get("setHorn")){
|
||||
this.user.set("setHorn", false);
|
||||
this.app.send("cancel:horn");
|
||||
this.render();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(!!this.user.get("waitForDecoy")){
|
||||
if(id === this.user.get("waitForDecoy")){
|
||||
this.user.set("waitForDecoy", false);
|
||||
@ -313,6 +328,9 @@ var BattleView = Backbone.View.extend({
|
||||
if(this.user.get("waitForDecoy")){
|
||||
var $card = $(e.target).closest(".card");
|
||||
var _id = $card.data("id");
|
||||
|
||||
if($card.parent().hasClass("field-horn")) return;
|
||||
|
||||
this.app.send("decoy:replaceWith", {
|
||||
cardID: _id
|
||||
})
|
||||
@ -328,6 +346,16 @@ var BattleView = Backbone.View.extend({
|
||||
});
|
||||
this.user.set("setAgile", false);
|
||||
}
|
||||
if(this.user.get("setHorn")){
|
||||
var $field = $(e.target).closest(".field.active").find(".field-close, .field-range, .field-siege");
|
||||
|
||||
console.log($field);
|
||||
var target = $field.hasClass("field-close") ? 0 : ($field.hasClass("field-range") ? 1 : 2);
|
||||
this.app.send("horn:field", {
|
||||
field: target
|
||||
});
|
||||
this.user.set("setHorn", false);
|
||||
}
|
||||
},
|
||||
onMouseover: function(e){
|
||||
var target = $(e.target).closest(".card");
|
||||
@ -355,13 +383,20 @@ var BattleView = Backbone.View.extend({
|
||||
var self = this;
|
||||
this.$el.html(this.template({
|
||||
cards: self.handCards,
|
||||
agile: self.user.get("setAgile")
|
||||
active: {
|
||||
close: self.user.get("setAgile") || self.user.get("setHorn"),
|
||||
range: self.user.get("setAgile") || self.user.get("setHorn"),
|
||||
siege: self.user.get("setHorn")
|
||||
}
|
||||
}));
|
||||
if(!(this.otherSide && this.yourSide)) return;
|
||||
this.otherSide.render();
|
||||
this.yourSide.render();
|
||||
|
||||
|
||||
if(this.handCards){
|
||||
calculateCardMargin(this.$el.find(".field-hand .card"), 538, 70, this.handCards.length);
|
||||
}
|
||||
|
||||
if(this.user.get("openDiscard")){
|
||||
var modal = new Modal({model: this.user});
|
||||
@ -375,6 +410,10 @@ var BattleView = Backbone.View.extend({
|
||||
var id = this.user.get("setAgile");
|
||||
this.$el.find("[data-id='" + id + "']").addClass("activeCard");
|
||||
}
|
||||
if(this.user.get("setHorn")){
|
||||
var id = this.user.get("setHorn");
|
||||
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");
|
||||
@ -529,6 +568,11 @@ var User = Backbone.Model.extend({
|
||||
self.set("setAgile", data.cardID);
|
||||
})
|
||||
|
||||
app.receive("played:horn", function(data){
|
||||
console.log("played horn");
|
||||
self.set("setHorn", data.cardID);
|
||||
})
|
||||
|
||||
app.on("createRoom", this.createRoom, this);
|
||||
app.on("joinRoom", this.joinRoom, this);
|
||||
app.on("setName", this.setName, this);
|
||||
|
@ -17,7 +17,7 @@ $game-height: 800px;
|
||||
}
|
||||
|
||||
.field {
|
||||
width: 100%;
|
||||
//width: 100%;
|
||||
height: 100px;
|
||||
border: 1px solid black;/*
|
||||
overflow: hidden;
|
||||
@ -35,6 +35,14 @@ $game-height: 800px;
|
||||
}
|
||||
}
|
||||
|
||||
.field-horn {/*
|
||||
border: 1px solid green;*/
|
||||
/*clear: both;*/
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
|
||||
}
|
||||
|
||||
.field:hover, .field-single:hover {
|
||||
box-shadow: 0px 0px 10px #000;
|
||||
}
|
||||
@ -104,11 +112,11 @@ $game-height: 800px;
|
||||
span {
|
||||
color: #00b000;
|
||||
font-weight: bold;
|
||||
font-size: 24px;
|
||||
font-size: 20px;
|
||||
position: absolute;
|
||||
text-shadow: 1px 1px #101010;
|
||||
margin-top: 55px;
|
||||
margin-left: 30px;
|
||||
margin-top: 62px;
|
||||
margin-left: 0px;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,7 @@ gulp.task("unit tests", function(){
|
||||
gulp.task("watch", function(){
|
||||
gulp.watch("./client/js/*", ["browserify"]);
|
||||
gulp.watch("./client/scss/*", ["sass"]);
|
||||
gulp.watch("./client/*.html", ["index"]);
|
||||
gulp.watch("./test/src/*", ["unit tests"]);
|
||||
})
|
||||
|
||||
|
@ -76,7 +76,6 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 gwent-lives">
|
||||
<!--<i class="ruby"></i>-->
|
||||
{{#health lives}}{{/health}}
|
||||
</div>
|
||||
</div>
|
||||
@ -92,30 +91,42 @@
|
||||
<div class="col-xs-6">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 battleside battleside-foe foe">
|
||||
<div class="col-xs-12 field">
|
||||
<div class="col-xs-2 field-horn field-horn-siege">
|
||||
</div>
|
||||
<div class="col-xs-10 field">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-siege"></div>
|
||||
</div>
|
||||
<div class="col-xs-12 field">
|
||||
<div class="col-xs-2 field-horn field-horn-range">
|
||||
</div>
|
||||
<div class="col-xs-10 field">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-range"></div>
|
||||
</div>
|
||||
<div class="col-xs-12 field">
|
||||
<div class="col-xs-2 field-horn field-horn-close">
|
||||
</div>
|
||||
<div class="col-xs-10 field">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-close"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 mid-line"></div>
|
||||
<div class="col-xs-12 battleside battleside-player player">
|
||||
<div class="col-xs-12 field{{#if agile}} active{{/if}}">
|
||||
<div class="col-xs-2 field-horn field-horn-close">
|
||||
</div>
|
||||
<div class="col-xs-10 field{{#if active.close}} active{{/if}}">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-close"></div>
|
||||
</div>
|
||||
<div class="col-xs-12 field{{#if agile}} active{{/if}}">
|
||||
<div class="col-xs-2 field-horn field-horn-range">
|
||||
</div>
|
||||
<div class="col-xs-10 field{{#if active.range}} active{{/if}}">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-range"></div>
|
||||
</div>
|
||||
<div class="col-xs-12 field">
|
||||
<div class="col-xs-2 field-horn field-horn-siege">
|
||||
</div>
|
||||
<div class="col-xs-10 field{{#if active.range}} active{{/if}}">
|
||||
<div class="col-xs-1 large-field-counter">0</div>
|
||||
<div class="col-xs-11 field-siege"></div>
|
||||
</div>
|
||||
|
@ -61,11 +61,17 @@ var Battle = (function(){
|
||||
this.p2.setLeadercard();
|
||||
this.p1.draw(10);
|
||||
this.p2.draw(10);
|
||||
this.p1.hand.add(Card("blue_stripes_commando"));
|
||||
this.p2.hand.add(Card("blue_stripes_commando"));
|
||||
this.p1.hand.add(Card("blue_stripes_commando"));
|
||||
this.p2.hand.add(Card("blue_stripes_commando"));
|
||||
this.p1.hand.add(Card("commanders_horn"));
|
||||
this.p2.hand.add(Card("commanders_horn"));
|
||||
this.p1.hand.add(Card("commanders_horn"));
|
||||
this.p2.hand.add(Card("commanders_horn"));
|
||||
/*
|
||||
this.p1.hand.add(Card("biting_frost"));
|
||||
this.p2.hand.add(Card("biting_frost"));
|
||||
this.p1.hand.add(Card("torrential_rain"));
|
||||
this.p2.hand.add(Card("torrential_rain"));
|
||||
this.p1.hand.add(Card("clear_weather"));
|
||||
this.p2.hand.add(Card("clear_weather"));*//*
|
||||
this.p1.hand.add(Card("kaedweni_siege_expert"));
|
||||
this.p2.hand.add(Card("kaedweni_siege_expert"));
|
||||
this.p1.hand.add(Card("ballista"));
|
||||
@ -77,8 +83,8 @@ var Battle = (function(){
|
||||
this.p1.hand.add(Card("ballista"));
|
||||
this.p2.hand.add(Card("ballista"));
|
||||
this.p1.hand.add(Card("ballista"));
|
||||
this.p2.hand.add(Card("ballista"));
|
||||
this.p1.hand.add(Card("decoy"));
|
||||
this.p2.hand.add(Card("ballista"));*/
|
||||
/*this.p1.hand.add(Card("decoy"));
|
||||
this.p2.hand.add(Card("decoy"));*/
|
||||
/*
|
||||
this.p1.hand.add(Card("dun_banner_medic"));
|
||||
@ -86,8 +92,8 @@ var Battle = (function(){
|
||||
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.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"));
|
||||
@ -155,10 +161,10 @@ var Battle = (function(){
|
||||
cards: JSON.stringify(p.hand.getCards())
|
||||
});
|
||||
p.send("update:fields", {
|
||||
close: p.field[Card.TYPE.CLOSE_COMBAT],
|
||||
ranged: p.field[Card.TYPE.RANGED],
|
||||
siege: p.field[Card.TYPE.SIEGE],
|
||||
weather: p.field[Card.TYPE.WEATHER]
|
||||
close: p.field[Card.TYPE.CLOSE_COMBAT].getInfo(),
|
||||
ranged: p.field[Card.TYPE.RANGED].getInfo(),
|
||||
siege: p.field[Card.TYPE.SIEGE].getInfo(),
|
||||
weather: p.field[Card.TYPE.WEATHER].getInfo()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,15 @@ Battleside = (function(){
|
||||
this._isWaiting = true;
|
||||
this.socket = user.socket;
|
||||
this.field = {};
|
||||
this.field[Card.TYPE.LEADER] = Field(Card.TYPE.LEADER);
|
||||
this.field[Card.TYPE.CLOSE_COMBAT] = Field(Card.TYPE.CLOSE_COMBAT);
|
||||
this.field[Card.TYPE.RANGED] = Field(Card.TYPE.RANGED);
|
||||
this.field[Card.TYPE.SIEGE] = Field(Card.TYPE.SIEGE);
|
||||
this.field[Card.TYPE.LEADER] = Field(this);
|
||||
this.field[Card.TYPE.CLOSE_COMBAT] = Field(this, true);
|
||||
this.field[Card.TYPE.RANGED] = Field(this, true);
|
||||
this.field[Card.TYPE.SIEGE] = Field(this, true);
|
||||
/*this.field[Card.TYPE.HORN] = {
|
||||
close: Field(this),
|
||||
range: Field(this),
|
||||
siege: Field(this)
|
||||
};*/
|
||||
this.n = n ? "p2" : "p1";
|
||||
this._name = name;
|
||||
this.battle = battle;
|
||||
@ -90,12 +95,22 @@ Battleside = (function(){
|
||||
})
|
||||
this.receive("agile:field", function(data){
|
||||
var fieldType = data.field;
|
||||
if(!(fieldType in [0, 1])) throw new Error("set field agile: false fieldtype " + fieldType);
|
||||
self.runEvent("agile:setField", null, [fieldType]);
|
||||
self.runEvent("NextTurn", null, [self.foe]);
|
||||
})
|
||||
this.receive("cancel:agile", function(){
|
||||
self.off("agile:setField");
|
||||
})
|
||||
this.receive("horn:field", function(data){
|
||||
var fieldType = data.field;
|
||||
if(!(fieldType in [0, 1, 2])) throw new Error("set field horn: false fieldtype " + fieldType);
|
||||
self.runEvent("horn:setField", null, [fieldType]);
|
||||
self.runEvent("NextTurn", null, [self.foe]);
|
||||
})
|
||||
this.receive("cancel:horn", function(){
|
||||
self.off("horn:setField");
|
||||
})
|
||||
|
||||
|
||||
this.on("Turn" + this.getID(), this.onTurnStart, this);
|
||||
@ -129,7 +144,7 @@ Battleside = (function(){
|
||||
}
|
||||
|
||||
r.setUpWeatherFieldWith = function(p2){
|
||||
this.field[Card.TYPE.WEATHER] = p2.field[Card.TYPE.WEATHER] = Field(Card.TYPE.WEATHER);
|
||||
this.field[Card.TYPE.WEATHER] = p2.field[Card.TYPE.WEATHER] = Field(this);
|
||||
}
|
||||
|
||||
r.findCardOnFieldByID = function(id){
|
||||
@ -279,8 +294,16 @@ Battleside = (function(){
|
||||
this.checkAbilities(card, obj);
|
||||
if(obj._cancelPlacement) return 0;
|
||||
|
||||
var field = obj.targetSide.field[card.getType()];
|
||||
|
||||
var field;
|
||||
if(typeof obj.isHorn !== "undefined"){
|
||||
field = obj.targetSide.field[obj.isHorn];
|
||||
field.add(card, true);
|
||||
}
|
||||
else {
|
||||
field = obj.targetSide.field[card.getType()];
|
||||
field.add(card);
|
||||
}
|
||||
|
||||
|
||||
this.runEvent("EachCardPlace");
|
||||
@ -298,6 +321,49 @@ Battleside = (function(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
r.setHorn = function(card) {
|
||||
var self = this;
|
||||
this.send("played:horn", {cardID: card.getID()}, true)
|
||||
this.on("horn:setField", function(type){
|
||||
self.off("horn:setField");
|
||||
card.changeType(type);
|
||||
self.placeCard(card, {
|
||||
isHorn: type,
|
||||
disabled: true
|
||||
});
|
||||
self.hand.remove(card);
|
||||
})
|
||||
}
|
||||
|
||||
r.commanderHornAbility = function(card) {
|
||||
var field = this.field[card.getType()];
|
||||
var id = "commanders_horn";
|
||||
|
||||
if(typeof field === "undefined") {
|
||||
//console.log("field unknown | %s", card.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
if(!field.isOnField(card)){
|
||||
field.get().forEach(function(_card){
|
||||
if(_card.getID() == id) return;
|
||||
if(_card.getType() != card.getType()) return;
|
||||
if(_card.hasAbility("hero")) return;
|
||||
_card.setBoost(id, 0);
|
||||
})
|
||||
this.off("EachCardPlace", card.getUidEvents("EachCardPlace"));
|
||||
return;
|
||||
}
|
||||
|
||||
field.get().forEach(function(_card){
|
||||
if(_card.getID() == id) return;
|
||||
if(_card.getType() != card.getType()) return;
|
||||
if(_card.hasAbility("hero")) return;
|
||||
_card.setBoost(id, 0);
|
||||
_card.setBoost(id, _card.getPower());
|
||||
})
|
||||
}
|
||||
|
||||
r.checkAbilities = function(card, obj, __flag){
|
||||
var self = this;
|
||||
obj.targetSide = this;
|
||||
@ -319,6 +385,13 @@ Battleside = (function(){
|
||||
if(ability.onBeforePlace){
|
||||
ability.onBeforePlace.apply(this, [card]);
|
||||
}
|
||||
if(ability.isCommandersHornCard) {
|
||||
this.setHorn(card);
|
||||
}
|
||||
if(ability.commandersHorn) {
|
||||
ability.onEachCardPlace = this.commanderHornAbility;
|
||||
ability.onWeatherChange = this.commanderHornAbility;
|
||||
}
|
||||
if(ability.cancelPlacement){
|
||||
obj._cancelPlacement = true;
|
||||
}
|
||||
@ -327,10 +400,11 @@ Battleside = (function(){
|
||||
}
|
||||
if(ability.changeSide){
|
||||
obj.targetSide = this.foe;
|
||||
}/*
|
||||
if(ability.onReset){
|
||||
this.on("Reset", ability.onReset, this, [card])
|
||||
}*/
|
||||
}
|
||||
if(typeof ability.weather !== "undefined"){
|
||||
ability.onEachTurn = this.setWeather.bind(this, ability.weather);
|
||||
ability.onEachCardPlace = this.setWeather.bind(this, ability.weather);
|
||||
}
|
||||
if(ability.replaceWith){
|
||||
obj._cancelPlacement = true;
|
||||
this.on("Decoy:replaceWith", function(replaceCard){
|
||||
@ -362,6 +436,10 @@ Battleside = (function(){
|
||||
var uid = this.on("EachCardPlace", ability.onEachCardPlace, this, [card]);
|
||||
card._uidEvents["EachCardPlace"] = uid;
|
||||
}
|
||||
if(ability.onWeatherChange){
|
||||
var uid = this.on("WeatherChange", ability.onWeatherChange, this, [card]);
|
||||
card._uidEvents["WeatherChange"] = uid;
|
||||
}
|
||||
|
||||
this.update();
|
||||
}
|
||||
@ -380,6 +458,49 @@ Battleside = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
r.setWeather = function(weather){
|
||||
var targetRow = weather;
|
||||
var field;
|
||||
if(typeof targetRow === "undefined") return;
|
||||
|
||||
|
||||
//console.log(this.field[Card.TYPE.WEATHER]);
|
||||
if(targetRow === Card.TYPE.WEATHER){
|
||||
field = this.field[targetRow];
|
||||
field.removeAll();
|
||||
|
||||
for(var i = Card.TYPE.CLOSE_COMBAT; i <= Card.TYPE.SIEGE; i++) {
|
||||
var _field1, _field2, _field;
|
||||
_field1 = this.field[i].get();
|
||||
_field2 = this.foe.field[i].get();
|
||||
_field = _field1.concat(_field2);
|
||||
|
||||
_field.forEach(function(_card){
|
||||
if(_card.hasAbility("hero")) return;
|
||||
_card.setForcedPower(-1);
|
||||
});
|
||||
}
|
||||
this.runEvent("WeatherChange");
|
||||
return;
|
||||
}
|
||||
var forcedPower = 1;
|
||||
|
||||
if(typeof targetRow === "undefined"){
|
||||
console.trace(this);
|
||||
}
|
||||
var field1 = this.field[targetRow].get();
|
||||
var field2 = this.foe.field[targetRow].get();
|
||||
|
||||
field = field1.concat(field2);
|
||||
|
||||
field.forEach(function(_card){
|
||||
if(_card.hasAbility("hero")) return;
|
||||
_card.setForcedPower(forcedPower);
|
||||
});
|
||||
this.runEvent("WeatherChange");
|
||||
this.update();
|
||||
}
|
||||
|
||||
r.clearMainFields = function(){
|
||||
var cards1 = this.field[Card.TYPE.CLOSE_COMBAT].removeAll();
|
||||
var cards2 = this.field[Card.TYPE.RANGED].removeAll();
|
||||
|
@ -17,7 +17,6 @@ var Card = (function(){
|
||||
this._boost = {};
|
||||
this._forcedPower = -1;
|
||||
this._init();
|
||||
|
||||
};
|
||||
var r = Card.prototype;
|
||||
/**
|
||||
@ -68,6 +67,7 @@ var Card = (function(){
|
||||
}
|
||||
r.setForcedPower = function(nr){
|
||||
this._forcedPower = nr;
|
||||
/*this.getBoost(); *///recalculate
|
||||
}
|
||||
r.getRawAbility = function(){
|
||||
return this._data.ability;
|
||||
@ -82,6 +82,16 @@ var Card = (function(){
|
||||
}
|
||||
return AbilityData[this._data.ability];
|
||||
}
|
||||
r.hasAbility = function(ability) {
|
||||
var a = this.getRawAbility();
|
||||
if(Array.isArray(a)) {
|
||||
for(var i=0; i<a.length; i++) {
|
||||
var _a = a[i];
|
||||
if(_a === ability) return true;
|
||||
}
|
||||
}
|
||||
return a === ability;
|
||||
}
|
||||
r.getImage = function(){
|
||||
return "../assets/cards/" + this._data.img + ".png";
|
||||
}
|
||||
@ -105,11 +115,6 @@ var Card = (function(){
|
||||
return this._id;
|
||||
}
|
||||
|
||||
/*r.boost = function(nr){
|
||||
this.getPower(); //to recalculate this._power;
|
||||
this._boost += nr;
|
||||
}*/
|
||||
|
||||
r.getBoost = function() {
|
||||
var res = 0;
|
||||
for(var key in this._boost) {
|
||||
|
@ -1,13 +1,15 @@
|
||||
var Field = (function(){
|
||||
var Field = function(){
|
||||
var Field = function(side, hasHornField){
|
||||
if(!(this instanceof Field)){
|
||||
return (new Field());
|
||||
return (new Field(side, hasHornField));
|
||||
}
|
||||
/**
|
||||
* constructor here
|
||||
*/
|
||||
|
||||
this._hasHornField = hasHornField || false;
|
||||
this._cards = [];
|
||||
this.side = side;
|
||||
};
|
||||
var r = Field.prototype;
|
||||
/**
|
||||
@ -18,8 +20,19 @@ var Field = (function(){
|
||||
|
||||
r._cards = null;
|
||||
r._score = 0;
|
||||
r._hasHornField = null;
|
||||
r._hornCard = null;
|
||||
r.side = null;
|
||||
|
||||
r.add = function(card){
|
||||
r.add = function(card, isHorn){
|
||||
/*if(card.hasAbility("commanders_horn")) {
|
||||
this.setHorn(card);
|
||||
return;
|
||||
}*/
|
||||
if(isHorn && this._hasHornField) {
|
||||
this.setHorn(card);
|
||||
return;
|
||||
}
|
||||
this._cards.push(card);
|
||||
this.updateScore();
|
||||
}
|
||||
@ -49,6 +62,9 @@ var Field = (function(){
|
||||
}
|
||||
|
||||
r.isOnField = function(card){
|
||||
if(this._hasHornField && this.getHorn() && card.getID() === this.getHorn().getID()){
|
||||
return true;
|
||||
}
|
||||
return this.getPosition(card) >= 0;
|
||||
}
|
||||
|
||||
@ -69,13 +85,45 @@ var Field = (function(){
|
||||
|
||||
r.removeAll = function(){
|
||||
var tmp = this._cards.slice();
|
||||
var self = this;
|
||||
tmp.forEach(function(card){
|
||||
card.reset();
|
||||
for(var event in card._uidEvents) {
|
||||
self.side.off(event, card.getUidEvents(event));
|
||||
}
|
||||
})
|
||||
this._cards = [];
|
||||
if(this.getHorn()) {
|
||||
var card = this.getHorn();
|
||||
card.reset();
|
||||
this.setHorn(null);
|
||||
for(var event in card._uidEvents) {
|
||||
self.side.off(event, card.getUidEvents(event));
|
||||
}
|
||||
tmp.push(card);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
r.getInfo = function() {
|
||||
var self = this;
|
||||
return {
|
||||
cards: self._cards,
|
||||
horn: self.getHorn(),
|
||||
score: self._score
|
||||
}
|
||||
}
|
||||
|
||||
r.getHorn = function() {
|
||||
if(!this._hasHornField) return null;
|
||||
return this._hornCard;
|
||||
}
|
||||
|
||||
r.setHorn = function(card) {
|
||||
if(!this._hasHornField) return null;
|
||||
this._hornCard = card;
|
||||
}
|
||||
|
||||
return Field;
|
||||
})();
|
||||
|
||||
|
@ -23,7 +23,8 @@ var Hand = (function(){
|
||||
*/
|
||||
r._hand = null;
|
||||
|
||||
r.add = function(card){
|
||||
r.add = function(card){/*
|
||||
console.log(card.getID(), card.getName());*/
|
||||
this._hand.push(card);
|
||||
}
|
||||
|
||||
@ -45,6 +46,8 @@ var Hand = (function(){
|
||||
//console.trace(id);
|
||||
id = id instanceof Card ? id.getID() : id;
|
||||
|
||||
if(!n) return -1;
|
||||
|
||||
for(var i = 0; i < n; i++) {
|
||||
if(!this._hand[i]) {
|
||||
console.trace(this._hand[i]);
|
||||
@ -59,6 +62,7 @@ var Hand = (function(){
|
||||
|
||||
r.getRandomCard = function(){
|
||||
var rnd = (Math.random() * this._hand.length) | 0;
|
||||
if(!this._hand.length) return -1;
|
||||
return this._hand[rnd];
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
2
site/server/composer.lock
generated
2
site/server/composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "5c6026b96e6fa11a641b51a6ba976f5e",
|
||||
"hash": "541ee30ee4a0e782a2473d5a9ab09eb0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "classpreloader/classpreloader",
|
||||
|
13
test/src/CardSpec.js
Normal file
13
test/src/CardSpec.js
Normal file
@ -0,0 +1,13 @@
|
||||
var Card = require("../../server/Card");
|
||||
|
||||
describe("cards", function(){
|
||||
var card;
|
||||
|
||||
beforeEach(function() {
|
||||
card = Card("john_natalis");
|
||||
});
|
||||
|
||||
it("should have hero ability", function() {
|
||||
expect(card.hasAbility("hero")).toBe(true);
|
||||
})
|
||||
})
|
@ -94,5 +94,37 @@ describe("pubsub", function(){
|
||||
expect(battle.events).toEqual({});*/
|
||||
})
|
||||
|
||||
it("should give binded ctx", function() {
|
||||
var obj = {}, otherCtx = { key: "test"};
|
||||
var card = Card("biting_frost");
|
||||
var ability = card.getAbility();
|
||||
|
||||
obj.setWeather = function(weatherType) {
|
||||
expect(weatherType).toEqual(0);
|
||||
expect(this).toBe(otherCtx);
|
||||
}
|
||||
|
||||
spyOn(obj, "setWeather").and.callThrough();
|
||||
|
||||
expect(ability.weather).toBeDefined();
|
||||
|
||||
ability.onEachTurn = obj.setWeather.bind(otherCtx, ability.weather);
|
||||
ability.onEachCardPlace = obj.setWeather.bind(otherCtx, ability.weather);
|
||||
|
||||
if(ability.onEachTurn){
|
||||
var uid = battle.on("EachTurn", ability.onEachTurn, battle, [card])
|
||||
card._uidEvents["EachTurn"] = uid;
|
||||
}
|
||||
if(ability.onEachCardPlace){
|
||||
var uid = battle.on("EachCardPlace", ability.onEachCardPlace, battle, [card]);
|
||||
card._uidEvents["EachCardPlace"] = uid;
|
||||
}
|
||||
|
||||
battle.runEvent("EachCardPlace");
|
||||
battle.runEvent("EachTurn");
|
||||
|
||||
expect(obj.setWeather).toHaveBeenCalled();
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
require("./filterSpec");
|
||||
require("./PubSubSpec");
|
||||
require("./CardSpec");
|
||||
|
||||
(function main(){
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user