mirror of
https://github.com/exane/not-gwent-online
synced 2025-09-02 14:07:31 +00:00
add card redraw at battle begin
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
var Battleside = require("./Battleside");
|
||||
var Card = require("./Card");
|
||||
var shortid = require("shortid");
|
||||
var Promise = require("jquery-deferred");
|
||||
|
||||
|
||||
var Battle = (function(){
|
||||
@@ -61,72 +62,23 @@ var Battle = (function(){
|
||||
this.p2.setLeadercard();
|
||||
this.p1.draw(10);
|
||||
this.p2.draw(10);
|
||||
/*this.p1.hand.add(Card("commanders_horn"));
|
||||
this.p2.hand.add(Card("commanders_horn"));*/
|
||||
/*
|
||||
this.p1.hand.add(Card("ciaran_aep_easnillien"));
|
||||
this.p2.hand.add(Card("ciaran_aep_easnillien"));*/
|
||||
/*
|
||||
*/
|
||||
/*this.p1.hand.add(Card("decoy"));
|
||||
this.p2.hand.add(Card("decoy"));*/
|
||||
/*
|
||||
this.p1.hand.add(Card("milva"));
|
||||
this.p2.hand.add(Card("milva"));
|
||||
this.p1.hand.add(Card("havekar_healer"));
|
||||
this.p2.hand.add(Card("havekar_healer"));
|
||||
this.p1.hand.add(Card("toruviel"));
|
||||
this.p2.hand.add(Card("toruviel"));
|
||||
this.p1.hand.add(Card("vrihedd_brigade_recruit"));
|
||||
this.p2.hand.add(Card("vrihedd_brigade_recruit"));
|
||||
this.p1.hand.add(Card("impenetrable_fog"));
|
||||
this.p2.hand.add(Card("impenetrable_fog"));*/
|
||||
/*
|
||||
this.p1.hand.add(Card("commanders_horn"));
|
||||
this.p1.hand.add(Card("commanders_horn"));
|
||||
this.p2.hand.add(Card("commanders_horn"));*/
|
||||
/*
|
||||
this.p1.hand.add(Card("biting_frost"));
|
||||
this.p2.hand.add(Card("biting_frost"));
|
||||
this.p1.hand.add(Card("torrential_rain"));
|
||||
this.p2.hand.add(Card("torrential_rain"));
|
||||
this.p1.hand.add(Card("clear_weather"));
|
||||
this.p2.hand.add(Card("clear_weather"));*/
|
||||
/*
|
||||
this.p1.hand.add(Card("kaedweni_siege_expert"));
|
||||
this.p2.hand.add(Card("kaedweni_siege_expert"));
|
||||
this.p1.hand.add(Card("ballista"));
|
||||
this.p2.hand.add(Card("ballista"));
|
||||
this.p1.hand.add(Card("ballista"));
|
||||
this.p2.hand.add(Card("ballista"));
|
||||
this.p1.hand.add(Card("ballista"));
|
||||
this.p2.hand.add(Card("ballista"));
|
||||
this.p1.hand.add(Card("ballista"));
|
||||
this.p2.hand.add(Card("ballista"));
|
||||
this.p1.hand.add(Card("ballista"));
|
||||
this.p2.hand.add(Card("ballista"));*/
|
||||
|
||||
/*
|
||||
this.p1.hand.add(Card("dun_banner_medic"));
|
||||
this.p2.hand.add(Card("dun_banner_medic"));
|
||||
this.p1.hand.add(Card("isengrim_faoiltiarnah"));
|
||||
this.p2.hand.add(Card("isengrim_faoiltiarnah"));*/
|
||||
|
||||
/*this.p1.addToDiscard([Card("kaedweni_siege_expert")]);
|
||||
this.p2.addToDiscard([Card("kaedweni_siege_expert")]);*/
|
||||
/*
|
||||
this.p1.hand.add(Card("decoy"));
|
||||
this.p1.hand.add(Card("impenetrable_fog"));
|
||||
this.p2.hand.add(Card("decoy"));
|
||||
this.p2.hand.add(Card("impenetrable_fog"));*/
|
||||
|
||||
this.update();
|
||||
|
||||
|
||||
/*PubSub.subscribe("nextTurn", this.switchTurn.bind(this));*/
|
||||
Promise.when(this.p1.reDraw(2), this.p2.reDraw(2))
|
||||
.then(function() {
|
||||
this.on("NextTurn", this.switchTurn);
|
||||
this.switchTurn(Math.random() > .5 ? this.p1 : this.p2);
|
||||
}.bind(this));
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
this.on("NextTurn", this.switchTurn);
|
||||
|
||||
this.switchTurn(Math.random() > .5 ? this.p1 : this.p2);
|
||||
this.switchTurn(Math.random() > .5 ? this.p1 : this.p2);*/
|
||||
}
|
||||
|
||||
r.switchTurn = function(side, __flag){
|
||||
@@ -173,6 +125,7 @@ var Battle = (function(){
|
||||
}
|
||||
|
||||
r.update = function(){
|
||||
console.log("update called");
|
||||
this._update(this.p1);
|
||||
this._update(this.p2);
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ var Hand = require("./Hand");
|
||||
var Card = require("./Card");
|
||||
var Field = require("./Field");
|
||||
var _ = require("underscore");
|
||||
var Promise = require("jquery-deferred");
|
||||
|
||||
|
||||
var Battleside;
|
||||
@@ -143,7 +144,7 @@ Battleside = (function(){
|
||||
return this._passing;
|
||||
}
|
||||
|
||||
r.isWaiting = function() {
|
||||
r.isWaiting = function(){
|
||||
return this._isWaiting;
|
||||
}
|
||||
|
||||
@@ -212,7 +213,7 @@ Battleside = (function(){
|
||||
|
||||
console.log("update:hand fired");
|
||||
|
||||
this.update();
|
||||
/*this.update();*/
|
||||
}
|
||||
|
||||
r.calcScore = function(){
|
||||
@@ -593,7 +594,7 @@ Battleside = (function(){
|
||||
res.push(card);
|
||||
}
|
||||
}
|
||||
else if(_.isArray(val)) {
|
||||
else if(_.isArray(val)){
|
||||
var _f = false;
|
||||
for(var i = 0; i < val.length; i++) {
|
||||
if(property === val[i]){
|
||||
@@ -615,6 +616,40 @@ Battleside = (function(){
|
||||
return arr;
|
||||
}
|
||||
|
||||
r.reDraw = function(n){
|
||||
var hand = this.hand.getCards();
|
||||
var self = this;
|
||||
var left = n;
|
||||
var deferred = Promise.Deferred();
|
||||
|
||||
this.send("redraw:cards", null, true);
|
||||
|
||||
this.receive("redraw:reDrawCard", function(data){
|
||||
var id = data.cardID;
|
||||
if(!left) return;
|
||||
left--;
|
||||
var card = self.hand.remove(id)[0];
|
||||
console.log("hand -> deck: ", card.getName());
|
||||
self.deck.add(card);
|
||||
self.deck.shuffle();
|
||||
self.draw(1);
|
||||
self.update();
|
||||
if(!left) {
|
||||
self.send("redraw:close", null, true);
|
||||
console.log("redraw finished");
|
||||
deferred.resolve("done");
|
||||
}
|
||||
})
|
||||
|
||||
this.receive("redraw:close_client", function() {
|
||||
console.log("redraw finished!");
|
||||
deferred.resolve("done");
|
||||
})
|
||||
|
||||
return deferred;
|
||||
|
||||
}
|
||||
|
||||
return Battleside;
|
||||
})();
|
||||
|
||||
|
@@ -50,7 +50,6 @@ var Deck = (function(){
|
||||
return card;
|
||||
}
|
||||
|
||||
|
||||
r._loadCards = function(){
|
||||
this._deck = this.getDeck().map(function(cardkey){
|
||||
return Card(cardkey);
|
||||
@@ -100,6 +99,10 @@ var Deck = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
r.add = function(card) {
|
||||
this._deck.push(card);
|
||||
}
|
||||
|
||||
return Deck;
|
||||
})();
|
||||
|
||||
|
Reference in New Issue
Block a user