mirror of
https://github.com/exane/not-gwent-online
synced 2024-11-23 19:36:53 +00:00
tidy up
This commit is contained in:
parent
fe0aeb33f4
commit
cef1c045d7
@ -380,7 +380,7 @@ var BattleView = Backbone.View.extend({
|
|||||||
calculateCardMargin(this.$el.find(".field-hand .card"), 538, 70, this.handCards.length);
|
calculateCardMargin(this.$el.find(".field-hand .card"), 538, 70, this.handCards.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.user.get("isReDrawing")) {
|
if(this.user.get("isReDrawing")){
|
||||||
this.user.set("handCards", this.handCards);
|
this.user.set("handCards", this.handCards);
|
||||||
var modal = new ReDrawModal({model: this.user});
|
var modal = new ReDrawModal({model: this.user});
|
||||||
this.$el.prepend(modal.render().el);
|
this.$el.prepend(modal.render().el);
|
||||||
@ -584,11 +584,11 @@ var User = Backbone.Model.extend({
|
|||||||
self.set("setHorn", data.cardID);
|
self.set("setHorn", data.cardID);
|
||||||
})
|
})
|
||||||
|
|
||||||
app.receive("redraw:cards", function() {
|
app.receive("redraw:cards", function(){
|
||||||
self.set("isReDrawing", true);
|
self.set("isReDrawing", true);
|
||||||
})
|
})
|
||||||
|
|
||||||
app.receive("redraw:close", function() {
|
app.receive("redraw:close", function(){
|
||||||
self.set("isReDrawing", false);
|
self.set("isReDrawing", false);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -67,25 +67,16 @@ var Battle = (function(){
|
|||||||
|
|
||||||
|
|
||||||
Promise.when(this.p1.reDraw(2), this.p2.reDraw(2))
|
Promise.when(this.p1.reDraw(2), this.p2.reDraw(2))
|
||||||
.then(function() {
|
.then(function(){
|
||||||
this.on("NextTurn", this.switchTurn);
|
this.on("NextTurn", this.switchTurn);
|
||||||
this.switchTurn(Math.random() > .5 ? this.p1 : this.p2);
|
this.switchTurn(Math.random() > .5 ? this.p1 : this.p2);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
this.on("NextTurn", this.switchTurn);
|
|
||||||
|
|
||||||
this.switchTurn(Math.random() > .5 ? this.p1 : this.p2);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r.switchTurn = function(side, __flag){
|
r.switchTurn = function(side, __flag){
|
||||||
__flag = typeof __flag == "undefined" ? 0 : 1;
|
__flag = typeof __flag == "undefined" ? 0 : 1;
|
||||||
|
|
||||||
/*side.foe.wait();*/
|
|
||||||
|
|
||||||
|
|
||||||
if(!(side instanceof Battleside)){
|
if(!(side instanceof Battleside)){
|
||||||
console.trace("side is not a battleside!");
|
console.trace("side is not a battleside!");
|
||||||
@ -98,13 +89,12 @@ var Battle = (function(){
|
|||||||
return this.switchTurn(side.foe, 1);
|
return this.switchTurn(side.foe, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.runEvent("EachTurn");
|
this.runEvent("EachTurn");
|
||||||
|
|
||||||
//setTimeout(function() {
|
|
||||||
this.runEvent("Turn" + side.getID());
|
this.runEvent("Turn" + side.getID());
|
||||||
//}.bind(this), 1000);
|
|
||||||
console.log("current Turn: ", side.getName());
|
|
||||||
|
|
||||||
|
console.log("current Turn: ", side.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
r.startNextRound = function(){
|
r.startNextRound = function(){
|
||||||
@ -175,7 +165,7 @@ var Battle = (function(){
|
|||||||
obj.cb.apply(ctx, obj.onArgs.concat(args));
|
obj.cb.apply(ctx, obj.onArgs.concat(args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.update();
|
//this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
r.on = function(eventid, cb, ctx, args){
|
r.on = function(eventid, cb, ctx, args){
|
||||||
|
@ -78,7 +78,7 @@ Battleside = (function(){
|
|||||||
})
|
})
|
||||||
this.receive("set:passing", function(){
|
this.receive("set:passing", function(){
|
||||||
self.setPassing(true);
|
self.setPassing(true);
|
||||||
self.update();
|
//self.update();
|
||||||
self.runEvent("NextTurn", null, [self.foe]);
|
self.runEvent("NextTurn", null, [self.foe]);
|
||||||
})
|
})
|
||||||
this.receive("medic:chooseCardFromDiscard", function(data){
|
this.receive("medic:chooseCardFromDiscard", function(data){
|
||||||
@ -210,10 +210,6 @@ Battleside = (function(){
|
|||||||
var card = this.deck.draw();
|
var card = this.deck.draw();
|
||||||
this.hand.add(card);
|
this.hand.add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("update:hand fired");
|
|
||||||
|
|
||||||
/*this.update();*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r.calcScore = function(){
|
r.calcScore = function(){
|
||||||
@ -266,9 +262,9 @@ Battleside = (function(){
|
|||||||
this.socket.on(event, cb);
|
this.socket.on(event, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
r.update = function(){
|
r.update = function(self){
|
||||||
//PubSub.publish("update");
|
self = self || false;
|
||||||
this.runEvent("Update");
|
this.runEvent("Update", null, [self]);
|
||||||
}
|
}
|
||||||
|
|
||||||
r.onTurnStart = function(){
|
r.onTurnStart = function(){
|
||||||
@ -325,7 +321,6 @@ Battleside = (function(){
|
|||||||
|
|
||||||
this.checkAbilityOnAfterPlace(card, obj);
|
this.checkAbilityOnAfterPlace(card, obj);
|
||||||
|
|
||||||
this.update();
|
|
||||||
|
|
||||||
if(obj._waitResponse){
|
if(obj._waitResponse){
|
||||||
this.hand.remove(card);
|
this.hand.remove(card);
|
||||||
@ -333,6 +328,8 @@ Battleside = (function(){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.update();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +406,7 @@ Battleside = (function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(ability && ability.name === obj.suppress){
|
if(ability && ability.name === obj.suppress){
|
||||||
this.update();
|
//this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ability && !Array.isArray(ability)){
|
if(ability && !Array.isArray(ability)){
|
||||||
@ -454,7 +451,6 @@ Battleside = (function(){
|
|||||||
|
|
||||||
self.hand.add(replaceCard);
|
self.hand.add(replaceCard);
|
||||||
self.hand.remove(card);
|
self.hand.remove(card);
|
||||||
self.update();
|
|
||||||
|
|
||||||
self.runEvent("NextTurn", null, [self.foe]);
|
self.runEvent("NextTurn", null, [self.foe]);
|
||||||
})
|
})
|
||||||
@ -472,7 +468,7 @@ Battleside = (function(){
|
|||||||
card._uidEvents["WeatherChange"] = uid;
|
card._uidEvents["WeatherChange"] = uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update();
|
//this.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +476,7 @@ Battleside = (function(){
|
|||||||
var ability = card.getAbility();
|
var ability = card.getAbility();
|
||||||
if(ability){
|
if(ability){
|
||||||
if(ability.name && ability.name === obj.suppress){
|
if(ability.name && ability.name === obj.suppress){
|
||||||
this.update();
|
//this.update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(ability.onAfterPlace){
|
if(ability.onAfterPlace){
|
||||||
@ -529,7 +525,7 @@ Battleside = (function(){
|
|||||||
_card.setForcedPower(forcedPower);
|
_card.setForcedPower(forcedPower);
|
||||||
});
|
});
|
||||||
this.runEvent("WeatherChange");
|
this.runEvent("WeatherChange");
|
||||||
this.update();
|
//this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
r.clearMainFields = function(){
|
r.clearMainFields = function(){
|
||||||
@ -624,7 +620,7 @@ Battleside = (function(){
|
|||||||
|
|
||||||
this.send("redraw:cards", null, true);
|
this.send("redraw:cards", null, true);
|
||||||
|
|
||||||
this.receive("redraw:reDrawCard", function(data){
|
var h1 = this.receive("redraw:reDrawCard", function(data){
|
||||||
var id = data.cardID;
|
var id = data.cardID;
|
||||||
if(!left) return;
|
if(!left) return;
|
||||||
left--;
|
left--;
|
||||||
@ -633,17 +629,19 @@ Battleside = (function(){
|
|||||||
self.deck.add(card);
|
self.deck.add(card);
|
||||||
self.deck.shuffle();
|
self.deck.shuffle();
|
||||||
self.draw(1);
|
self.draw(1);
|
||||||
self.update();
|
|
||||||
if(!left) {
|
if(!left) {
|
||||||
self.send("redraw:close", null, true);
|
self.send("redraw:close", null, true);
|
||||||
console.log("redraw finished");
|
console.log("redraw finished");
|
||||||
deferred.resolve("done");
|
deferred.resolve("done");
|
||||||
|
self.socket.off("redraw:reDrawCard", h1);
|
||||||
}
|
}
|
||||||
|
self.update(self);
|
||||||
})
|
})
|
||||||
|
|
||||||
this.receive("redraw:close_client", function() {
|
var h2 = this.receive("redraw:close_client", function() {
|
||||||
console.log("redraw finished!");
|
console.log("redraw finished!");
|
||||||
deferred.resolve("done");
|
deferred.resolve("done");
|
||||||
|
self.socket.off("redraw:close_client", h2);
|
||||||
})
|
})
|
||||||
|
|
||||||
return deferred;
|
return deferred;
|
||||||
|
Loading…
Reference in New Issue
Block a user