Skip to content

Commit 785a0a0

Browse files
committed
Add unique_color_change
1 parent fb200ab commit 785a0a0

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/arena/data/EntityDataManager.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ namespace arena::data
6565
actions.push_back("ability1");
6666
};
6767

68-
if (!entity_data->getProjectileSpecial().empty()) {
68+
// TODO: Check if this is still used, its only used for fisherman
69+
/*if (!entity_data->getProjectileSpecial().empty()) {
6970
actions.push_back("loading1");
70-
}
71+
}*/
7172

7273
auto action = actions[random.random_int_from_interval(0, actions.size() - 1)];
7374
std::filesystem::path directory_path = character_directory / fmt::format("{export_name}_{action}_1", fmt::arg("export_name", is_blue ? entity_data->getBlueExportName() : entity_data->getRedExportName()), fmt::arg("action", action));

src/main.cpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ static json settings_schema = R"(
223223
"default": false,
224224
"type": "boolean"
225225
},
226+
"unique_color_change": {
227+
"description": "The chance of the color of the character to be changed",
228+
"type": "integer",
229+
"default": 20,
230+
"minimum": 0,
231+
"maximum": 100
232+
},
226233
"ready": {
227234
"description": "Set to 'true' when ready",
228235
"default": false,
@@ -256,7 +263,7 @@ typedef std::pair<
256263

257264
tl::expected<bool, std::string> try_read_settings_json();
258265
ThreadOutput generate_images(ThreadInfo thread_info, int start_image_id, int end_image_id);
259-
std::pair<std::list<json>, json> generate_battle(int image_id, int total_character_count, int character_count, Random& random, std::filesystem::path& asset_directory, std::filesystem::path& output_image_directory);
266+
std::pair<std::list<json>, json> generate_battle(int image_id, int total_character_count, int character_count, int unique_color_change, Random& random, std::filesystem::path& asset_directory, std::filesystem::path& output_image_directory);
260267
json get_categories();
261268
void create_annotations_json(std::filesystem::path& output_directory, json& coco_annotations);
262269
void create_data_yaml(std::filesystem::path& output_directory);
@@ -448,11 +455,12 @@ ThreadOutput generate_images(ThreadInfo thread_info, int start_image_id, int end
448455

449456
int character_min_count(settings_json["character_min_count"].get<int>());
450457
int character_max_count(settings_json["character_max_count"].get<int>());
458+
int unique_color_change(settings_json["unique_color_change"].get<int>());
451459

452460
int total_character_count = 0;
453461
for (int image_id = start_image_id; image_id < end_image_id; image_id++) {
454462
int character_count = random.random_int_from_interval(character_min_count, character_max_count);
455-
auto result = generate_battle(image_id, total_character_count, character_count, random, asset_directory, output_image_directory);
463+
auto result = generate_battle(image_id, total_character_count, character_count, unique_color_change, random, asset_directory, output_image_directory);
456464
std::list<json> character_coco_objects = result.first;
457465
json image_coco_object = result.second;
458466

@@ -466,7 +474,7 @@ ThreadOutput generate_images(ThreadInfo thread_info, int start_image_id, int end
466474
};
467475
}
468476

469-
std::pair<std::list<json>, json> generate_battle(int image_id, int total_character_count, int character_count, Random& random, std::filesystem::path& asset_directory, std::filesystem::path& output_image_directory) {
477+
std::pair<std::list<json>, json> generate_battle(int image_id, int total_character_count, int character_count, int unique_color_change, Random& random, std::filesystem::path& asset_directory, std::filesystem::path& output_image_directory) {
470478
auto& entity_data_manager = EntityDataManager::getInstance();
471479

472480
spdlog::info("Generating image {} with {} characters!\n", image_id, character_count);
@@ -510,7 +518,7 @@ std::pair<std::list<json>, json> generate_battle(int image_id, int total_charact
510518
static_cast<float>(Random::get_instance().random_int_from_interval(128, 954))
511519
};
512520
character->setPosition(position);
513-
if (random.random_int_from_interval(0, 1)) {
521+
if (random.random_int_from_interval(0, 100) <= unique_color_change) {
514522
std::vector<EntityEffect> non_stackable_entity_effects_vector(non_stackable_entity_effects);
515523
do {
516524
int index = random.random_int_from_interval(0, non_stackable_entity_effects_vector.size() - 1);

0 commit comments

Comments
 (0)