#include "sandboxlevelbuilder.h" #include "location.h" #include "item.h" #include "locationcontroller.h" #include "itemcontroller.h" #include "itemrequiredpolicy.h" #include "readyitemrequiredpolicy.h" #include "allpoliciesvalidator.h" #include "removecontrollersmodificator.h" #include "changeinteractionmessagemodificator.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!!"); std::shared_ptr pleroman_validator = std::make_shared(std::list>{need_tenshi_policy}); pleroman_cont->setValidator(pleroman_validator); // 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, {table_cont, couch_cont}}; std::shared_ptr pleroman = std::make_shared(std::move(pleromanloc_init)); // TENSHI POSTCARD ITEM std::shared_ptr tenshi = std::make_shared("postcard of tenshi eating corndog"); need_tenshi_policy->setRequiredReadyItem(tenshi); // WHAT HAPPENS WHEN YOU PICK TENSHI std::shared_ptr remove_tenshi_modif = std::make_shared(); remove_tenshi_modif->setDependentObjects(table, {tenshi_cont}); std::shared_ptr change_table_desc_modif = std::make_shared(); change_table_desc_modif->setDependentObjects(table, "Boring table."); tenshi_cont->setModificators({remove_tenshi_modif, change_table_desc_modif}); std::shared_ptr change_pleroman_desc_modif = std::make_shared(); change_pleroman_desc_modif->setDependentObjects(pleroman, "He is happy."); pleroman_cont->setModificators({change_pleroman_desc_modif}); 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; }