107 lines
5.3 KiB
C++
107 lines
5.3 KiB
C++
#include "sandboxlevelbuilder.h"
|
|
#include "location.h"
|
|
#include "item.h"
|
|
#include "locationcontroller.h"
|
|
#include "itemcontroller.h"
|
|
#include "itemrequiredpolicy.h"
|
|
#include "allpoliciesvalidator.h"
|
|
#include "removecontrollersmodificator.h"
|
|
#include <iostream>
|
|
|
|
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<LocationController> the_first_and_only_trigger = std::make_shared<LocationController>(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<LocationController> door_cont = std::make_shared<LocationController>(std::move(door_init));
|
|
|
|
// TABLE CONTROLLER
|
|
Controller::Initializer table_init = {{"table"}, "You approached the table."};
|
|
std::shared_ptr<LocationController> table_cont = std::make_shared<LocationController>(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<ItemController> tenshi_cont = std::make_shared<ItemController>(std::move(tenshi_init));
|
|
|
|
// COUCH CONTROLLER
|
|
Controller::Initializer couch_init = {{"couch", "sofa"}, "You approached the coach."};
|
|
std::shared_ptr<LocationController> couch_cont = std::make_shared<LocationController>(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<LocationController> coach2_cont = std::make_shared<LocationController>(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<LocationController> pleroman_cont = std::make_shared<LocationController>(std::move(pleroman_init));
|
|
std::shared_ptr<ItemRequiredPolicy> need_tenshi_policy = std::make_shared<ItemRequiredPolicy>("You give him the postcard of Tenshi.", "He doesn't want to talk to you. Make him trust you!!");
|
|
std::shared_ptr<AllPoliciesValidator> pleroman_validator = std::make_shared<AllPoliciesValidator>(std::list<std::shared_ptr<Policy>>{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<Location> start = std::make_shared<Location>(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<Location> room = std::make_shared<Location>(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<Location> table = std::make_shared<Location>(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<Location> couch = std::make_shared<Location>(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<Location> pleroman = std::make_shared<Location>(std::move(pleromanloc_init));
|
|
|
|
std::shared_ptr<Item> tenshi = std::make_shared<Item>("Postcard of Tenshi eating corndog");
|
|
need_tenshi_policy->setRequiredItem(tenshi);
|
|
|
|
std::shared_ptr<RemoveControllersModificator> remove_tenshi_modif = std::make_shared<RemoveControllersModificator>();
|
|
remove_tenshi_modif->setDependentObjects(table, {tenshi_cont}, "Boring table.");
|
|
tenshi_cont->setModificators({remove_tenshi_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<Controller> &SandboxLevelBuilder::getStartingController() const
|
|
{
|
|
return _starting_controller;
|
|
}
|