#include "SunClientPrecompiledHeader.h" #include "AreaConquestInfo.h" #include "AreaConquestDefine.h" #include "hero.h" namespace { const int kAllAreaCode = 601; // ü class SortByIndex { public: bool operator()(AchievementInfo*& Info_left_ref, AchievementInfo*& Info_right_ref) const { return Info_left_ref->GetIndex() < Info_right_ref->GetIndex(); } }; }; AreaConquestInfo::AreaConquestInfo(): achievement_(NULL), show_ratio_(false) { } AreaConquestInfo::~AreaConquestInfo() { } void AreaConquestInfo::InitAreaCodeList() { if (achievement() == NULL) { return; } // AC Ʈ // ü ߰ WORD area_code = kAllAreaCode; area_code_list_.clear(); area_code_list_.push_back(kAllAreaCode); // Achievement ڵ ߰ Achievement::ACHIEVEMENT_PART_ITER achievement_part_itr = achievement()->Begin(); Achievement::ACHIEVEMENT_PART_ITER achievement_part_itr_end = achievement()->End(); for ( ; achievement_part_itr != achievement_part_itr_end; ++achievement_part_itr) { area_code = (achievement_part_itr->first); area_code_list_.push_back(area_code); } std::sort(area_code_list_.begin(), area_code_list_.end()); } void AreaConquestInfo::RefreshAchievementInfo(WORD selected_area_code, WORD selected_info_state) { if (achievement() == NULL) { return; } AchievementInfo_List progress_info_list; AchievementInfo_List complete_info_list; achievement_info_list_.clear(); complete_ratio_ = 0; info_total_count_ = 0; info_complete_count_ = 0; show_ratio_ = false; // ¿ AchievementInfo // ü Ǵ Ư Achievement::ACHIEVEMENT_PART_ITER achievement_part_itr = achievement()->Begin(); Achievement::ACHIEVEMENT_PART_ITER achievement_part_itr_end = achievement()->End(); for ( ; achievement_part_itr != achievement_part_itr_end; ++achievement_part_itr) { AchievementPart* achievement_part = achievement_part_itr->second; if (achievement_part == NULL) { continue; } if (selected_area_code != kAllAreaCode) { if (selected_area_code != achievement_part->GetLocationCode()) { continue; } complete_ratio_ = achievement_part->GetAccomplishmentRatio(); show_ratio_ = achievement_part->show_ratio(); } AchievementPart::ACHIEVEMENT_ITER info_itr = achievement_part->Begin(); AchievementPart::ACHIEVEMENT_ITER info_itr_end = achievement_part->End(); for ( ; info_itr != info_itr_end; ++info_itr) { AchievementInfo* info_ptr = info_itr->second; if (info_ptr == NULL) { continue; } if (info_ptr->GetClassType() != eCHAR_NONE && g_pHero != NULL) { if (g_pHero->GetClass() != info_ptr->GetClassType()) { continue; } } if (IsAccomplishmentParent(info_ptr) == false) { continue; } #ifdef _SCJ_ACSYSTEM_OVERLAP_PARENT if (IsOverlap(info_ptr) == true) { // ļ continue; } #endif //_SCJ_ACSYSTEM_OVERLAP_PARENT // ¿ bool is_complete = info_ptr->IsAccomplishment() == true; switch (selected_info_state) { case uiAreaConquest::kSelect_All: { achievement_info_list_.push_back(info_ptr); } break; case uiAreaConquest::kSelect_Progress: case uiAreaConquest::kSelect_Complete: { if (is_complete == true) { complete_info_list.push_back(info_ptr); } else { progress_info_list.push_back(info_ptr); } } break; } ++info_total_count_; if (is_complete == true) { ++info_complete_count_; } } } // ¼ÿ switch (selected_info_state) { case uiAreaConquest::kSelect_All: { std::sort(achievement_info_list_.begin(), achievement_info_list_.end(), SortByIndex()); } break; case uiAreaConquest::kSelect_Progress: { std::sort(progress_info_list.begin(), progress_info_list.end(), SortByIndex()); std::sort(complete_info_list.begin(), complete_info_list.end(), SortByIndex()); achievement_info_list_.insert(achievement_info_list_.end(), progress_info_list.begin(), progress_info_list.end()); achievement_info_list_.insert(achievement_info_list_.end(), complete_info_list.begin(), complete_info_list.end()); } break; case uiAreaConquest::kSelect_Complete: { std::sort(progress_info_list.begin(), progress_info_list.end(), SortByIndex()); std::sort(complete_info_list.begin(), complete_info_list.end(), SortByIndex()); achievement_info_list_.insert(achievement_info_list_.end(), complete_info_list.begin(), complete_info_list.end()); achievement_info_list_.insert(achievement_info_list_.end(), progress_info_list.begin(), progress_info_list.end()); } break; } } WORD AreaConquestInfo::GetAreaCode( WORD list_index ) { WORD area_code = 0; if (list_index < area_code_list_.size()) { area_code = area_code_list_[list_index]; } return area_code; } WORD AreaConquestInfo::GetStartAreaCode() { WORD area_code = area_code_list_[uiAreaConquest::kFirstAreaCodeIndex]; return area_code; } DWORD AreaConquestInfo::GetAccomplishmentRatio() { return complete_ratio_; } DWORD AreaConquestInfo::GetAchievementInfoTotalCount() { return info_total_count_; } DWORD AreaConquestInfo::GetAccomplishmentCount() { return info_complete_count_; } bool AreaConquestInfo::IsShowRatio() { return show_ratio_; } bool AreaConquestInfo::IsAccomplishmentParent(AchievementInfo* achivement_ptr) { for (int i = 0; i < MAX_ACHIEVEMENT_PARENT_CODE; ++i) { if (achivement_ptr->GetParentCode(i) == 0 ) { return true; } bool is_accomplishment = achievement()->IsAccomplishmentByIndex(achivement_ptr->GetParentCode(i)); if (is_accomplishment == false) { return false; } } return true; } #ifdef _SCJ_ACSYSTEM_OVERLAP_PARENT bool AreaConquestInfo::IsOverlap(AchievementInfo* achivement_ptr) // return true : / false : ȼ { if ((achivement_ptr->IsAccomplishment() == true) && (achivement_ptr->IsReward() == false)) { // Ϸᰡ ʾ return false; } if ((achivement_ptr == NULL) || (achivement_ptr->GetChildMap().size() == 0)) { // Ǽ return false; } ACHIEVEMENT_INFO_MAP_ITER begin = achivement_ptr->GetChildMap().begin(); ACHIEVEMENT_INFO_MAP_ITER end = achivement_ptr->GetChildMap().end(); AchievementInfo* child_achievement; for (; begin != end; ++begin) { child_achievement = (*begin).second; // Ŭ ٸ 񱳴󿡼 if (child_achievement->GetClassType() != eCHAR_NONE && g_pHero != NULL) { if (g_pHero->GetClass() != child_achievement->GetClassType()) { continue; } } if (IsAccomplishmentParent(child_achievement) == false) { // Ϸ ȵ Ǽ return false; } } return true; } #endif //_SCJ_ACSYSTEM_OVERLAP_PARENT