From 159b7e46735b9cbe896790451f8008b1459872b1 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Sat, 8 May 2021 04:36:26 +0300 Subject: [PATCH] Init --- .gitignore | 1 + CMakeLists.txt | 11 ++++ actors/actor.cpp | 7 ++ actors/actor.h | 26 ++++++++ actors/player.cpp | 80 +++++++++++++++++++++++ actors/player.h | 21 ++++++ controllers/controller.cpp | 46 ++++++++++++++ controllers/controller.h | 42 ++++++++++++ controllers/itemcontroller.cpp | 33 ++++++++++ controllers/itemcontroller.h | 21 ++++++ controllers/locationcontroller.cpp | 34 ++++++++++ controllers/locationcontroller.h | 21 ++++++ entities/item.cpp | 21 ++++++ entities/item.h | 20 ++++++ entities/location.cpp | 24 +++++++ entities/location.h | 33 ++++++++++ levelbuilder.cpp | 7 ++ levelbuilder.h | 21 ++++++ main.cpp | 20 ++++++ policies/itemrequiredpolicy.cpp | 20 ++++++ policies/itemrequiredpolicy.h | 23 +++++++ policies/locationrequiredpolicy.cpp | 20 ++++++ policies/locationrequiredpolicy.h | 23 +++++++ policies/policy.cpp | 16 +++++ policies/policy.h | 27 ++++++++ sandboxlevelbuilder.cpp | 99 +++++++++++++++++++++++++++++ sandboxlevelbuilder.h | 22 +++++++ 27 files changed, 739 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 actors/actor.cpp create mode 100644 actors/actor.h create mode 100644 actors/player.cpp create mode 100644 actors/player.h create mode 100644 controllers/controller.cpp create mode 100644 controllers/controller.h create mode 100644 controllers/itemcontroller.cpp create mode 100644 controllers/itemcontroller.h create mode 100644 controllers/locationcontroller.cpp create mode 100644 controllers/locationcontroller.h create mode 100644 entities/item.cpp create mode 100644 entities/item.h create mode 100644 entities/location.cpp create mode 100644 entities/location.h create mode 100644 levelbuilder.cpp create mode 100644 levelbuilder.h create mode 100644 main.cpp create mode 100644 policies/itemrequiredpolicy.cpp create mode 100644 policies/itemrequiredpolicy.h create mode 100644 policies/locationrequiredpolicy.cpp create mode 100644 policies/locationrequiredpolicy.h create mode 100644 policies/policy.cpp create mode 100644 policies/policy.h create mode 100644 sandboxlevelbuilder.cpp create mode 100644 sandboxlevelbuilder.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a9d35c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.user diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a62be50 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.5) + +project(slumber-quest LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +file(GLOB SOURCES "*.h" "*.cpp" "*/*.h" "*/*.cpp") +include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/actors ${CMAKE_SOURCE_DIR}/controllers ${CMAKE_SOURCE_DIR}/entities ${CMAKE_SOURCE_DIR}/policies) + +add_executable(slumber-quest ${SOURCES}) diff --git a/actors/actor.cpp b/actors/actor.cpp new file mode 100644 index 0000000..1615f50 --- /dev/null +++ b/actors/actor.cpp @@ -0,0 +1,7 @@ +#include "actor.h" + +Actor::Actor() +{} + +Actor::~Actor() +{} diff --git a/actors/actor.h b/actors/actor.h new file mode 100644 index 0000000..99075ed --- /dev/null +++ b/actors/actor.h @@ -0,0 +1,26 @@ +#ifndef ACTOR_H +#define ACTOR_H + +#include +#include + +class Location; +class Item; + +class Actor +{ +public: + explicit Actor(); + virtual ~Actor() = 0; + + virtual void commitAction() = 0; + virtual void moveToLocation(const std::shared_ptr& location) = 0; + virtual void giveItem(const std::shared_ptr& item) = 0; + virtual void useItem(const std::shared_ptr& item) = 0; + +protected: + std::shared_ptr _current_location; + std::list> _inventory; +}; + +#endif // ACTOR_H diff --git a/actors/player.cpp b/actors/player.cpp new file mode 100644 index 0000000..da18fec --- /dev/null +++ b/actors/player.cpp @@ -0,0 +1,80 @@ +#include +#include +#include + +#include "player.h" +#include "location.h" +#include "controller.h" +#include "item.h" + +Player::Player() +{} + +Player::~Player() +{} + +void Player::commitAction() +{ + std::cout << ">> "; + std::string input; + std::cin >> input; + std::cout << "\n"; + + std::transform(input.begin(), input.end(), input.begin(), + [](unsigned char c){ return std::tolower(c); }); + + if (input == "inventory") + { + std::cout << showInventory() << "\n\n"; + return; + } + + for (auto& controller : _current_location->controllers()) + { + if (controller->validateInput(input)) + { + std::shared_ptr player_as_actor = shared_from_this(); + std::cout << controller->interact(player_as_actor) << "\n\n"; + return; + } + } + + std::cout << "Nothing to do with that. Please think again." << "\n\n"; +} + +void Player::moveToLocation(const std::shared_ptr &location) +{ + _current_location = location; +} + +void Player::giveItem(const std::shared_ptr& item) +{ + item->setReceived(true); + _inventory.push_back(item); +} + +void Player::useItem(const std::shared_ptr& item) +{ + item->setReceived(false); + _inventory.remove(item); +} + +std::string Player::showInventory() const +{ + if (_inventory.empty()) + { + return "Your pockets are empty."; + } + + std::string inventory_message = "Currently you have "; + for (const auto& item : _inventory) + { + inventory_message += item->label(); + inventory_message += ", "; + } + inventory_message.pop_back(); + inventory_message.pop_back(); + inventory_message += "."; + + return inventory_message; +} diff --git a/actors/player.h b/actors/player.h new file mode 100644 index 0000000..0006afe --- /dev/null +++ b/actors/player.h @@ -0,0 +1,21 @@ +#ifndef PLAYER_H +#define PLAYER_H + +#include "actor.h" + +class Player : public Actor, public std::enable_shared_from_this +{ +public: + explicit Player(); + virtual ~Player() override; + + virtual void commitAction() override; + virtual void moveToLocation(const std::shared_ptr& location) override; + virtual void giveItem(const std::shared_ptr& item) override; + virtual void useItem(const std::shared_ptr& item) override; + +private: + std::string showInventory() const; +}; + +#endif // PLAYER_H diff --git a/controllers/controller.cpp b/controllers/controller.cpp new file mode 100644 index 0000000..42dd586 --- /dev/null +++ b/controllers/controller.cpp @@ -0,0 +1,46 @@ +#include "controller.h" +#include "policy.h" +#include + +Controller::Controller(Initializer&& initializer) : + _keywords(initializer.keywords), + _interaction_message(initializer.message) +{} + +Controller::~Controller() +{} + +bool Controller::validateInput(const std::string &input_word) const +{ + return std::find(_keywords.begin(), _keywords.end(), input_word) != _keywords.end(); +} + +void Controller::setValidationPolicies(const std::list>& policies) +{ + _validation_policies = policies; +} + +Controller::ValidationResult Controller::validatePolicies() const +{ + if (_validation_policies.empty()) + return {true, ""}; + + std::string interaction_output; + + bool success = true; + for (const auto& policy : _validation_policies) + { + const auto check_result = policy->check(); + interaction_output += (check_result.commentary + "\n\n"); + if (!check_result.satisfied) + { + success = false; + break; + } + } + + interaction_output.pop_back(); + interaction_output.pop_back(); + + return {success, interaction_output}; +} diff --git a/controllers/controller.h b/controllers/controller.h new file mode 100644 index 0000000..fa25edd --- /dev/null +++ b/controllers/controller.h @@ -0,0 +1,42 @@ +#ifndef CONTROLLER_H +#define CONTROLLER_H + +#include +#include +#include + +class Node; +class Actor; +class Policy; + +class Controller +{ +public: + struct Initializer + { + const std::list& keywords; + const std::string& message; + }; + + explicit Controller(Initializer&& initializer); + virtual ~Controller() = 0; + + virtual std::string interact(std::shared_ptr actor) = 0; + virtual bool validateInput(const std::string& input_word) const final; + virtual void setValidationPolicies(const std::list>& policies) final; + + struct ValidationResult + { + bool success = false; + std::string validation_output; + }; + +protected: + virtual ValidationResult validatePolicies() const final; + + std::list _keywords; + std::string _interaction_message; + std::list> _validation_policies; +}; + +#endif // CONTROLLER_H diff --git a/controllers/itemcontroller.cpp b/controllers/itemcontroller.cpp new file mode 100644 index 0000000..2d9034a --- /dev/null +++ b/controllers/itemcontroller.cpp @@ -0,0 +1,33 @@ +#include "itemcontroller.h" +#include "item.h" +#include "actor.h" +#include "policy.h" + +ItemController::ItemController(Initializer &&initializer) : + Controller(std::move(initializer)) +{} + +ItemController::~ItemController() +{} + +std::string ItemController::interact(std::shared_ptr actor) +{ + std::string interaction_output; + + const auto validation_result = validatePolicies(); + interaction_output += validation_result.validation_output; + + if (validation_result.success) + { + actor->giveItem(_item); + interaction_output += _interaction_message; + } + + return interaction_output; +} + +void ItemController::setDependentItem(const std::shared_ptr &item) +{ + _item = item; +} + diff --git a/controllers/itemcontroller.h b/controllers/itemcontroller.h new file mode 100644 index 0000000..417f970 --- /dev/null +++ b/controllers/itemcontroller.h @@ -0,0 +1,21 @@ +#ifndef ITEMCONTROLLER_H +#define ITEMCONTROLLER_H + +#include "controller.h" + +class Item; + +class ItemController : public Controller +{ +public: + explicit ItemController(Controller::Initializer&& initializer); + virtual ~ItemController() override; + + virtual std::string interact(std::shared_ptr actor) override; + void setDependentItem(const std::shared_ptr& item); + +private: + std::shared_ptr _item; +}; + +#endif // ITEMCONTROLLER_H diff --git a/controllers/locationcontroller.cpp b/controllers/locationcontroller.cpp new file mode 100644 index 0000000..ceee1d0 --- /dev/null +++ b/controllers/locationcontroller.cpp @@ -0,0 +1,34 @@ +#include "locationcontroller.h" +#include "location.h" +#include "policy.h" +#include "actor.h" + +LocationController::LocationController(Initializer &&initializer) : + Controller(std::move(initializer)) +{} + +LocationController::~LocationController() +{} + +std::string LocationController::interact(std::shared_ptr actor) +{ + std::string interaction_output; + + const auto validation_result = validatePolicies(); + interaction_output += validation_result.validation_output; + + if (validation_result.success) + { + actor->moveToLocation(_location); + + const std::string& node_interact_message = _location->interact(); + interaction_output += (_interaction_message + "\n\n" + node_interact_message); + } + + return interaction_output; +} + +void LocationController::setDependentLocation(const std::shared_ptr &location) +{ + _location = location; +} diff --git a/controllers/locationcontroller.h b/controllers/locationcontroller.h new file mode 100644 index 0000000..668c4c9 --- /dev/null +++ b/controllers/locationcontroller.h @@ -0,0 +1,21 @@ +#ifndef LOCATIONCONTROLLER_H +#define LOCATIONCONTROLLER_H + +#include "controller.h" + +class Location; + +class LocationController : public Controller +{ +public: + explicit LocationController(Controller::Initializer&& initializer); + virtual ~LocationController() override; + + virtual std::string interact(std::shared_ptr actor) override; + void setDependentLocation(const std::shared_ptr& location); + +private: + std::shared_ptr _location; +}; + +#endif // LOCATIONCONTROLLER_H diff --git a/entities/item.cpp b/entities/item.cpp new file mode 100644 index 0000000..5ff4cb3 --- /dev/null +++ b/entities/item.cpp @@ -0,0 +1,21 @@ +#include "item.h" + +Item::Item(const std::string &label) : + _label(label), + _is_received(false) +{} + +const std::string& Item::label() const +{ + return _label; +} + +bool Item::isReceived() const +{ + return _is_received; +} + +void Item::setReceived(bool received) +{ + _is_received = received; +} diff --git a/entities/item.h b/entities/item.h new file mode 100644 index 0000000..fc1d1b0 --- /dev/null +++ b/entities/item.h @@ -0,0 +1,20 @@ +#ifndef ITEM_H +#define ITEM_H + +#include + +class Item +{ +public: + explicit Item(const std::string& label); + + const std::string& label() const; + bool isReceived() const; + void setReceived(bool received); + +private: + std::string _label; + bool _is_received; +}; + +#endif // ITEM_H diff --git a/entities/location.cpp b/entities/location.cpp new file mode 100644 index 0000000..573edb7 --- /dev/null +++ b/entities/location.cpp @@ -0,0 +1,24 @@ +#include "location.h" +#include + +Location::Location(Initializer &&initializer) : + _interaction_message(initializer.message), + _interactive_controllers(initializer.interactive_controllers), + _is_visited(false) +{} + +const std::string& Location::interact() +{ + _is_visited = true; + return _interaction_message; +} + +const std::list>& Location::controllers() +{ + return _interactive_controllers; +} + +bool Location::isVisited() const +{ + return _is_visited; +} diff --git a/entities/location.h b/entities/location.h new file mode 100644 index 0000000..e97f26f --- /dev/null +++ b/entities/location.h @@ -0,0 +1,33 @@ +#ifndef LOCATION_H +#define LOCATION_H + +#include +#include +#include + +class Controller; + +class Location +{ +public: + struct Initializer + { + const std::string& message; + const std::list>& interactive_controllers; + }; + + explicit Location(Initializer &&initializer); + + virtual const std::string& interact(); + + const std::list>& controllers(); + bool isVisited() const; + +private: + std::string _interaction_message; + std::list> _interactive_controllers; + std::shared_ptr _current_user_location; + bool _is_visited; +}; + +#endif // LOCATION_H diff --git a/levelbuilder.cpp b/levelbuilder.cpp new file mode 100644 index 0000000..c87fb40 --- /dev/null +++ b/levelbuilder.cpp @@ -0,0 +1,7 @@ +#include "levelbuilder.h" + +LevelBuilder::LevelBuilder() +{} + +LevelBuilder::~LevelBuilder() +{} diff --git a/levelbuilder.h b/levelbuilder.h new file mode 100644 index 0000000..7f8edad --- /dev/null +++ b/levelbuilder.h @@ -0,0 +1,21 @@ +#ifndef LEVELBUILDER_H +#define LEVELBUILDER_H + +#include + +class Controller; + +class LevelBuilder +{ +public: + explicit LevelBuilder(); + virtual ~LevelBuilder() = 0; + + virtual void init() = 0; + virtual void save() = 0; + virtual void load() = 0; + + virtual const std::shared_ptr& getStartingController() const = 0; +}; + +#endif // LEVELBUILDER_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..3a8c4b6 --- /dev/null +++ b/main.cpp @@ -0,0 +1,20 @@ +#include + +#include "controller.h" +#include "player.h" +#include "sandboxlevelbuilder.h" + +int main() +{ + std::unique_ptr level_builder = std::make_unique(); + level_builder->init(); + + std::shared_ptr player = std::make_unique(); + const auto& starting_controller = level_builder->getStartingController(); + std::cout << starting_controller->interact(player) << "\n\n"; + + while (true) + { + player->commitAction(); + } +} diff --git a/policies/itemrequiredpolicy.cpp b/policies/itemrequiredpolicy.cpp new file mode 100644 index 0000000..0e92e58 --- /dev/null +++ b/policies/itemrequiredpolicy.cpp @@ -0,0 +1,20 @@ +#include "itemrequiredpolicy.h" +#include "item.h" + +ItemRequiredPolicy::ItemRequiredPolicy(const std::string& satisfaction, const std::string& dissatisfaction) : + Policy(satisfaction, dissatisfaction) +{} + +ItemRequiredPolicy::~ItemRequiredPolicy() +{} + +Policy::CheckResult ItemRequiredPolicy::check() const +{ + bool success = _item->isReceived(); + return composeMessageFromResult(success); +} + +void ItemRequiredPolicy::setRequiredItem(const std::shared_ptr &item) +{ + _item = item; +} diff --git a/policies/itemrequiredpolicy.h b/policies/itemrequiredpolicy.h new file mode 100644 index 0000000..3db6a53 --- /dev/null +++ b/policies/itemrequiredpolicy.h @@ -0,0 +1,23 @@ +#ifndef ITEMREQUIREDPOLICY_H +#define ITEMREQUIREDPOLICY_H + +#include +#include "policy.h" + +class Item; + +class ItemRequiredPolicy : public Policy +{ +public: + explicit ItemRequiredPolicy(const std::string& satisfaction, const std::string& dissatisfaction); + virtual ~ItemRequiredPolicy() override; + + virtual Policy::CheckResult check() const override; + + void setRequiredItem(const std::shared_ptr& item); + +private: + std::shared_ptr _item; +}; + +#endif // ITEMREQUIREDPOLICY_H diff --git a/policies/locationrequiredpolicy.cpp b/policies/locationrequiredpolicy.cpp new file mode 100644 index 0000000..db30462 --- /dev/null +++ b/policies/locationrequiredpolicy.cpp @@ -0,0 +1,20 @@ +#include "locationrequiredpolicy.h" +#include "location.h" + +LocationRequiredPolicy::LocationRequiredPolicy(const std::string& satisfaction, const std::string& dissatisfaction) : + Policy(satisfaction, dissatisfaction) +{} + +LocationRequiredPolicy::~LocationRequiredPolicy() +{} + +Policy::CheckResult LocationRequiredPolicy::check() const +{ + bool success = _location->isVisited(); + return composeMessageFromResult(success); +} + +void LocationRequiredPolicy::setRequiredLocation(const std::shared_ptr &location) +{ + _location = location; +} diff --git a/policies/locationrequiredpolicy.h b/policies/locationrequiredpolicy.h new file mode 100644 index 0000000..3950c56 --- /dev/null +++ b/policies/locationrequiredpolicy.h @@ -0,0 +1,23 @@ +#ifndef LOCATIONREQUIREDPOLICY_H +#define LOCATIONREQUIREDPOLICY_H + +#include +#include "policy.h" + +class Location; + +class LocationRequiredPolicy : public Policy +{ +public: + explicit LocationRequiredPolicy(const std::string& satisfaction, const std::string& dissatisfaction); + virtual ~LocationRequiredPolicy() override; + + virtual Policy::CheckResult check() const override; + + void setRequiredLocation(const std::shared_ptr& location); + +private: + std::shared_ptr _location; +}; + +#endif // LOCATIONREQUIREDPOLICY_H diff --git a/policies/policy.cpp b/policies/policy.cpp new file mode 100644 index 0000000..c5c2179 --- /dev/null +++ b/policies/policy.cpp @@ -0,0 +1,16 @@ +#include "policy.h" + +Policy::Policy(const std::string& satisfaction, const std::string& dissatisfaction) : + _commentary_on_satisfaction(satisfaction), + _commentary_on_dissatisfaction(dissatisfaction) +{} + +Policy::~Policy() +{} + +Policy::CheckResult Policy::composeMessageFromResult(bool result) const +{ + return {result, (result) + ? _commentary_on_satisfaction + : _commentary_on_dissatisfaction}; +} diff --git a/policies/policy.h b/policies/policy.h new file mode 100644 index 0000000..8539149 --- /dev/null +++ b/policies/policy.h @@ -0,0 +1,27 @@ +#ifndef POLICY_H +#define POLICY_H + +#include + +class Policy +{ +public: + explicit Policy(const std::string& satisfaction, const std::string& dissatisfaction); + virtual ~Policy() = 0; + + struct CheckResult + { + bool satisfied = false; + std::string commentary; + }; + + virtual CheckResult check() const = 0; + +protected: + virtual CheckResult composeMessageFromResult(bool result) const final; + + std::string _commentary_on_satisfaction; + std::string _commentary_on_dissatisfaction; +}; + +#endif // POLICY_H diff --git a/sandboxlevelbuilder.cpp b/sandboxlevelbuilder.cpp new file mode 100644 index 0000000..7735ba9 --- /dev/null +++ b/sandboxlevelbuilder.cpp @@ -0,0 +1,99 @@ +#include "sandboxlevelbuilder.h" +#include "location.h" +#include "item.h" +#include "locationcontroller.h" +#include "itemcontroller.h" +#include "itemrequiredpolicy.h" +#include + +SandboxLevelBuilder::SandboxLevelBuilder() +{} + +SandboxLevelBuilder::~SandboxLevelBuilder() +{} + +void SandboxLevelBuilder::init() +{ + // START GAME TRIGGER + Controller::Initializer the_first_and_only_trigger_init = {{}, "Hello! This is a test run."}; + std::shared_ptr the_first_and_only_trigger = std::make_shared(std::move(the_first_and_only_trigger_init)); + + // DOOR CONTROLLER + Controller::Initializer door_init = {{"door"}, "You successfully opened the door and entered the house."}; + std::shared_ptr door_cont = std::make_shared(std::move(door_init)); + + // TABLE CONTROLLER + Controller::Initializer table_init = {{"table"}, "You approached the table."}; + std::shared_ptr table_cont = std::make_shared(std::move(table_init)); + + // TENSHI CONTROLLER + Controller::Initializer tenshi_init = {{"tenshi", "card", "postcard"}, "You picked up cute postcard of tenshi eating corndog. Now you are happy."}; + std::shared_ptr tenshi_cont = std::make_shared(std::move(tenshi_init)); + + // COUCH CONTROLLER + Controller::Initializer couch_init = {{"couch", "sofa"}, "You approached the coach."}; + std::shared_ptr couch_cont = std::make_shared(std::move(couch_init)); + + // COACH FROM TABLE CONTROLLER + Controller::Initializer coach2_init = {{"coach", "sofa"}, "You slowly moved away from the table and approached the coach."}; + std::shared_ptr coach2_cont = std::make_shared(std::move(coach2_init)); + + // PLEROMAN CONTROLLER + Controller::Initializer pleroman_init = {{"pleroman"}, "You talk to a pleroma user! What a happy and carefree creature. He even brew you some cofe!"}; + std::shared_ptr pleroman_cont = std::make_shared(std::move(pleroman_init)); + std::shared_ptr need_tenshi_policy = std::make_shared("You give him the postcard of Tenshi.", "He doesn't want to talk to you. Make him trust you!!"); + pleroman_cont->setValidationPolicies({need_tenshi_policy}); + + // START LOCATION + auto&& init_msg = "You are now in a staring location. There is a door leading to a house. Typical text quest situation. To interact with something, type it as noun."; + Location::Initializer init = {init_msg, {door_cont}}; + std::shared_ptr start = std::make_shared(std::move(init)); + + // ROOM LOCATION + auto&& room_msg = "This is an old room. You can see only a rusty table and a coach. Also there is a pleroma user standing still."; + Location::Initializer roomloc_init = {room_msg, {table_cont, couch_cont, pleroman_cont}}; + std::shared_ptr room = std::make_shared(std::move(roomloc_init)); + + // TABLE LOCATION + auto&& table_msg = "Boring table. There is a flashy postcard on it."; + Location::Initializer tableloc_init = {table_msg, {coach2_cont, tenshi_cont, pleroman_cont}}; + std::shared_ptr table = std::make_shared(std::move(tableloc_init)); + + // COUCH LOCATION + auto&& couch_msg = "Looks like the coach was comfy... several years ago. Now probably it only feeds roaches. Better not touch it."; + Location::Initializer couchloc_init = {couch_msg, {table_cont, pleroman_cont}}; + std::shared_ptr couch = std::make_shared(std::move(couchloc_init)); + + // PLEROMAN LOCATION + auto&& pleroman_msg = ". . . \n\n From the conversation you find out the quest is still in a very raw test state, the engine isn't even finished... Alright, just terminate the game process."; + Location::Initializer pleromanloc_init = {pleroman_msg, {}}; + std::shared_ptr pleroman = std::make_shared(std::move(pleromanloc_init)); + + std::shared_ptr tenshi = std::make_shared("Postcard of Tenshi eating corndog"); + need_tenshi_policy->setRequiredItem(tenshi); + + the_first_and_only_trigger->setDependentLocation(start); + door_cont->setDependentLocation(room); + table_cont->setDependentLocation(table); + couch_cont->setDependentLocation(couch); + coach2_cont->setDependentLocation(couch); + pleroman_cont->setDependentLocation(pleroman); + tenshi_cont->setDependentItem(tenshi); + + _starting_controller = the_first_and_only_trigger; +} + +void SandboxLevelBuilder::save() +{ + std::cerr << "SandboxLevelBuilder::save : Not implemented!"; +} + +void SandboxLevelBuilder::load() +{ + std::cerr << "SandboxLevelBuilder::load : Not implemented!"; +} + +const std::shared_ptr &SandboxLevelBuilder::getStartingController() const +{ + return _starting_controller; +} diff --git a/sandboxlevelbuilder.h b/sandboxlevelbuilder.h new file mode 100644 index 0000000..85218b6 --- /dev/null +++ b/sandboxlevelbuilder.h @@ -0,0 +1,22 @@ +#ifndef SANDBOXLEVELBUILDER_H +#define SANDBOXLEVELBUILDER_H + +#include "levelbuilder.h" + +class SandboxLevelBuilder : public LevelBuilder +{ +public: + explicit SandboxLevelBuilder(); + virtual ~SandboxLevelBuilder() override; + + virtual void init() override; + virtual void save() override; + virtual void load() override; + + virtual const std::shared_ptr& getStartingController() const override; + +private: + std::shared_ptr _starting_controller; +}; + +#endif // SANDBOXLEVELBUILDER_H