/** * API:获取主角所有信息 * * @access public * @param int $user_id 用户ID * @return array */ public function GetAllCharacterInfo($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); } //读取系统主角,属性列表 $file = IniFileManager::getRootDir() . "/files/csv/character.csv"; $characterArr = self::readCsv($file); foreach ($characterArr as $key => $value) { if ($userCharacter[$value['character_id']]) { $characterArr[$key]['n_get'] = 1; $characterArr[$key]['battle'] = self::getCharacterBattle($user_id, $value['character_id']); $characterArr[$key]['updateInfo'] = self::getUpdateInfo($user_id, $value['character_id']); $characterArr[$key]['level'] = $userCharacter[$value['character_id']]['n_level']; $characterArr[$key]['bigest_level'] = $value['bigest_level']; $characterArr[$key]['attributeInfo'] = self::GetCharacterAttribute($user_id, $value['character_id']); } else { $characterArr[$key]['n_get'] = 0; $characterArr[$key]['battle'] = self::getCharacterBattle($user_id, $value['character_id']); $characterArr[$key]['updateInfo'] = self::getUpdateInfo($user_id, $value['character_id']); $characterArr[$key]['level'] = $value['level']; $characterArr[$key]['bigest_level'] = $value['bigest_level']; $characterArr[$key]['attributeInfo'] = self::GetCharacterAttribute($user_id, $value['character_id']); } } foreach (self::$price_type as $key => $value) { $moneyArr[$value] = UserCache::getByKey($user_id, $value); if (!$moneyArr[$value]) { $userInfo = CharacterModel::getUserInfo($user_id); $moneyArr[$value] = $userInfo[$value]; } } $messageArr['moneyInfo'] = $moneyArr; $messageArr['characterInfo'] = $characterArr; $messageArr['n_fight_id'] = $userCharacter[0]; return $messageArr; }
/** * API:获取武将属性 * * @access public * @param $integer $user_id 用户ID * @return array */ public function GetAllGeneralInfo($user_id) { $userGeneral = UserCache::getByKey($user_id, 's_general_info'); if (!$userGeneral) { $userGeneral = GeneralModel::getUserGeneralInfo($user_id); UserCache::setByKey($user_id, 's_general_info', $userGeneral); } //读取系统武将,属性列表 $file = IniFileManager::getRootDir() . "/files/csv/general.csv"; $generalArr = CharacterAction::readCsv($file); foreach ($generalArr as $key => $value) { if ($userGeneral[$value['general_id']]) { $generalArr[$key]['n_get'] = 1; //$generalArr[$key]['battle']=self::GetGeneralBattle($user_id,$value['general_id']); $generalArr[$key]['attributeInfo'] = self::GetGeneralAttribute($user_id, $value['general_id']); } else { $generalArr[$key]['n_get'] = 0; // $generalArr[$key]['battle']=self::GetGeneralBattle($user_id,$value['general_id']); $generalArr[$key]['attributeInfo'] = self::GetGeneralAttribute($user_id, $value['general_id']); } } foreach (self::$price_type as $key => $value) { $moneyArr[$value] = UserCache::getByKey($user_id, $value); if (!$moneyArr[$value]) { $userInfo = CharacterModel::getUserInfo($user_id); $moneyArr[$value] = $userInfo[$value]; } } $messageArr['moneyInfo'] = $moneyArr; $messageArr['generalInfo'] = $generalArr; return $messageArr; }