Code revision after 2 years

This commit is contained in:
Matúš Púll 2025-08-04 16:25:11 +02:00
parent e412e0c173
commit 94f905e917
16 changed files with 114 additions and 148 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
image
generate

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

9
Makefile Normal file
View file

@ -0,0 +1,9 @@
image: image.cpp
g++ image.cpp -o image -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs
generate: generate.cpp
g++ generate.cpp -o generate
folders: cards/factions.json
for jmeno in $$(cat cards/factions); do mkdir cards/$$jmeno && mkdir cards/$$jmeno; done

View file

@ -1 +0,0 @@
bruh

View file

@ -1,5 +1,4 @@
[
"universal",
"northern-kingdoms",
"monsters",
"nilfgaard",

View file

@ -4,7 +4,5 @@
"faction": "My Ass",
"line": "balls",
"power": 0,
"traits": [
]
"traits": []
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 KiB

View file

@ -1,11 +0,0 @@
{
"display": "Tester",
"faction": "universal",
"line": "front",
"name": "test",
"power": 0,
"traits": [
"spy",
"double"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

View file

@ -1,31 +0,0 @@
#include <nlohmann/json.hpp>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
using nlohmann::json;
using std::string;
int main() {
std::ifstream f1("cards/template.json");
json data = json::parse(f1);
std::ifstream f2("cards/traits.json");
json traits = json::parse(f2);
std::ifstream f3("cards/factions.json");
json factions = json::parse(f3);
std::ifstream f4("cards/lines.json");
json lines = json::parse(f4);
for(auto f : factions) {
string command = "mkdir cards/" + string(f) + "/images";
std::system(command.c_str());
}
//std::ofstream out("cards/"+factions[faction]+"/"+name+".json");
return 0;
}

BIN
generate

Binary file not shown.

View file

@ -1,12 +1,22 @@
#include <nlohmann/json.hpp>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
using nlohmann::json;
using std::string;
string get(json j, string name) {
std::cout << name << " (";
for(int i = 0; i < j.size(); ++i)
std::cout << i << ':' << j[i] << ' ';
std::cout << ") : ";
int index; std::cin >> index;
if(index < 0 || index >= j.size())
return "";
return j[index];
}
int main() {
std::ifstream f1("cards/template.json");
json data = json::parse(f1);
@ -14,7 +24,6 @@ int main() {
std::ifstream f2("cards/traits.json");
json traits = json::parse(f2);
std::ifstream f3("cards/factions.json");
json factions = json::parse(f3);
@ -22,29 +31,22 @@ int main() {
json lines = json::parse(f4);
std::cout << "Name: ";
string name; std::cin >> name; data["name"] = name;
std::cout << "Display name: ";
std::cin.ignore();
string display; std::getline(std::cin, display); data["display"] = display;
string name; std::getline(std::cin, name);
data["name"] = name;
std::cout << "Faction (0:Universal,1:SK,2:M,3:N,4:S): ";
int faction; std::cin >> faction; data["faction"] = factions[faction];
data["faction"] = get(factions, "Faction");
std::cout << "Line (0:front, 1:middle, 2:back): ";
int line; std::cin >> line; data["line"] = lines[line];
data["line"] = get(lines, "Line");
std::cout << "Power: ";
int power; std::cin >> power; data["power"] = power;
std::cout << "Traits (0:End,1:Spy,2:Double,3:Boost,4:Call-to-arms,5:Horn,6:Revive,7:Destroy): ";
int trait = -1;
while(trait != 0) {
if(trait != -1) data["traits"].push_back(traits[trait-1]);
std::cin >> trait;
}
for(string trait = get(traits, "Trait"); trait != ""; trait = get(traits, "Trait"))
if(trait != "")
data["traits"].push_back(trait);
std::ofstream out("cards/"+string(factions[faction])+"/"+name+".json");
std::ofstream out("cards/"+string(data["faction"])+"/"+name+".json");
out << data.dump(2) << std::endl;
return 0;

1
icom
View file

@ -1 +0,0 @@
g++ image.cpp -o image -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs

BIN
image

Binary file not shown.

Binary file not shown.