#include "Location.h" #include "Dungeon.h" #include "RNG.h" #include "backend/ListIterator.h" #include "print.h" void Dungeon::update(Location * player_location) { this->player_location = player_location; ListRange enemies = player_location->get_enemies(); if (enemies.size() > 0) this->update_attacks(enemies); else this->update_movement(); } void Dungeon::update_attacks(ListRange & enemies) { printf("TODO: de vijanden vallen aan!\n"); } void Dungeon::update_movement() { bool moved = false; for (Location * location : this->locations) { for (Enemy * enemy : location->get_enemies()) { if (RNG::get().rand_double() < 0.5) continue; if (!moved) lprtf(":: De vijanden bewegen ::\n"); Direction direction = random_direction(*location); location->remove_enemy(enemy); Location * new_location = location->get_exit(direction); new_location->add_enemy(enemy); if (player_location == new_location) lprtf("%s komt de huidige locatie binnen\n", enemy->get_name().c_str()); moved = true; } } } void Dungeon::add_location(Location * location) { this->locations.push_back(location); } Location * Dungeon::get_start_location() { size_t size = this->locations.size(); if (size == 0) return nullptr; size_t index = RNG::get().rand_int(size); return this->locations[index]; }