我有一个小纸牌游戏,我有一个经销商向玩家分发卡片。我的game.js
中的这段代码使Meteor崩溃并导致RangeError: Maximum call stack size exceeded
Dealer = {
deal: function(players, deck) {
for(var j=0; j < players.length; j++) {
var p = players[j];
for(var i=0; i < 3; i++) {
//assign card to player
var card = deck.shift();
card.owner = p;
p.cards.push(card);
}
}
}
};
在/server/main.js
我有一些设置新游戏的代码
var table = new Table();
var deck = new Deck();
deck.deck = deck.shuffle();
var trump = deck.deck[_.random(0, 39)];
trump.is_trump = true;
var human = new Player('Human', false);
var computer = new Player('Computer', true);
var players = [human, computer];
console.log('Players: ', players);
//this last line is the one that calls the Dealer above
Dealer.deal(players, deck.deck);
我该如何调试此错误? card.owner = p
行
我是否应该考虑以不同的方式编写此代码?