| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * @property integer $uid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @property integer $dollarImprovement | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @property integer $skillImprovement | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 6 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 7 |  |  | class Advancement extends CModel | 
            
                                                                        
                            
            
                                    
            
            
                | 8 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 9 |  |  |     private $uid; | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     public function attributeNames() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |         return []; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 14 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     // getters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     public function getUid() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         return (int)$this->uid; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 20 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     public function getDollarImprovement() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         return 30 + (5 * Yii::app()->player->model->level); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 25 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     public function getSkillImprovement() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $di = $this->getDollarImprovement(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         //strongest bait | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $bait = Yii::app()->db->createCommand() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             ->select('id, skill, price') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |             ->from('baits') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             ->where('level<=:level', [':level'=>(int)Yii::app()->player->model->level]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             ->order('level DESC') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             ->limit(1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             ->queryRow(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $skill = round($di / $bait['price'] * $bait['skill'] / 2 * 0.8); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         return (int)$skill; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 41 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     public function setUid($uid) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $this->uid = (int)$uid; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 46 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     public function incrementForStatuspoint($id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         $player = Yii::app()->player->model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         if (!$player->itsMe()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         if ($player->status_points < 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $mapIdAttribute = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             1=>['energy_max'=>1, 'energy'=>1], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             ['skill'=>2, 'skill_extended'=>2], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             ['strength'=>2], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             ['dollar'=>$this->getDollarImprovement()] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $mapIdAttribute[2]['skill'] = $mapIdAttribute[2]['skill_extended'] = $this->getSkillImprovement(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $increment = isset($mapIdAttribute[$id]) ? $mapIdAttribute[$id] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         if ($increment) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             $player->updateAttributes($increment, ['status_points'=>1]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             //badge | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             $b = new ProfileBadgeActivator(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             $b->uid = $this->uid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             if ($id==1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                 $b->triggerMaxNrg($player->energy_max); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             if ($id==2) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                 $b->triggerSkill($player->skill); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             if ($id==3) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                 $b->triggerStrength($player->strength); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         return true; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 85 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 86 |  |  | } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 87 |  |  |  | 
            
                        
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.