Exemplo n.º 1
0
 /**
  * 判断是否主角全满级
  *
  * @access public
  * @param int $user_id 用户ID
  * @return array
  */
 public function isRoleMax($user_id)
 {
     $file = IniFileManager::getRootDir() . "/files/csv/character.csv";
     $characterArr = CharacterAction::readCsv($file);
     $userCharacter = UserCache::getByKey($user_id, CharacterAction::CHARACTER_STRING);
     if (!$userCharacter) {
         $userCharacter = CharacterModel::getUserCharacterInfo($user_id);
         UserCache::setByKey($user_id, CharacterAction::CHARACTER_STRING, $userCharacter);
     }
     $attribute = array(1 => 'n_attack_level', 2 => 'n_crit_level', 3 => 'n_hp_level');
     $CharacterNum = 0;
     foreach ($characterArr as $key => $value) {
         if ($userCharacter[$value['character_id']] && $userCharacter[$value['character_id']]['n_level'] == $value['bigest_level']) {
             foreach ($attribute as $key2 => $value2) {
                 $CharacterNum += Constants::MAX_ATTRIBUTE - $userCharacter[$value['character_id']][$value2];
             }
         } else {
             $CharacterNum += 15;
         }
     }
     // if (count($userCharacter)>count($characterArr))
     // {
     //     foreach ($userCharacter as $key => $value)
     //     {
     //         if ($value['n_level']==Constants::CHARACTER_MAX_LEVEL)
     //         {
     //             foreach ($attribute as $key2 => $value2)
     //             {
     //                 $CharacterNum+=Constants::MAX_ATTRIBUTE-$value[$value2];
     //             }
     //         }
     //         else
     //         {
     //             $generalNum=5;
     //         }
     //     }
     // }
     // else {
     //     $generalNum=10;
     // }
     return $CharacterNum;
 }
Exemplo n.º 2
0
 /**
  * API:获取当前上阵主角信息
  *
  * @access public
  * @param $integer $user_id $general_id 用户ID,武将ID
  * @return array 
  */
 public function nowCharacterInfo($user_id)
 {
     $userCharacter = UserCache::getByKey($user_id, self::CHARACTER_STRING);
     if (!$userCharacter) {
         $userCharacter = CharacterModel::getUserCharacterInfo($user_id);
         UserCache::setByKey($user_id, self::CHARACTER_STRING, $userCharacter);
     }
     return self::GetCharacterAttribute($user_id, $userCharacter[0]);
 }