aboutsummaryrefslogtreecommitdiff
path: root/oop2eindopdr/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'oop2eindopdr/main.cpp')
-rw-r--r--oop2eindopdr/main.cpp37
1 files changed, 33 insertions, 4 deletions
diff --git a/oop2eindopdr/main.cpp b/oop2eindopdr/main.cpp
index 9a8c352..278d62f 100644
--- a/oop2eindopdr/main.cpp
+++ b/oop2eindopdr/main.cpp
@@ -38,15 +38,44 @@ int interactive_mode() {
}
int export_mode(int argc, char** argv) {
+ cout << "entering export mode..." << endl;
std::string csv_file = argv[1];
std::string zip_file = argc == 3 ? argv[2] : "";
- while (zip_file.size() == 0) { // make sure target file is given
+
+ ZipExport zip_export;
+ zip_export.set_pokedex(g_pokedex);
+ std::vector<std::string> card_ids = zip_export.import_csv(csv_file);
+ std::vector<PokemonCard*> cards;
+ for (std::string card_id : card_ids) {
+ PokemonCard* card = g_pokedex->get_card_by_id(card_id);
+ if (card == nullptr) {
+ cout << "could not find card with id " << card_id << endl;
+ continue;
+ }
+ card->fetch_market_value();
+ cards.push_back(card);
+ }
+
+ double total_value = 0.f;
+ for (PokemonCard* card : cards) {
+ cout << card->short_identifier() << " currently sells for " << card->value << endl;
+ total_value += card->value;
+ }
+ cout << "sum value of cards: " << total_value << endl;
+
+ if (zip_file.size() == 0) {
+ cout << "export as zip? [Y/n]: ";
+ std::string export_yn;
+ if (!std::getline(cin, export_yn)) return EXIT_SUCCESS; // exit if EOF (ctrl-d)
+ if (export_yn.size() > 0 && (export_yn[0] | (1 << 5)) != 'y')
+ return EXIT_SUCCESS; // exit if input is not 'Y', 'y', or <enter>
+
cout << "zip file location?: ";
- if (!std::getline(cin, zip_file)) break;
+ if (!std::getline(cin, zip_file)) return EXIT_FAILURE;
}
- cout << "exporting cards in " << csv_file << " to " << zip_file << endl;
- ZipExport zip_export(g_pokedex, csv_file, zip_file);
+ cout << "exporting as zip..." << endl;
+ zip_export.export_zip(zip_file, cards);
return EXIT_SUCCESS;
}