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:
parent
b5d28bcc08
commit
7f0d7f9db8
@ -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){
|
||||||
|
@ -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)){
|
||||||
@ -29,7 +31,7 @@ var Field = (function(){
|
|||||||
this.setHorn(card);
|
this.setHorn(card);
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
if(isHorn && this._hasHornField) {
|
if(isHorn && this._hasHornField){
|
||||||
this.setHorn(card);
|
this.setHorn(card);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -86,14 +88,28 @@ 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++) {
|
||||||
if(this.getHorn()) {
|
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()){
|
||||||
var card = this.getHorn();
|
var card = this.getHorn();
|
||||||
card.reset();
|
card.reset();
|
||||||
this.setHorn(null);
|
this.setHorn(null);
|
||||||
@ -105,21 +121,21 @@ var Field = (function(){
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.removeCard = function(cards) {
|
r.removeCard = function(cards){
|
||||||
var res = [];
|
var res = [];
|
||||||
var _cards = this.get();
|
var _cards = this.get();
|
||||||
if(!Array.isArray(cards)) {
|
if(!Array.isArray(cards)){
|
||||||
cards = [cards];
|
cards = [cards];
|
||||||
}
|
}
|
||||||
var self = this;
|
var self = this;
|
||||||
cards.forEach(function(card) {
|
cards.forEach(function(card){
|
||||||
res.push(_cards.splice(self.getPosition(card), 1)[0]);
|
res.push(_cards.splice(self.getPosition(card), 1)[0]);
|
||||||
})
|
})
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.getInfo = function() {
|
r.getInfo = function(){
|
||||||
var self = this;
|
var self = this;
|
||||||
return {
|
return {
|
||||||
cards: self._cards,
|
cards: self._cards,
|
||||||
@ -128,27 +144,27 @@ var Field = (function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r.getHorn = function() {
|
r.getHorn = function(){
|
||||||
if(!this._hasHornField) return null;
|
if(!this._hasHornField) return null;
|
||||||
return this._hornCard;
|
return this._hornCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.setHorn = function(card) {
|
r.setHorn = function(card){
|
||||||
if(!this._hasHornField) return null;
|
if(!this._hasHornField) return null;
|
||||||
this._hornCard = card;
|
this._hornCard = card;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.getHighestCards = function(noHeroes) {
|
r.getHighestCards = function(noHeroes){
|
||||||
noHeroes = noHeroes || false;
|
noHeroes = noHeroes || false;
|
||||||
var res = [];
|
var res = [];
|
||||||
var highest = 0;
|
var highest = 0;
|
||||||
|
|
||||||
this.get().forEach(function(card) {
|
this.get().forEach(function(card){
|
||||||
if(noHeroes && card.hasAbility("hero")) return;
|
if(noHeroes && card.hasAbility("hero")) return;
|
||||||
highest = card.getPower() > highest ? card.getPower() : highest;
|
highest = card.getPower() > highest ? card.getPower() : highest;
|
||||||
})
|
})
|
||||||
|
|
||||||
this.get().forEach(function(card) {
|
this.get().forEach(function(card){
|
||||||
if(noHeroes && card.hasAbility("hero")) return;
|
if(noHeroes && card.hasAbility("hero")) return;
|
||||||
if(card.getPower() === highest) res.push(card);
|
if(card.getPower() === highest) res.push(card);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user