diff --git a/assets/config.json b/assets/config.json index 5e2047a..c85279e 100644 --- a/assets/config.json +++ b/assets/config.json @@ -5,7 +5,8 @@ "player": { }, - "type": { - "TEST": 1234 + "worldgen": { + "enemy_probability": 60, + "empty_room_probability": 20 } } diff --git a/assets/items.json b/assets/items.json index 9ff75f4..ed7fac5 100644 --- a/assets/items.json +++ b/assets/items.json @@ -7,7 +7,7 @@ "description": "A torch that barely lights the way. You wonder if it'd be better to not see the person who murders you.", "inventory_count": 1, "components": [ - {"type": "LightSource", "config": {"strength": 100, "radius": 4.0}}, + {"type": "LightSource", "config": {"strength": 70, "radius": 2.0}}, {"type": "Tile", "config": {"chr": "\u0f08"}} ] }, diff --git a/lights.hpp b/lights.hpp index 8f9cd98..5faabcc 100644 --- a/lights.hpp +++ b/lights.hpp @@ -13,8 +13,8 @@ namespace lighting { float radius = 1.0f; }; - const int MIN = 35; - const int MAX = 95; + const int MIN = 30; + const int MAX = 105; class LightRender { public: diff --git a/worldbuilder.cpp b/worldbuilder.cpp index 8a3a5b2..0d57755 100644 --- a/worldbuilder.cpp +++ b/worldbuilder.cpp @@ -187,26 +187,28 @@ DinkyECS::Entity configure_entity_in_map(DinkyECS::World &world, Map &game_map, void WorldBuilder::randomize_entities(DinkyECS::World &world, GameConfig &config) { - int rand_type = Random::uniform(0,1); - json entity_db = rand_type == 0 ? config.enemies.json() : config.items.json(); + auto &gen_config = config.game["worldgen"]; - std::vector keys; - for(auto &el : entity_db.items()) { - keys.push_back(el.key()); - } for(size_t room_num = $map.room_count() - 1; room_num > 0; room_num--) { - int has_entity = Random::uniform(0, 1); + int empty_room = Random::uniform(0, 100); + if(empty_room < gen_config["empty_room_probability"]) continue; - if(has_entity == 0) { - int rand_entity = Random::uniform(0, keys.size() - 1); - std::string key = keys[rand_entity]; - auto entity_data = entity_db[key]; + int rand_type = Random::uniform(0,100); + json& entity_db = rand_type < gen_config["enemy_probability"] ? config.enemies.json() : config.items.json(); - // pass that to the config as it'll be a generic json - auto entity = configure_entity_in_map(world, $map, entity_data, room_num); - (void)entity; + std::vector keys; + for(auto &el : entity_db.items()) { + keys.push_back(el.key()); } + + int rand_entity = Random::uniform(0, keys.size() - 1); + std::string key = keys[rand_entity]; + auto entity_data = entity_db[key]; + + // pass that to the config as it'll be a generic json + auto entity = configure_entity_in_map(world, $map, entity_data, room_num); + (void)entity; } }