Page 453 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 453

Game.prototype.shuffleCups  =  function(bet)  {
                         console.log(setlevel);
                            var _this =  this;

                            var times  = Math.floor(setlevel  *  2);
                            var speed =  Math.floor(20  -  setlevel * 0.7);
                            if  (speed < 2)  {
                                 speed  = 2;
                            }
                                    var  timeout  =  Math.floor(1000  -  setlevel  *  50);
                            if  (timeout < 0)  {
                                 timeout  = 0;
                            }
                            console.log("times:  "  +  times  +  "\nspeed:  "  +  speed +  "\ntimeout: " +  timeout);
                            this.bet  =  bet;
                            this.updateBank(false);
                            this.putBackCups(function()  {
                                 _this.shuffleThem(times,  speed, timeout,  _this, 0,  function()  {

                                       _this.showSelectCupMenu();
                                 });
                            });
                       };


                       Game.prototype.shuffleThem  =  function(times,  speed,  timeout,  self,  progress,  callBack)  {
                            if  (progress  <  times)  {
                                 var random =  Math.floor((Math.random() * 3));
                                 var otherRandom =  random;
                                 while  (otherRandom ==  random)  {
                                       otherRandom  =  Math.floor((Math.random()  * 3));
                                 }
                                 self.cupCollection[random].swapCups(speed,  self.cupCollection[otherRandom],
            function()  {
                                       setTimeout(self.shuffleThem, timeout,  times,  speed,  timeout,  self,  progress  +
            1,  callBack);
                                 });

                            }  else  {
                                 callBack();
                            }
                       };


                       Game.prototype.showSelectCupMenu =  function()  {



                                                         -  446  -
   448   449   450   451   452   453   454   455   456   457   458