mirror of
https://github.com/exane/not-gwent-online
synced 2024-11-23 19:36:53 +00:00
fix monster ability bug
This commit is contained in:
parent
2de34251b5
commit
3e5c660d6d
@ -263,18 +263,6 @@ let SideView = Backbone.View.extend({
|
|||||||
}*/
|
}*/
|
||||||
});
|
});
|
||||||
|
|
||||||
let calculateCardMargin = function($selector, totalWidth, cardWidth, n){
|
|
||||||
let w = totalWidth, c = cardWidth;
|
|
||||||
let res;
|
|
||||||
if(n < 6)
|
|
||||||
res = 0;
|
|
||||||
else {
|
|
||||||
res = -((w - c) / (n - 1) - c) + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
$selector.css("margin-left", -res);
|
|
||||||
}
|
|
||||||
|
|
||||||
let BattleView = Backbone.View.extend({
|
let BattleView = Backbone.View.extend({
|
||||||
el: ".gwent-battle",
|
el: ".gwent-battle",
|
||||||
template: require("../templates/battle.handlebars"),
|
template: require("../templates/battle.handlebars"),
|
||||||
@ -706,7 +694,7 @@ let ChooseSideModal = Modal.extend({
|
|||||||
let User = Backbone.Model.extend({
|
let User = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
name: localStorage["userName"] || null,
|
name: localStorage["userName"] || null,
|
||||||
deck: localStorage["userDeck"] || null,
|
deck: localStorage["userDeck"] || "random",
|
||||||
serverOffline: true
|
serverOffline: true
|
||||||
},
|
},
|
||||||
initialize: function(){
|
initialize: function(){
|
||||||
@ -863,6 +851,7 @@ let Lobby = Backbone.View.extend({
|
|||||||
this.app.receive("update:playerOnline", this.renderStatus.bind(this));
|
this.app.receive("update:playerOnline", this.renderStatus.bind(this));
|
||||||
|
|
||||||
this.listenTo(this.app.user, "change:serverOffline", this.render);
|
this.listenTo(this.app.user, "change:serverOffline", this.render);
|
||||||
|
this.listenTo(this.app.user, "change:name", this.setName);
|
||||||
$(".gwent-battle").html(this.el);
|
$(".gwent-battle").html(this.el);
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
@ -893,6 +882,14 @@ let Lobby = Backbone.View.extend({
|
|||||||
this.app.trigger("setDeck", val);
|
this.app.trigger("setDeck", val);
|
||||||
this.$el.find("#deckChoice option[value='" + val + "']").attr("selected", "selected")
|
this.$el.find("#deckChoice option[value='" + val + "']").attr("selected", "selected")
|
||||||
},
|
},
|
||||||
|
setName: function(){
|
||||||
|
/*let val = $(e.target).val();
|
||||||
|
this.app.trigger("setDeck", val);
|
||||||
|
this.$el.find("#deckChoice option[value='" + val + "']").attr("selected", "selected")*/
|
||||||
|
localStorage["userName"] = this.app.user.get("name");
|
||||||
|
/*this.render();*/
|
||||||
|
this.$el.find(".name-input").val(this.app.user.get("name"));
|
||||||
|
},
|
||||||
changeName: function(e){
|
changeName: function(e){
|
||||||
let name = $(e.target).val();
|
let name = $(e.target).val();
|
||||||
this.app.trigger("setName", name);
|
this.app.trigger("setName", name);
|
||||||
|
@ -58,7 +58,7 @@ Battleside = (function(){
|
|||||||
leaderCard.setDisabled(true);
|
leaderCard.setDisabled(true);
|
||||||
self.battle.sendNotification(self.getName() + " activated " + leaderCard.getName() + "! (leadercard)");
|
self.battle.sendNotification(self.getName() + " activated " + leaderCard.getName() + "! (leadercard)");
|
||||||
self.update();
|
self.update();
|
||||||
if(ability.waitResponse) {
|
if(ability.waitResponse){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//self.runEvent("NextTurn", null, [self.foe]);
|
//self.runEvent("NextTurn", null, [self.foe]);
|
||||||
@ -219,7 +219,7 @@ Battleside = (function(){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.getFieldCards = function() {
|
r.getFieldCards = function(){
|
||||||
var close, range, siege;
|
var close, range, siege;
|
||||||
|
|
||||||
close = this.field[Card.TYPE.CLOSE_COMBAT].get();
|
close = this.field[Card.TYPE.CLOSE_COMBAT].get();
|
||||||
@ -348,7 +348,7 @@ Battleside = (function(){
|
|||||||
this.endTurn();
|
this.endTurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
r.endTurn = function() {
|
r.endTurn = function(){
|
||||||
this.update();
|
this.update();
|
||||||
|
|
||||||
this.runEvent("NextTurn", null, [this.foe]);
|
this.runEvent("NextTurn", null, [this.foe]);
|
||||||
@ -473,22 +473,24 @@ Battleside = (function(){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
r.setTightBond = function(card) {
|
r.setTightBond = function(card){
|
||||||
var field = this.field[card.getType()];
|
var field = this.field[card.getType()];
|
||||||
var pos = field.getPosition(card);
|
var pos = field.getPosition(card);
|
||||||
var cards = field.get();
|
var cards = field.get();
|
||||||
|
|
||||||
if(pos < 0) return;
|
if(pos < 0) return;
|
||||||
if(pos >= 1 && cards[pos-1].getName() === cards[pos].getName()) {
|
if(pos >= 1 && cards[pos - 1].getName() === cards[pos].getName()){
|
||||||
cards[pos].setBoost(cards[pos].getID()+"|left", "tight_bond");
|
cards[pos].setBoost(cards[pos].getID() + "|left", "tight_bond");
|
||||||
} else {
|
}
|
||||||
cards[pos].setBoost(cards[pos].getID()+"|left", 0);
|
else {
|
||||||
|
cards[pos].setBoost(cards[pos].getID() + "|left", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pos < cards.length-1 && cards[pos+1].getName() === cards[pos].getName()) {
|
if(pos < cards.length - 1 && cards[pos + 1].getName() === cards[pos].getName()){
|
||||||
cards[pos].setBoost(cards[pos].getID()+"|right", "tight_bond");
|
cards[pos].setBoost(cards[pos].getID() + "|right", "tight_bond");
|
||||||
} else {
|
}
|
||||||
cards[pos].setBoost(cards[pos].getID()+"|right", 0);
|
else {
|
||||||
|
cards[pos].setBoost(cards[pos].getID() + "|right", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,13 +668,13 @@ Battleside = (function(){
|
|||||||
this.runEvent("WeatherChange");
|
this.runEvent("WeatherChange");
|
||||||
}
|
}
|
||||||
|
|
||||||
r.scorchMelee = function(card) {
|
r.scorchMelee = function(card){
|
||||||
var side = this.foe;
|
var side = this.foe;
|
||||||
var field = side.field[Card.TYPE.CLOSE_COMBAT];
|
var field = side.field[Card.TYPE.CLOSE_COMBAT];
|
||||||
|
|
||||||
this.battle.sendNotification(this.getName() + " played " + card.getName());
|
this.battle.sendNotification(this.getName() + " played " + card.getName());
|
||||||
|
|
||||||
if(field.getScore() < 10) {
|
if(field.getScore() < 10){
|
||||||
this.battle.sendNotification("Scorch: Score is under 10! Nothing happens.");
|
this.battle.sendNotification("Scorch: Score is under 10! Nothing happens.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -682,7 +684,7 @@ Battleside = (function(){
|
|||||||
|
|
||||||
|
|
||||||
var txt = "Scorch destroyed:";
|
var txt = "Scorch destroyed:";
|
||||||
for (var i = 0; i < removeCards.length; i++) {
|
for(var i = 0; i < removeCards.length; i++) {
|
||||||
var c = removeCards[i];
|
var c = removeCards[i];
|
||||||
txt += "\n" + c.getName();
|
txt += "\n" + c.getName();
|
||||||
}
|
}
|
||||||
@ -716,9 +718,9 @@ Battleside = (function(){
|
|||||||
if(card.getPower() === highest) res.push(card);
|
if(card.getPower() === highest) res.push(card);
|
||||||
});
|
});
|
||||||
|
|
||||||
res.forEach(function(card) {
|
res.forEach(function(card){
|
||||||
var side = self;
|
var side = self;
|
||||||
if(self.foe.field[card.getType()].isOnField(card)) {
|
if(self.foe.field[card.getType()].isOnField(card)){
|
||||||
side = self.foe;
|
side = self.foe;
|
||||||
}
|
}
|
||||||
var removed = side.field[card.getType()].removeCard(card);
|
var removed = side.field[card.getType()].removeCard(card);
|
||||||
@ -726,7 +728,7 @@ Battleside = (function(){
|
|||||||
})
|
})
|
||||||
|
|
||||||
var txt = "Scorch destroyed:";
|
var txt = "Scorch destroyed:";
|
||||||
for (var i = 0; i < res.length; i++) {
|
for(var i = 0; i < res.length; i++) {
|
||||||
var c = res[i];
|
var c = res[i];
|
||||||
txt += "\n" + c.getName();
|
txt += "\n" + c.getName();
|
||||||
}
|
}
|
||||||
@ -738,12 +740,11 @@ 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) {
|
if(rndCard){
|
||||||
rndCard.__lock = true;
|
rndCard.__lock = true;
|
||||||
//console.log("Monsters faction ability triggered!");
|
|
||||||
|
|
||||||
this.sendNotification(this.getName() + ": Monsters faction ability triggered! " + rndCard.getName());
|
this.sendNotification(this.getName() + ": Monsters faction ability triggered! " + rndCard.getName());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
this.sendNotification(this.getName() + ": Monsters faction ability triggered! But no card found.");
|
this.sendNotification(this.getName() + ": Monsters faction ability triggered! But no card found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -762,6 +763,10 @@ Battleside = (function(){
|
|||||||
cards = [cards];
|
cards = [cards];
|
||||||
}
|
}
|
||||||
cards.forEach(function(_card){
|
cards.forEach(function(_card){
|
||||||
|
if(_card.__lock){
|
||||||
|
delete _card.__lock;
|
||||||
|
return;
|
||||||
|
}
|
||||||
self._discard.push(_card);
|
self._discard.push(_card);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -837,7 +842,7 @@ Battleside = (function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.reDraw = function(n){
|
r.reDraw = function(n){
|
||||||
var hand = this.hand.getCards();
|
//var hand = this.hand.getCards();
|
||||||
var self = this;
|
var self = this;
|
||||||
var left = n;
|
var left = n;
|
||||||
var deferred = Promise.Deferred();
|
var deferred = Promise.Deferred();
|
||||||
@ -875,7 +880,7 @@ Battleside = (function(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r.sendNotification = function(msg) {
|
r.sendNotification = function(msg){
|
||||||
this.battle.sendNotification(msg);
|
this.battle.sendNotification(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ var Field = (function(){
|
|||||||
for(var i = 0; i < tmp.length; i++) {
|
for(var i = 0; i < tmp.length; i++) {
|
||||||
var card = tmp[i];
|
var card = tmp[i];
|
||||||
if(card.__lock){
|
if(card.__lock){
|
||||||
delete card.__lock;
|
//delete card.__lock;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
card.reset();
|
card.reset();
|
||||||
|
Loading…
Reference in New Issue
Block a user