git
BIN
Bez_nadeje.png
Normal file
After Width: | Height: | Size: 85 KiB |
7
cards/factions.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
[
|
||||
"universal",
|
||||
"northern-kingdoms",
|
||||
"monsters",
|
||||
"nilfgaard",
|
||||
"scoiatael"
|
||||
]
|
BIN
cards/images/factions/universal.png
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
cards/images/lines/front.png
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
cards/images/traits/double.png
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
cards/images/traits/spy.png
Normal file
After Width: | Height: | Size: 85 KiB |
5
cards/lines.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
[
|
||||
"front",
|
||||
"middle",
|
||||
"back"
|
||||
]
|
12
cards/northern-kingdoms/brambor.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"display": "oligarchie",
|
||||
"faction": "northern-kingdoms",
|
||||
"line": "front",
|
||||
"name": "brambor",
|
||||
"power": 1,
|
||||
"traits": [
|
||||
"spy",
|
||||
"double",
|
||||
"call-to-arms"
|
||||
]
|
||||
}
|
10
cards/template.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "card",
|
||||
"display": "The Name",
|
||||
"faction": "My Ass",
|
||||
"line": "balls",
|
||||
"power": 0,
|
||||
"traits": [
|
||||
|
||||
]
|
||||
}
|
9
cards/traits.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
[
|
||||
"spy",
|
||||
"double",
|
||||
"boost",
|
||||
"call-to-arms",
|
||||
"horn",
|
||||
"revive",
|
||||
"destroy"
|
||||
]
|
BIN
cards/universal/images/test.png
Normal file
After Width: | Height: | Size: 449 KiB |
11
cards/universal/test.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"display": "Tester",
|
||||
"faction": "universal",
|
||||
"line": "front",
|
||||
"name": "test",
|
||||
"power": 0,
|
||||
"traits": [
|
||||
"spy",
|
||||
"double"
|
||||
]
|
||||
}
|
BIN
cards/universal/test.png
Normal file
After Width: | Height: | Size: 85 KiB |
31
folders.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#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
Executable file
51
generate.cpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
#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);
|
||||
|
||||
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;
|
||||
|
||||
std::cout << "Faction (0:Universal,1:SK,2:M,3:N,4:S): ";
|
||||
int faction; std::cin >> faction; data["faction"] = factions[faction];
|
||||
|
||||
std::cout << "Line (0:front, 1:middle, 2:back): ";
|
||||
int line; std::cin >> line; data["line"] = 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;
|
||||
}
|
||||
|
||||
std::ofstream out("cards/"+string(factions[faction])+"/"+name+".json");
|
||||
|
||||
out << data.dump(2) << std::endl;
|
||||
return 0;
|
||||
}
|
1
icom
Executable file
|
@ -0,0 +1 @@
|
|||
g++ image.cpp -o image -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs
|
BIN
image
Executable file
91
image.cpp
Normal file
|
@ -0,0 +1,91 @@
|
|||
#include <opencv2/highgui.hpp>
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
using namespace cv;
|
||||
using nlohmann::json;
|
||||
using std::string;
|
||||
|
||||
#define H 800
|
||||
#define W 300
|
||||
#define M 30
|
||||
#define R 60
|
||||
|
||||
Mat source_image = Mat::zeros(Size(H,W),CV_8UC1);
|
||||
void render(int i, int j, int y_s, int x_s, Mat *img) {
|
||||
if(i >= y_s && i <= y_s+R-1 && j >= x_s && j <= x_s+R-1) {
|
||||
source_image.at<uchar>(i,j)=img->at<uchar>(i-y_s,j-x_s);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
// FACTION
|
||||
int fac;
|
||||
if(argc <= 1) {
|
||||
std::cout << "0:U,1:SK,2:M,3:N,4:S";
|
||||
std::cin >> fac;
|
||||
}
|
||||
else fac = std::atoi(argv[1]);
|
||||
|
||||
std::ifstream ff("cards/factions.json");
|
||||
json factions = json::parse(ff);
|
||||
string faction = factions[fac];
|
||||
|
||||
// NAME
|
||||
string name;
|
||||
if(argc <= 2) std::cin >> name;
|
||||
else name = argv[2];
|
||||
std::ifstream f("cards/"+faction+"/"+name+".json");
|
||||
json data = json::parse(f);
|
||||
|
||||
// LOAD IMAGES
|
||||
Mat i_look = imread("cards/"+faction+"/images/"+name+".png",IMREAD_GRAYSCALE);
|
||||
Mat i_faction = imread("cards/images/factions/"+faction+".png",IMREAD_GRAYSCALE);
|
||||
Mat i_line = imread("cards/images/lines/"+string(data["line"])+".png",IMREAD_GRAYSCALE);
|
||||
|
||||
// RENDER IMAGES
|
||||
std::vector<Mat> i_traits;
|
||||
for(auto trait : data["traits"]) {
|
||||
i_traits.push_back(imread("cards/images/traits/"+string(trait)+".png",IMREAD_GRAYSCALE));
|
||||
}
|
||||
|
||||
for(int i=0;i<source_image.rows;i++)
|
||||
for(int j=0;j<source_image.cols;j++)
|
||||
source_image.at<uchar>(i,j)=i_look.at<uchar>(i,j);
|
||||
|
||||
// RENDER POWER AND TRAITS
|
||||
string bruh = std::to_string((int)data["power"]);
|
||||
for(int i=0;i<source_image.rows;i++) {
|
||||
for(int j=0;j<source_image.cols;j++) {
|
||||
// Vlevo nahoře sílu
|
||||
putText(
|
||||
source_image,
|
||||
bruh,
|
||||
Point(M,M),
|
||||
FONT_HERSHEY_COMPLEX_SMALL,
|
||||
1,
|
||||
Scalar(0,0,0),
|
||||
2
|
||||
);
|
||||
|
||||
render(i,j, M,W/2-R/2, &i_faction);
|
||||
render(i,j, M,W-M-R, &i_line);
|
||||
// Traits
|
||||
for(int k = 0; k < i_traits.size(); k++)
|
||||
render(i,j, H-M-R,W-M-R*(k+1), &i_traits[k]);
|
||||
}
|
||||
}
|
||||
|
||||
imshow("Result",source_image);
|
||||
waitKey(0);
|
||||
return 0;
|
||||
|
||||
|
||||
}
|