diff --git a/EXA-Parser/EXA-Parser.cpp b/EXA-Parser/EXA-Parser.cpp index 6f58943..3be317a 100644 --- a/EXA-Parser/EXA-Parser.cpp +++ b/EXA-Parser/EXA-Parser.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include namespace fs = std::filesystem; using namespace std; @@ -62,6 +64,7 @@ map solutions; map dataMap; vector ids = { }; vector battles = { }; +vector bonus = { }; // Utils string readString(ifstream& stream) { @@ -157,6 +160,7 @@ int main(int argc, char* argv[]) int globalCounter = 0; int solutionCounter = 1; int battleCounter = 1; + int bonusCounter = 1; string line; while (getline(dataStream, line)) { int i1 = line.find(','); @@ -171,6 +175,8 @@ int main(int argc, char* argv[]) bool isBattle = description.rfind("battle-", 0) == 0; int counter = isBattle ? battleCounter++ : solutionCounter++; + bool isBonus = description.rfind("bonus-", 0) == 0; + counter = isBonus ? bonusCounter++ : counter; // Create path based on title string path = ((counter < 10) ? ("0" + to_string(counter)) : to_string(counter)) + '-'; @@ -200,8 +206,9 @@ int main(int argc, char* argv[]) dataMap[id] = info; - if (!isBattle) ids.push_back(id); + if(!isBattle) ids.push_back(id); else battles.push_back(id); + if(isBonus) bonus.push_back(id); globalCounter++; } @@ -323,6 +330,15 @@ int main(int argc, char* argv[]) cout << " No 'battles' directory found" << endl; } + fs::path pathOutputBonus = pathOutput / "bonus"; + if (fs::is_directory(pathOutputBonus)) { + fs::remove_all(pathOutputBonus); + cout << " Clearing 'bonus' directory" << endl; + } + else { + cout << " No 'bonus' directory found" << endl; + } + cout << endl << "Create files:" << endl; // Create README @@ -360,7 +376,7 @@ int main(int argc, char* argv[]) for (int i = 0; i < maxChars + 2 + 4; i++) readmeOut << '-'; readmeOut << "|--------|------|----------|" << endl; - for (int i = 0; i < ids.size(); i++) { + for (int i = 0; i < 34; i++) { Info info = dataMap[ids[i]]; readmeOut << "| [" << to_string(i + 1) << ": " << info.title << "](solutions/" << info.path << ") "; @@ -404,6 +420,34 @@ int main(int argc, char* argv[]) writeNum(readmeOut, solution.losses, 6); readmeOut << " | S+ |" << endl; } + + // Create bonus + readmeOut << endl << "| Bonus campaign level"; + for (int i = 0; i < maxChars - 5 + 1 + 4; i++) readmeOut << ' '; + readmeOut << "| Cycles | Size | Activity |" << endl; + + readmeOut << "|"; + for (int i = 0; i < maxChars + 2 + 4; i++) readmeOut << '-'; + readmeOut << "|--------|------|----------|" << endl; + + for (int i = 0; i < bonus.size(); i++) { + Info info = dataMap[bonus[i]]; + readmeOut << "| [" << to_string(i + 1) << ": " << info.title << "](bonus/" << info.path << ") "; + + int total = maxChars - (1 + info.title.length() + 12 + info.path.length() + 1); + for (int j = 0; j < total; j++) readmeOut << ' '; + + if (i < 9) readmeOut << ' '; + + Solution solution = solutions[ids[34 + i]]; + readmeOut << "| "; + writeNum(readmeOut, solution.cycles, CYCLE_N); + readmeOut << " | "; + writeNum(readmeOut, solution.size, SIZE_N); + readmeOut << " | "; + writeNum(readmeOut, solution.activity, ACTIVITY_N); + readmeOut << " |" << endl; + } } else if (line == "") { readmeOut << line << endl; @@ -425,7 +469,7 @@ int main(int argc, char* argv[]) cout << endl << " Making solutions:" << endl; - for (int i = 0; i < ids.size(); i++) { + for (int i = 0; i < 34; i++) { Info info = dataMap[ids[i]]; fs::create_directories(pathOutputSolutions / info.path); @@ -531,4 +575,66 @@ int main(int argc, char* argv[]) cout << " " << info.title << endl; } + + // Create bonus folder + fs::create_directories(pathOutputBonus); + + cout << endl << " Making bonus:" << endl; + + for (int i = 0; i < bonus.size(); i++) { + Info info = dataMap[bonus[i]]; + + fs::create_directories(pathOutputBonus / info.path); + ofstream readmeOut(pathOutputBonus / info.path / "README.md"); + + readmeOut << "# " << to_string(i + 1) << ": " << info.title << endl << endl; + + // Copy GIF + fs::copy(info.gif, pathOutputBonus / info.path / info.gif.filename()); + readmeOut << "
" << endl << endl; + + // Read description files + ifstream descriptionStream(pathDescriptions / info.description); + if (descriptionStream) { + readmeOut << "## Instructions" << endl; + while (getline(descriptionStream, line)) { + readmeOut << "> " << line << endl; + } + readmeOut << endl; + } + + readmeOut << "## Solution" << endl << endl; + + // Add source as well + Solution solution = solutions[bonus[i]]; + + for (int j = 0; j < solution.exas.size(); j++) { + EXA exa = solution.exas[j]; + readmeOut << "### [" << exa.name << "](" << exa.name << ".exa) (" << (exa.local ? "local" : "global") << ")" << endl; + readmeOut << "```asm" << endl; + readmeOut << exa.source << endl; + readmeOut << "```" << endl << endl; + + // Generate file as well + ofstream exaOut(pathOutputBonus / info.path / (exa.name + ".exa")); + exaOut << exa.source; + } + + // Copy OG file save as well + fs::copy(solution.path, pathOutputBonus / info.path / solution.path.filename()); + + // Add score + readmeOut << "#### Results" << endl; + readmeOut << "| Cycles | Size | Activity |" << endl; + readmeOut << "|--------|------|----------|" << endl; + readmeOut << "| "; + writeNum(readmeOut, solution.cycles, CYCLE_N); + readmeOut << " | "; + writeNum(readmeOut, solution.size, SIZE_N); + readmeOut << " | "; + writeNum(readmeOut, solution.activity, ACTIVITY_N); + readmeOut << " |" << endl; + + cout << " " << info.title << endl; + } } \ No newline at end of file diff --git a/EXA-Parser/data.txt b/EXA-Parser/data.txt index a501237..7d0f162 100644 --- a/EXA-Parser/data.txt +++ b/EXA-Parser/data.txt @@ -26,7 +26,7 @@ PB022,battle-3,Deadlock's Domain (Deadlock) PB023,baseball,Xtreme League Baseball (Player Database) PB024,mmo,King's Ransom Online (US West Realm) PB028,satellite,KGOG-TV (Satellite Uplink) -PB025,bank,Equity First Bank (San Francisco (ATMs Offline) +PB025,bank,Equity First Bank (San Francisco - ATMs Offline) PB019,battle-4,The Wormhole (X10X10X) PB026B,worm,TEC EXA-Blaster Modem (Dataphone Network) PB029B,snaxnet,Last Stop Snaxnet (Warehouse 27) @@ -36,4 +36,13 @@ PB031B,battle-5,Aberdeen (selenium_wolf) PB033,dna,US Government (Fema Genetic Database) PB034,secure-enclave,Unknown Network 2 (Unknown Context) PB035B,pagers,TEC EXA-Blaster Modem (Pager Network) -PB036,interface,Mitsuzen HDI-10 (Cerebral Cortex) \ No newline at end of file +PB036,interface,Mitsuzen HDI-10 (Cerebral Cortex) +PB054,bonus-mutex,Bloodlust Online (US East Realm) +PB053,bonus-nth,Motor Vehicle Administration (Scheduling System) +PB050,bonus-ghast,Cybermyth Studios (Accounting System) +PB056,bonus-hydro,US Department of Defense (USAF Secure Facility) +PB051,bonus-plastered,Netronics NET40 Modem (The Wardialer) +PB057,bonus-selenium,EspaƱola Valley High School (School Management System) +PB052,bonus-x10,Mitsuzen D300-N (Personal Storage Array) +PB055,bonus-deadlock,Crystalair International (Ticketing System) +PB058,bonus-moss,Your Computer (Unknown Context) \ No newline at end of file diff --git a/README.md b/README.md index ffca804..dade86c 100644 --- a/README.md +++ b/README.md @@ -93,5 +93,5 @@ Linux: ## TODO - [ ] Generate circa 1997 geocities static html pages - [ ] [Achievements](https://steamcommunity.com/stats/716490/achievements) -- [ ] Bonus Levels -- [ ] Nonograms \ No newline at end of file +- [x] Bonus Levels +- [ ] Nonograms