mirror of
https://github.com/exane/not-gwent-online
synced 2024-10-31 10:36:53 +00:00
Merge branch 'master' of https://github.com/exane/gwent-online
This commit is contained in:
commit
513efc2116
@ -209,58 +209,12 @@ module.exports = {
|
|||||||
replaceWith: true
|
replaceWith: true
|
||||||
},
|
},
|
||||||
"commanders_horn": {
|
"commanders_horn": {
|
||||||
commandersHorn: true/*,
|
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": {
|
"commanders_horn_card": {
|
||||||
cancelPlacement: true,
|
cancelPlacement: true,
|
||||||
commandersHorn: true,
|
commandersHorn: true,
|
||||||
isCommandersHornCard: 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": {
|
"foltest_leader1": {
|
||||||
onActivate: function(){
|
onActivate: function(){
|
||||||
@ -277,12 +231,17 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
"foltest_leader3": {
|
"foltest_leader3": {
|
||||||
onActivate: function(){
|
onActivate: function(){
|
||||||
var siegeCards = this.field[2].get();
|
var field = this.field[2];
|
||||||
|
|
||||||
//todo: unless there is commanders horn active
|
//todo: unless there is commanders horn active
|
||||||
siegeCards.forEach(function(card){
|
/*siegeCards.forEach(function(card){
|
||||||
card.setBoost("foltest_leader3", card.getPower());
|
card.setBoost("foltest_leader3", card.getPower());
|
||||||
})
|
})*/
|
||||||
|
/*field.add(Card("commanders_horn", true));*/
|
||||||
|
/*this.placeCard("commanders_horn", {
|
||||||
|
forceField: field
|
||||||
|
});*/
|
||||||
|
this.setHorn("commanders_horn", 2);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"foltest_leader4": {
|
"foltest_leader4": {
|
||||||
|
@ -4,7 +4,6 @@ var Backbone = require("backbone");
|
|||||||
require("./backbone.modal-min");
|
require("./backbone.modal-min");
|
||||||
var Handlebars = require("handlebars");
|
var Handlebars = require("handlebars");
|
||||||
var $ = require("jquery");
|
var $ = require("jquery");
|
||||||
//var Lobby = require("./client-lobby");
|
|
||||||
|
|
||||||
window.$ = $;
|
window.$ = $;
|
||||||
|
|
||||||
@ -307,6 +306,7 @@ var BattleView = Backbone.View.extend({
|
|||||||
onClickFieldCard: function(e){
|
onClickFieldCard: function(e){
|
||||||
if(this.user.get("waitForDecoy")){
|
if(this.user.get("waitForDecoy")){
|
||||||
var $card = $(e.target).closest(".card");
|
var $card = $(e.target).closest(".card");
|
||||||
|
if(!$card.length) return;
|
||||||
var _id = $card.data("id");
|
var _id = $card.data("id");
|
||||||
|
|
||||||
if($card.parent().hasClass("field-horn")) return;
|
if($card.parent().hasClass("field-horn")) return;
|
||||||
@ -405,9 +405,10 @@ var BattleView = Backbone.View.extend({
|
|||||||
},
|
},
|
||||||
clickLeader: function(e){
|
clickLeader: function(e){
|
||||||
var $card = $(e.target).closest(".field-leader");
|
var $card = $(e.target).closest(".field-leader");
|
||||||
console.log("click leader");
|
|
||||||
if(!$card.parent().hasClass("player")) return;
|
if(!$card.parent().hasClass("player")) return;
|
||||||
if($card.hasClass("disabled")) return;
|
if($card.find(".card").hasClass("disabled")) return;
|
||||||
|
|
||||||
|
console.log("click leader");
|
||||||
|
|
||||||
|
|
||||||
this.app.send("activate:leader")
|
this.app.send("activate:leader")
|
||||||
|
@ -89,7 +89,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-xs-2 field-horn field-horn-siege">
|
<div class="col-xs-2 field-horn field-horn-siege">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-10 field{{#if active.range}} active{{/if}}">
|
<div class="col-xs-10 field{{#if active.siege}} active{{/if}}">
|
||||||
<div class="col-xs-1 large-field-counter">0</div>
|
<div class="col-xs-1 large-field-counter">0</div>
|
||||||
<div class="col-xs-11 field-siege"></div>
|
<div class="col-xs-11 field-siege"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -59,6 +59,7 @@ gulp.task("unit tests", function(){
|
|||||||
|
|
||||||
gulp.task("watch", function(){
|
gulp.task("watch", function(){
|
||||||
gulp.watch("./client/js/*", ["browserify"]);
|
gulp.watch("./client/js/*", ["browserify"]);
|
||||||
|
gulp.watch("./client/templates/*", ["browserify"]);
|
||||||
gulp.watch("./client/scss/*", ["sass"]);
|
gulp.watch("./client/scss/*", ["sass"]);
|
||||||
gulp.watch("./client/*.html", ["index"]);
|
gulp.watch("./client/*.html", ["index"]);
|
||||||
gulp.watch("./test/src/*", ["unit tests"]);
|
gulp.watch("./test/src/*", ["unit tests"]);
|
||||||
|
@ -61,8 +61,12 @@ var Battle = (function(){
|
|||||||
this.p2.setLeadercard();
|
this.p2.setLeadercard();
|
||||||
this.p1.draw(10);
|
this.p1.draw(10);
|
||||||
this.p2.draw(10);
|
this.p2.draw(10);
|
||||||
/*this.p1.hand.add(Card("commanders_horn"));
|
this.p1.hand.add(Card("commanders_horn"));
|
||||||
this.p2.hand.add(Card("commanders_horn"));
|
this.p2.hand.add(Card("commanders_horn"));/*
|
||||||
|
this.p1.hand.add(Card("ciaran_aep_easnillien"));
|
||||||
|
this.p2.hand.add(Card("ciaran_aep_easnillien"));*/
|
||||||
|
/*this.p1.hand.add(Card("decoy"));
|
||||||
|
this.p2.hand.add(Card("decoy"));*/
|
||||||
this.p1.hand.add(Card("milva"));
|
this.p1.hand.add(Card("milva"));
|
||||||
this.p2.hand.add(Card("milva"));
|
this.p2.hand.add(Card("milva"));
|
||||||
this.p1.hand.add(Card("havekar_healer"));
|
this.p1.hand.add(Card("havekar_healer"));
|
||||||
@ -72,7 +76,7 @@ var Battle = (function(){
|
|||||||
this.p1.hand.add(Card("vrihedd_brigade_recruit"));
|
this.p1.hand.add(Card("vrihedd_brigade_recruit"));
|
||||||
this.p2.hand.add(Card("vrihedd_brigade_recruit"));
|
this.p2.hand.add(Card("vrihedd_brigade_recruit"));
|
||||||
this.p1.hand.add(Card("impenetrable_fog"));
|
this.p1.hand.add(Card("impenetrable_fog"));
|
||||||
this.p2.hand.add(Card("impenetrable_fog"));*/
|
this.p2.hand.add(Card("impenetrable_fog"));
|
||||||
/*
|
/*
|
||||||
this.p1.hand.add(Card("commanders_horn"));
|
this.p1.hand.add(Card("commanders_horn"));
|
||||||
this.p1.hand.add(Card("commanders_horn"));
|
this.p1.hand.add(Card("commanders_horn"));
|
||||||
@ -96,8 +100,7 @@ var Battle = (function(){
|
|||||||
this.p2.hand.add(Card("ballista"));
|
this.p2.hand.add(Card("ballista"));
|
||||||
this.p1.hand.add(Card("ballista"));
|
this.p1.hand.add(Card("ballista"));
|
||||||
this.p2.hand.add(Card("ballista"));*/
|
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"));
|
this.p1.hand.add(Card("dun_banner_medic"));
|
||||||
this.p2.hand.add(Card("dun_banner_medic"));
|
this.p2.hand.add(Card("dun_banner_medic"));
|
||||||
|
@ -46,11 +46,11 @@ Battleside = (function(){
|
|||||||
if(self._isWaiting) return;
|
if(self._isWaiting) return;
|
||||||
if(self.isPassing()) return;
|
if(self.isPassing()) return;
|
||||||
|
|
||||||
console.log("leader activated");
|
|
||||||
|
|
||||||
var leaderCard = self.getLeader();
|
var leaderCard = self.getLeader();
|
||||||
if(leaderCard.isDisabled()) return;
|
if(leaderCard.isDisabled()) return;
|
||||||
|
|
||||||
|
console.log("leader activated");
|
||||||
|
|
||||||
var ability = leaderCard.getAbility();
|
var ability = leaderCard.getAbility();
|
||||||
|
|
||||||
@ -291,17 +291,25 @@ Battleside = (function(){
|
|||||||
r.placeCard = function(card, obj){
|
r.placeCard = function(card, obj){
|
||||||
obj = _.extend({}, obj);
|
obj = _.extend({}, obj);
|
||||||
|
|
||||||
|
if(typeof card === "string" ) {
|
||||||
|
card = Card(card);
|
||||||
|
}
|
||||||
|
|
||||||
this.checkAbilities(card, obj);
|
this.checkAbilities(card, obj);
|
||||||
if(obj._cancelPlacement) return 0;
|
if(obj._cancelPlacement && !obj.forceField) return 0;
|
||||||
|
|
||||||
|
|
||||||
var field;
|
var field = obj.forceField || null;
|
||||||
if(typeof obj.isHorn !== "undefined"){
|
if(typeof obj.isHorn !== "undefined"){
|
||||||
field = obj.targetSide.field[obj.isHorn];
|
if(!field){
|
||||||
|
field = obj.targetSide.field[obj.isHorn];
|
||||||
|
}
|
||||||
field.add(card, true);
|
field.add(card, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
field = obj.targetSide.field[card.getType()];
|
if(!field){
|
||||||
|
field = obj.targetSide.field[card.getType()];
|
||||||
|
}
|
||||||
field.add(card);
|
field.add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,8 +329,24 @@ Battleside = (function(){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.setHorn = function(card) {
|
r.setHorn = function(card, field){
|
||||||
var self = this;
|
var self = this;
|
||||||
|
field = typeof field === "undefined" ? null : field;
|
||||||
|
|
||||||
|
if(typeof card === "string"){
|
||||||
|
card = Card(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof field === "number") {
|
||||||
|
card.changeType(field);
|
||||||
|
this.placeCard(card, {
|
||||||
|
isHorn: field,
|
||||||
|
forcePlace: true
|
||||||
|
});
|
||||||
|
self.hand.remove(card);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.send("played:horn", {cardID: card.getID()}, true)
|
this.send("played:horn", {cardID: card.getID()}, true)
|
||||||
this.on("horn:setField", function(type){
|
this.on("horn:setField", function(type){
|
||||||
self.off("horn:setField");
|
self.off("horn:setField");
|
||||||
@ -335,11 +359,11 @@ Battleside = (function(){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
r.commanderHornAbility = function(card) {
|
r.commanderHornAbility = function(card){
|
||||||
var field = this.field[card.getType()];
|
var field = this.field[card.getType()];
|
||||||
var id = "commanders_horn";
|
var id = "commanders_horn";
|
||||||
|
|
||||||
if(typeof field === "undefined") {
|
if(typeof field === "undefined"){
|
||||||
//console.log("field unknown | %s", card.getName());
|
//console.log("field unknown | %s", card.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -385,17 +409,17 @@ Battleside = (function(){
|
|||||||
if(ability.onBeforePlace){
|
if(ability.onBeforePlace){
|
||||||
ability.onBeforePlace.apply(this, [card]);
|
ability.onBeforePlace.apply(this, [card]);
|
||||||
}
|
}
|
||||||
if(ability.isCommandersHornCard) {
|
if(ability.isCommandersHornCard && !obj.isHorn){
|
||||||
this.setHorn(card);
|
this.setHorn(card);
|
||||||
}
|
}
|
||||||
if(ability.commandersHorn) {
|
if(ability.commandersHorn){
|
||||||
ability.onEachCardPlace = this.commanderHornAbility;
|
ability.onEachCardPlace = this.commanderHornAbility;
|
||||||
ability.onWeatherChange = this.commanderHornAbility;
|
ability.onWeatherChange = this.commanderHornAbility;
|
||||||
}
|
}
|
||||||
if(ability.cancelPlacement){
|
if(ability.cancelPlacement && !obj.forcePlace){
|
||||||
obj._cancelPlacement = true;
|
obj._cancelPlacement = true;
|
||||||
}
|
}
|
||||||
if(ability.waitResponse){
|
if(ability.waitResponse && !obj.forcePlace){
|
||||||
obj._waitResponse = true;
|
obj._waitResponse = true;
|
||||||
}
|
}
|
||||||
if(ability.changeSide){
|
if(ability.changeSide){
|
||||||
@ -405,7 +429,7 @@ Battleside = (function(){
|
|||||||
ability.onEachTurn = this.setWeather.bind(this, ability.weather);
|
ability.onEachTurn = this.setWeather.bind(this, ability.weather);
|
||||||
ability.onEachCardPlace = this.setWeather.bind(this, ability.weather);
|
ability.onEachCardPlace = this.setWeather.bind(this, ability.weather);
|
||||||
}
|
}
|
||||||
if(ability.replaceWith){
|
if(ability.replaceWith && !obj.forcePlace){
|
||||||
obj._cancelPlacement = true;
|
obj._cancelPlacement = true;
|
||||||
this.on("Decoy:replaceWith", function(replaceCard){
|
this.on("Decoy:replaceWith", function(replaceCard){
|
||||||
if(replaceCard.getType() == Card.TYPE.LEADER ||
|
if(replaceCard.getType() == Card.TYPE.LEADER ||
|
||||||
|
@ -44,7 +44,7 @@ var Card = (function(){
|
|||||||
|
|
||||||
r._uidEvents = null;
|
r._uidEvents = null;
|
||||||
|
|
||||||
r.getUidEvents = function(key) {
|
r.getUidEvents = function(key){
|
||||||
return this._uidEvents[key];
|
return this._uidEvents[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,12 +55,22 @@ var Card = (function(){
|
|||||||
r.getName = function(){
|
r.getName = function(){
|
||||||
return this._data.name;
|
return this._data.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.getBasePower = function() {
|
||||||
|
var base = this._data.power;
|
||||||
|
if(this._forcedPower > -1){
|
||||||
|
base = this._forcedPower > this._data.power ? this._data.power : this._forcedPower;
|
||||||
|
}
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
r.getPower = function(){
|
r.getPower = function(){
|
||||||
if(this._data.power === -1) return 0;
|
if(this._data.power === -1) return 0;
|
||||||
if(this._forcedPower > -1){
|
return this.getBasePower() + this.getBoost();
|
||||||
|
/*if(this._forcedPower > -1){
|
||||||
return (this._forcedPower > this._data.power ? this._data.power : this._forcedPower) + this.getBoost();
|
return (this._forcedPower > this._data.power ? this._data.power : this._forcedPower) + this.getBoost();
|
||||||
}
|
}
|
||||||
return this._data.power + this.getBoost();
|
return this._data.power + this.getBoost();*/
|
||||||
}
|
}
|
||||||
r.getRawPower = function(){
|
r.getRawPower = function(){
|
||||||
return this._data.power;
|
return this._data.power;
|
||||||
@ -82,10 +92,10 @@ var Card = (function(){
|
|||||||
}
|
}
|
||||||
return AbilityData[this._data.ability];
|
return AbilityData[this._data.ability];
|
||||||
}
|
}
|
||||||
r.hasAbility = function(ability) {
|
r.hasAbility = function(ability){
|
||||||
var a = this.getRawAbility();
|
var a = this.getRawAbility();
|
||||||
if(Array.isArray(a)) {
|
if(Array.isArray(a)){
|
||||||
for(var i=0; i<a.length; i++) {
|
for(var i = 0; i < a.length; i++) {
|
||||||
var _a = a[i];
|
var _a = a[i];
|
||||||
if(_a === ability) return true;
|
if(_a === ability) return true;
|
||||||
}
|
}
|
||||||
@ -115,16 +125,22 @@ var Card = (function(){
|
|||||||
return this._id;
|
return this._id;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.getBoost = function() {
|
r.getBoost = function(){
|
||||||
var res = 0;
|
var res = 0;
|
||||||
for(var key in this._boost) {
|
for(var key in this._boost) {
|
||||||
|
if(key === "commanders_horn" || key === "commanders_horn_card") continue;
|
||||||
res += this._boost[key];
|
res += this._boost[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this._boost["commanders_horn"] || this._boost["commanders_horn_card"]){
|
||||||
|
res += res + this.getBasePower();
|
||||||
|
}
|
||||||
|
|
||||||
this.boost = res;
|
this.boost = res;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.setBoost = function(key, val) {
|
r.setBoost = function(key, val){
|
||||||
this._boost[key] = val;
|
this._boost[key] = val;
|
||||||
this.getBoost(); //to recalculate this.boost
|
this.getBoost(); //to recalculate this.boost
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user