Beispiel #1
0
 public function calcRoundOutcome($slam_time)
 {
     //determine round_bias from given slam time
     if ($slam_time == 0) {
         $round_bias = 0;
     } else {
         if ($slam_time > 1 && $slam_time <= 200) {
             $round_bias = 1;
         } else {
             if ($slam_time > 200 && $slam_time <= 300) {
                 $round_bias = 0.9;
             } else {
                 if ($slam_time > 300 && $slam_time <= 600) {
                     $round_bias = 0.8;
                 } else {
                     if ($slam_time > 600 && $slam_time <= 700) {
                         $round_bias = 0.7;
                     } else {
                         if ($slam_time > 700 && $slam_time <= 900) {
                             $round_bias = 0.6;
                         } else {
                             if ($slam_time > 900 && $slam_time <= 1200) {
                                 $round_bias = 0.5;
                             } else {
                                 if ($slam_time > 1200 && $slam_time <= 1600) {
                                     $round_bias = 0.4;
                                 } else {
                                     if ($slam_time > 1600 && $slam_time <= 2100) {
                                         $round_bias = 0.3;
                                     } else {
                                         if ($slam_time > 2100 && $slam_time <= 4000) {
                                             $round_bias = 0.2;
                                         } else {
                                             $round_bias = 0.1;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //get count of available mogs for this match
     $available_mog_count = PlayField::getActiveMogs($this->id);
     $available_mog_count = count((array) $available_mog_count);
     //get number to be flipped
     $flip_count = 40 * $round_bias;
     //make sure number to be flipped doesn't exceed available
     if ($flip_count > $available_mog_count) {
         $flip_count = $available_mog_count;
     }
     //Flip the mogs
     PlayField::flipMogs($this->id, $this->active_player_id, $flip_count);
     //update count of mogs for player
     if ($this->active_player_id == $this->p1_id) {
         $this->p1_mog_count += $flip_count;
     } else {
         $this->p2_mog_count += $flip_count;
     }
     $this->save();
 }