1
0
mirror of https://github.com/exane/not-gwent-online synced 2024-10-31 10:36:53 +00:00

update stuff

This commit is contained in:
exane 2015-06-22 18:48:08 +02:00
parent 03f6645211
commit d4fc3b0404
5 changed files with 78 additions and 78 deletions

View File

@ -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": {

View File

@ -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")

View File

@ -62,12 +62,12 @@ var Battle = (function(){
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.p1.hand.add(Card("ciaran_aep_easnillien"));
this.p2.hand.add(Card("ciaran_aep_easnillien")); this.p2.hand.add(Card("ciaran_aep_easnillien"));*/
/*this.p1.hand.add(Card("decoy")); /*this.p1.hand.add(Card("decoy"));
this.p2.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"));
this.p2.hand.add(Card("havekar_healer")); this.p2.hand.add(Card("havekar_healer"));
@ -76,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"));

View File

@ -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 ||

View File

@ -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
} }