Code revision after 2 years
This commit is contained in:
parent
e412e0c173
commit
94f905e917
16 changed files with 114 additions and 148 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
image
|
||||
generate
|
BIN
Bez_nadeje.png
BIN
Bez_nadeje.png
Binary file not shown.
Before Width: | Height: | Size: 85 KiB |
9
Makefile
Normal file
9
Makefile
Normal 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
|
1
bruhmbor
1
bruhmbor
|
@ -1 +0,0 @@
|
|||
bruh
|
|
@ -1,5 +1,4 @@
|
|||
[
|
||||
"universal",
|
||||
"northern-kingdoms",
|
||||
"monsters",
|
||||
"nilfgaard",
|
||||
|
|
|
@ -4,7 +4,5 @@
|
|||
"faction": "My Ass",
|
||||
"line": "balls",
|
||||
"power": 0,
|
||||
"traits": [
|
||||
|
||||
]
|
||||
"traits": []
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 449 KiB |
|
@ -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 |
31
folders.cpp
31
folders.cpp
|
@ -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
BIN
generate
Binary file not shown.
36
generate.cpp
36
generate.cpp
|
@ -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
1
icom
|
@ -1 +0,0 @@
|
|||
g++ image.cpp -o image -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs
|
BIN
image
BIN
image
Binary file not shown.
BIN
notes.xopp
BIN
notes.xopp
Binary file not shown.
Loading…
Reference in a new issue