Exemplo n.º 1
0
 /**
  * Builds criterias table for current (this->achId) achievement
  * @category Achievements class
  * @access   private
  * @return   array
  **/
 private function BuildAchievementCriteriaTable()
 {
     if (in_array(Armory::GetLocale(), array('es_es', 'es_mx'))) {
         $locale = 'en_gb';
     } else {
         $locale = Armory::GetLocale();
     }
     if (!$this->guid || !$this->achId) {
         Armory::Log()->writeError('%s : player guid or achievement id is not defiend (GUID: %s, achId: %d)', __METHOD__, $this->guid, $this->achId);
         return false;
     }
     $data = Armory::$aDB->select("SELECT * FROM `ARMORYDBPREFIX_achievement_criteria` WHERE `referredAchievement`=%d ORDER BY `showOrder`", $this->achId);
     if (!$data) {
         Armory::Log()->writeError('%s : achievement criteria for achievement #%d was not found', __METHOD__, $this->achId);
         return false;
     }
     $i = 0;
     $achievement_criteria = array();
     foreach ($data as $criteria) {
         if ($criteria['completionFlag'] & ACHIEVEMENT_CRITERIA_FLAG_HIDE_CRITERIA) {
             continue;
         }
         $m_data = self::GetCriteriaData($criteria['id']);
         if (!isset($m_data['counter']) || !$m_data['counter']) {
             $m_data['counter'] = 0;
         }
         $achievement_criteria[$i]['id'] = $criteria['id'];
         if (isset($m_data['date']) && $m_data['date'] > 0) {
             $achievement_criteria[$i]['date'] = date('Y-m-d\\TH:i:s\\+01:00', $m_data['date']);
         }
         $achievement_criteria[$i]['name'] = $criteria['name_' . $locale];
         if ($criteria['completionFlag'] & ACHIEVEMENT_CRITERIA_FLAG_SHOW_PROGRESS_BAR || $criteria['completionFlag'] & ACHIEVEMENT_FLAG_COUNTER) {
             if ($criteria['completionFlag'] & ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER) {
                 $achievement_criteria[$i]['maxQuantityGold'] = $criteria['value'];
                 $money = Mangos::GetMoney($m_data['counter']);
                 $achievement_criteria[$i]['quantityGold'] = $money['gold'];
                 $achievement_criteria[$i]['quantitySilver'] = $money['silver'];
                 $achievement_criteria[$i]['quantityCopper'] = $money['copper'];
             } else {
                 $achievement_criteria[$i]['maxQuantity'] = $criteria['value'];
                 $achievement_criteria[$i]['quantity'] = $m_data['counter'];
             }
         }
         $i++;
     }
     return $achievement_criteria;
 }