diff options
Diffstat (limited to 'game/objectives')
-rw-r--r-- | game/objectives/freeroam.cpp | 22 | ||||
-rw-r--r-- | game/objectives/freeroam.h | 12 |
2 files changed, 27 insertions, 7 deletions
diff --git a/game/objectives/freeroam.cpp b/game/objectives/freeroam.cpp new file mode 100644 index 0000000..0721ef2 --- /dev/null +++ b/game/objectives/freeroam.cpp @@ -0,0 +1,22 @@ +#include "freeroam.h" +#include <game/activities/go.h> +#include <game/activity.h> +#include <game/network/link.h> +#include <iterator> +#include <memory> +#include <random> +#include <vector> + +ActivityPtr +FreeRoam::createActivity() const +{ + return std::make_unique<Go>(); +} + +Link::Next +FreeRoam::navigate(Link::Nexts::const_iterator begin, Link::Nexts::const_iterator end) const +{ + static std::mt19937 gen(std::random_device {}()); + auto off = std::uniform_int_distribution<>(0, std::distance(begin, end) - 1)(gen); + return begin[off]; +} diff --git a/game/objectives/freeroam.h b/game/objectives/freeroam.h index c97d9b4..2cfdcfc 100644 --- a/game/objectives/freeroam.h +++ b/game/objectives/freeroam.h @@ -1,18 +1,16 @@ #ifndef FREEROAM_H #define FREEROAM_H -#include "game/activities/go.h" -#include "game/objective.h" +#include <game/activity.h> +#include <game/network/link.h> +#include <game/objective.h> class FreeRoam : public Objective { public: using Objective::Objective; - [[nodiscard]] ActivityPtr - createActivity() const override - { - return std::make_unique<Go>(); - } + [[nodiscard]] ActivityPtr createActivity() const override; + [[nodiscard]] Link::Next navigate(Link::Nexts::const_iterator, Link::Nexts::const_iterator) const override; }; #endif |