1
0
mirror of https://github.com/exane/not-gwent-online synced 2024-11-23 19:36:53 +00:00
This commit is contained in:
exane 2015-06-24 15:10:54 +02:00
parent fe0aeb33f4
commit cef1c045d7
3 changed files with 22 additions and 34 deletions

View File

@ -72,20 +72,11 @@ var Battle = (function(){
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){

View File

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