| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * @property integer $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @property array $missions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @property array $missionTypes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @property string $name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @property string $county | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @property integer $routine | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @property array $routineStars | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @property string $routineImages | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @property array $navigationLinks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | class Location extends CModel | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     private $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     private $routine; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     private $skill_extended_at_visit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     private $county = ['', 'Baranya', 'Bács-Kiskun', 'Jász-Nagykun-Szolnok', 'Csongrád', 'Békés', 'Hajdú-Bihar', 'Szabolcs-Szatmár-Bereg', 'Borsod-Abaúj-Zemplén', 'Heves', 'Nógrád', 'Pest', 'Komárom-Esztergom', 'Győr-Moson-Sopron', 'Fejér', 'Veszprém', 'Vas', 'Zala', 'Somogy', 'Tolna']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     private $missions = []; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     private $missionTypes = ['simple'=>[], 'gate'=>[]]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private $visitedGates = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     public function attributeNames() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         return []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @param integer $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     public function setId($id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $this->id = (int)$id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     public function getId() | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |         return $this->id; | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     public function getMissions() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         return $this->missions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     public function getMissionTypes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         return $this->missionTypes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     public function getName($id = 0) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         if (!$id) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             $id = $this->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $res = $this->fetchWater($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         return $res['title']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     public function getCounty($id = 0) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         if (!$id) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             $id = $this->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $res = $this->fetchWater($id); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $countyId = $res['county_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $county = @$this->county[$countyId]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         if (!$county) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             $county = '?'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         return $county; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     public function getRoutine() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         return $this->routine; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     public function incrementRoutine() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         return $this->routine++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     public function getRoutineStars($r = 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         if (!$r) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |             $r = $this->routine; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $d = floor($r / 81); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $eRem = $r % 81; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $e = floor($eRem / 27); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         $gRem = $r % 27; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $g = floor($gRem / 9); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $sRem = $r % 9; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $s = floor($sRem / 3); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $bRem = $r % 3; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         $b = $bRem; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         $ret = ['routine'=>$r, 'diamant'=>$d, 'emerald'=>$e, 'gold'=>$g, 'silver'=>$s, 'bronze'=>$b]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     public function getRoutineImages($routine) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         $txt = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         foreach (['diamant', 'emerald', 'gold', 'silver', 'bronze'] as $star) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |             for ($i=0; $i<$routine[$star]; $i++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                 $txt .= '<span class="spr star-'.$star[0].'"></span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         return $txt; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     public function getNavigationLinks() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $nav = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         //previous locations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $res = $this->fetchWater($this->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         foreach (['from', 'from2'] as $id) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             if ($res[$id]) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |                 $navId = (int)$res[$id]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                 $link = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                     'id' => $navId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |                     'type' => 'prev', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |                     'title' => $this->getName($navId), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                     'active' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |                     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |                 $nav[] = $link; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         //next locations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         foreach ($this->missionTypes['gate'] as $missionId) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |             $nextId = (int)$this->missions[$missionId]->gate; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             $visited = $this->isVisited($nextId); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             $this->visitedGates[$nextId] = $visited; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             $link = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |                 'id' => $nextId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |                 'type' => 'next', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                 'title' => $this->getName($nextId), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |                 'active' => $this->visitedGates[$nextId], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                 ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |             $nav[] = $link; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         return $nav; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     public function isVisited($id = 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         if (!$id) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |             $id = $this->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         $uid = Yii::app()->player->model->uid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         $visited = Yii::app()->db->createCommand() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             ->select('*') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             ->from('visited') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |             ->where('uid=:uid AND water_id=:id', [':uid'=>$uid, ':id'=>$id]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |             ->queryScalar(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         if (!$visited && $id==1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             //visit 1. location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             Yii::app()->db->createCommand() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |                 ->insert('visited', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |                 'uid'=>$uid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |                 'water_id'=>$id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |                 ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |             $visited = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             Yii::app()->gameLogger->log(['type'=>'travel', 'traveled_to'=>$id]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         return $visited ? true : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     public function setActive() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         $player = Yii::app()->player->model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         if ($player->last_location == $this->id) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         $attr = ['last_location'=>$this->id]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         if ($this->id > 1 && $player->tutorial_mission==6) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             $attr['tutorial_mission'] = 7; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         $player->rewriteAttributes($attr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         Yii::app()->badge->model->triggerTravel($this->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     public function fetchMissions() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         $res = Yii::app()->db->createCommand() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             ->select('id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             ->from('missions') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |             ->where('water_id=:id', [':id'=>$this->id]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             ->order('id ASC') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |             ->queryAll(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         $this->fetchSkill_extended_at_visit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         foreach ($res as $mission) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |             $m = new Mission(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |             $m->id = $mission['id']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |             $m->skill_extended_at_visit = $this->skill_extended_at_visit; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |             $m->req_energy_expansion = $this->getEnergyExpansion(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |             $m->fetch(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             if ($m->gate) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |                 $m->gate_name = $this->getName($m->gate); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |                 $m->gate_visited = $this->isVisited($m->gate); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |                 $this->visitedGates[$m->gate] = $m->gate_visited; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             $this->missions[$mission['id']] = $m; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |             $key = $m->gate ? 'gate' : 'simple'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |             $this->missionTypes[$key][] = $mission['id']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     private function getEnergyExpansion() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         $exp = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |         if ($this->routine >= 27) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |             $exp = 1; // gold | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         if ($this->routine >= 243) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |             $exp = 2; // diamant | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |         return $exp; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |     public function fetchRoutine() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |         $res = Yii::app()->db->createCommand() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |             ->select('routine') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |             ->from('visited') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |             ->where('uid=:uid AND water_id=:water_id', [':uid'=>Yii::app()->player->model->uid, ':water_id'=>$this->id]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |             ->queryScalar(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         $this->routine = (int)$res; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     public function fetchSkill_extended_at_visit() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         $dependency = new CExpressionDependency('Yii::app()->params["visited_version"]'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |         $res = Yii::app()->db->cache(Yii::app()->params['cacheDuration'], $dependency)->createCommand() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |             ->select('skill_extended_at_visit') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |             ->from('visited') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |             ->where('uid=:uid AND water_id=:water_id', [':uid'=>Yii::app()->player->model->uid, ':water_id'=>$this->id]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |             ->queryScalar(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |         $this->skill_extended_at_visit = (int)$res; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |     public function listVisited() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |         $res = Yii::app()->db->createCommand() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |             ->select('water_id, routine') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |             ->from('visited') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |             ->where('uid=:uid', [':uid'=>Yii::app()->player->model->uid]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             ->queryAll(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         $visited = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |         foreach ($res as $l) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |             $water = $this->fetchWater($l['water_id']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |             if ($l['water_id'] == Yii::app()->player->model->last_location) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |                 $water['last']=1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |             $water['routine'] = $l['routine']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |             $visited[$l['water_id']] = $water; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         return $visited; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |     private function fetchWater($id) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |         $dependency = new CExpressionDependency('Yii::app()->params["waters_version"]'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |         $res = Yii::app()->db->cache(Yii::app()->params['cacheDuration'], $dependency)->createCommand() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |             ->select('*') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |             ->from('waters') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |             ->where('id=:id', [':id'=>(int)$id]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |             ->queryRow(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |         return $res; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 301 |  |  | } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 302 |  |  |  | 
            
                        
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.