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

monster faction ability fix

This commit is contained in:
exane 2015-07-01 09:17:16 +02:00
parent b5d28bcc08
commit 7f0d7f9db8
2 changed files with 39 additions and 22 deletions

View File

@ -197,7 +197,7 @@ Battleside = (function(){
var allCards = close.concat(range.concat(siege)); var allCards = close.concat(range.concat(siege));
var rnd = (Math.random() * allCards.length) | 0; var rnd = (Math.random() * allCards.length) | 0;
if(allCards[rnd].getType === 4) return null; //if(allCards[rnd].getType === 4) return null;
return allCards[rnd]; return allCards[rnd];
} }
@ -632,6 +632,13 @@ Battleside = (function(){
var rndCard = null; var rndCard = null;
if(this.deck.getFaction() === Deck.FACTION.MONSTERS){ if(this.deck.getFaction() === Deck.FACTION.MONSTERS){
rndCard = this.getRandomCardOnField(); rndCard = this.getRandomCardOnField();
if(rndCard) {
rndCard.__lock = true;
console.log("Monsters faction ability triggered!");
this.sendNotification(this.getName() + ": Monsters faction ability triggered! " + rndCard.getName());
} else {
this.sendNotification(this.getName() + ": Monsters faction ability triggered! But no card found.");
}
} }
var cards1 = this.field[Card.TYPE.CLOSE_COMBAT].removeAll(); var cards1 = this.field[Card.TYPE.CLOSE_COMBAT].removeAll();
var cards2 = this.field[Card.TYPE.RANGED].removeAll(); var cards2 = this.field[Card.TYPE.RANGED].removeAll();
@ -640,12 +647,6 @@ Battleside = (function(){
var cards = cards1.concat(cards2.concat(cards3.concat(cards4))); var cards = cards1.concat(cards2.concat(cards3.concat(cards4)));
this.addToDiscard(cards); this.addToDiscard(cards);
if(rndCard){
this.removeFromDiscard(rndCard);
this.placeCard(rndCard, {disabled: true}); //disabled == no abilities get triggered
console.log("Monsters faction ability triggered!");
}
} }
r.addToDiscard = function(cards){ r.addToDiscard = function(cards){

View File

@ -1,3 +1,5 @@
var _ = require("underscore");
var Field = (function(){ var Field = (function(){
var Field = function(side, hasHornField){ var Field = function(side, hasHornField){
if(!(this instanceof Field)){ if(!(this instanceof Field)){
@ -86,13 +88,27 @@ var Field = (function(){
r.removeAll = function(){ r.removeAll = function(){
var tmp = this._cards.slice(); var tmp = this._cards.slice();
var self = this; var self = this;
tmp.forEach(function(card){ /*tmp.forEach(function(card){
card.reset(); card.reset();
for(var event in card._uidEvents) { for(var event in card._uidEvents) {
self.side.off(event, card.getUidEvents(event)); self.side.off(event, card.getUidEvents(event));
} }
}) })*/
this._cards = []; for(var i = 0; i < tmp.length; i++) {
var card = tmp[i];
if(card.__lock){
delete card.__lock;
continue;
}
card.reset();
for(var event in card._uidEvents) {
self.side.off(event, card.getUidEvents(event));
}
this._cards[i] = null;
}
this._cards = _.without(this._cards, null);
if(this.getHorn()){ if(this.getHorn()){
var card = this.getHorn(); var card = this.getHorn();
card.reset(); card.reset();