1
0
mirror of https://github.com/exane/not-gwent-online synced 2024-10-31 10:36:53 +00:00
This commit is contained in:
devfake 2015-06-22 19:16:32 +02:00
commit 513efc2116
7 changed files with 85 additions and 81 deletions

View File

@ -209,58 +209,12 @@ module.exports = {
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());
})
}*/
commandersHorn: true
},
"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());
})
}*/
isCommandersHornCard: true
},
"foltest_leader1": {
onActivate: function(){
@ -277,12 +231,17 @@ module.exports = {
},
"foltest_leader3": {
onActivate: function(){
var siegeCards = this.field[2].get();
var field = this.field[2];
//todo: unless there is commanders horn active
siegeCards.forEach(function(card){
/*siegeCards.forEach(function(card){
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": {

View File

@ -4,7 +4,6 @@ var Backbone = require("backbone");
require("./backbone.modal-min");
var Handlebars = require("handlebars");
var $ = require("jquery");
//var Lobby = require("./client-lobby");
window.$ = $;
@ -307,6 +306,7 @@ var BattleView = Backbone.View.extend({
onClickFieldCard: function(e){
if(this.user.get("waitForDecoy")){
var $card = $(e.target).closest(".card");
if(!$card.length) return;
var _id = $card.data("id");
if($card.parent().hasClass("field-horn")) return;
@ -405,9 +405,10 @@ var BattleView = Backbone.View.extend({
},
clickLeader: function(e){
var $card = $(e.target).closest(".field-leader");
console.log("click leader");
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")

View File

@ -89,7 +89,7 @@
</div>
<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-10 field{{#if active.siege}} active{{/if}}">
<div class="col-xs-1 large-field-counter">0</div>
<div class="col-xs-11 field-siege"></div>
</div>

View File

@ -59,6 +59,7 @@ gulp.task("unit tests", function(){
gulp.task("watch", function(){
gulp.watch("./client/js/*", ["browserify"]);
gulp.watch("./client/templates/*", ["browserify"]);
gulp.watch("./client/scss/*", ["sass"]);
gulp.watch("./client/*.html", ["index"]);
gulp.watch("./test/src/*", ["unit tests"]);

View File

@ -61,8 +61,12 @@ var Battle = (function(){
this.p2.setLeadercard();
this.p1.draw(10);
this.p2.draw(10);
/*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("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.p2.hand.add(Card("milva"));
this.p1.hand.add(Card("havekar_healer"));
@ -72,7 +76,7 @@ var Battle = (function(){
this.p1.hand.add(Card("vrihedd_brigade_recruit"));
this.p2.hand.add(Card("vrihedd_brigade_recruit"));
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"));
@ -96,8 +100,7 @@ var Battle = (function(){
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("decoy"));*/
/*
this.p1.hand.add(Card("dun_banner_medic"));
this.p2.hand.add(Card("dun_banner_medic"));

View File

@ -46,11 +46,11 @@ Battleside = (function(){
if(self._isWaiting) return;
if(self.isPassing()) return;
console.log("leader activated");
var leaderCard = self.getLeader();
if(leaderCard.isDisabled()) return;
console.log("leader activated");
var ability = leaderCard.getAbility();
@ -291,17 +291,25 @@ Battleside = (function(){
r.placeCard = function(card, obj){
obj = _.extend({}, obj);
if(typeof card === "string" ) {
card = Card(card);
}
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"){
field = obj.targetSide.field[obj.isHorn];
if(!field){
field = obj.targetSide.field[obj.isHorn];
}
field.add(card, true);
}
else {
field = obj.targetSide.field[card.getType()];
if(!field){
field = obj.targetSide.field[card.getType()];
}
field.add(card);
}
@ -321,8 +329,24 @@ Battleside = (function(){
return 1;
}
r.setHorn = function(card) {
r.setHorn = function(card, field){
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.on("horn:setField", function(type){
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 id = "commanders_horn";
if(typeof field === "undefined") {
if(typeof field === "undefined"){
//console.log("field unknown | %s", card.getName());
return;
}
@ -385,17 +409,17 @@ Battleside = (function(){
if(ability.onBeforePlace){
ability.onBeforePlace.apply(this, [card]);
}
if(ability.isCommandersHornCard) {
if(ability.isCommandersHornCard && !obj.isHorn){
this.setHorn(card);
}
if(ability.commandersHorn) {
if(ability.commandersHorn){
ability.onEachCardPlace = this.commanderHornAbility;
ability.onWeatherChange = this.commanderHornAbility;
}
if(ability.cancelPlacement){
if(ability.cancelPlacement && !obj.forcePlace){
obj._cancelPlacement = true;
}
if(ability.waitResponse){
if(ability.waitResponse && !obj.forcePlace){
obj._waitResponse = true;
}
if(ability.changeSide){
@ -405,7 +429,7 @@ Battleside = (function(){
ability.onEachTurn = 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;
this.on("Decoy:replaceWith", function(replaceCard){
if(replaceCard.getType() == Card.TYPE.LEADER ||

View File

@ -44,7 +44,7 @@ var Card = (function(){
r._uidEvents = null;
r.getUidEvents = function(key) {
r.getUidEvents = function(key){
return this._uidEvents[key];
}
@ -55,12 +55,22 @@ var Card = (function(){
r.getName = function(){
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(){
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._data.power + this.getBoost();
return this._data.power + this.getBoost();*/
}
r.getRawPower = function(){
return this._data.power;
@ -82,10 +92,10 @@ var Card = (function(){
}
return AbilityData[this._data.ability];
}
r.hasAbility = function(ability) {
r.hasAbility = function(ability){
var a = this.getRawAbility();
if(Array.isArray(a)) {
for(var i=0; i<a.length; i++) {
if(Array.isArray(a)){
for(var i = 0; i < a.length; i++) {
var _a = a[i];
if(_a === ability) return true;
}
@ -115,16 +125,22 @@ var Card = (function(){
return this._id;
}
r.getBoost = function() {
r.getBoost = function(){
var res = 0;
for(var key in this._boost) {
if(key === "commanders_horn" || key === "commanders_horn_card") continue;
res += this._boost[key];
}
if(this._boost["commanders_horn"] || this._boost["commanders_horn_card"]){
res += res + this.getBasePower();
}
this.boost = res;
return res;
}
r.setBoost = function(key, val) {
r.setBoost = function(key, val){
this._boost[key] = val;
this.getBoost(); //to recalculate this.boost
}