kaysonli/lucky-ball

中奖人和转动的球没有关系?

seven0404 opened this issue · 1 comments

stop: function() { this.running = false; TagCanvas.SetSpeed('myCanvas', this.getSpeed()); var total = this.awards[this.currentAward].count; this.result[this.currentAward] = this.result[this.currentAward] || []; var todo = total - this.result[this.currentAward].length; var N = +localStorage.getItem('batchNumber') || 20; var batchPlayers = []; for (var i = 0, ln = Math.min(N, todo, this.players.length); i < ln; i++) { var index = this.getRandomInt(0, this.players.length - 1); batchPlayers.push(this.players.splice(index, 1)[0]); } this.batchPlayers = batchPlayers; this.result.splice( this.currentAward, 1, this.result[this.currentAward].concat(batchPlayers) ); localStorage.setItem('players', JSON.stringify(this.players)); localStorage.setItem('result', JSON.stringify(this.result)); TagCanvas.Reload('myCanvas'); },

getRandomInt: function(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; },

源码中:这个中奖是随机的,和那个球转动没有什么关系?那个转动的球只是一个装饰么?

stop: function() { this.running = false; TagCanvas.SetSpeed('myCanvas', this.getSpeed()); var total = this.awards[this.currentAward].count; this.result[this.currentAward] = this.result[this.currentAward] || []; var todo = total - this.result[this.currentAward].length; var N = +localStorage.getItem('batchNumber') || 20; var batchPlayers = []; for (var i = 0, ln = Math.min(N, todo, this.players.length); i < ln; i++) { var index = this.getRandomInt(0, this.players.length - 1); batchPlayers.push(this.players.splice(index, 1)[0]); } this.batchPlayers = batchPlayers; this.result.splice( this.currentAward, 1, this.result[this.currentAward].concat(batchPlayers) ); localStorage.setItem('players', JSON.stringify(this.players)); localStorage.setItem('result', JSON.stringify(this.result)); TagCanvas.Reload('myCanvas'); },

getRandomInt: function(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; },

源码中:这个中奖是随机的,和那个球转动没有什么关系?那个转动的球只是一个装饰么?

转动的球上显示了所有参与人员,为了保持神秘感,一直显示所有人,不会把已抽奖的人去掉。