2021-05-07 21:36:26 -04:00
# include "sandboxlevelbuilder.h"
# include "location.h"
# include "item.h"
# include "locationcontroller.h"
# include "itemcontroller.h"
# include "itemrequiredpolicy.h"
2021-05-16 11:20:57 -04:00
# include "readyitemrequiredpolicy.h"
2021-05-15 19:44:19 -04:00
# include "allpoliciesvalidator.h"
# include "removecontrollersmodificator.h"
2021-05-16 11:20:57 -04:00
# include "changeinteractionmessagemodificator.h"
2021-05-07 21:36:26 -04:00
# 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 ) ) ;
2021-05-16 11:20:57 -04:00
std : : shared_ptr < ReadyItemRequiredPolicy > need_tenshi_policy = std : : make_shared < ReadyItemRequiredPolicy > ( " You give him the postcard of Tenshi. " , " He doesn't want to talk to you. Make him trust you!! " ) ;
2021-05-15 19:44:19 -04:00
std : : shared_ptr < AllPoliciesValidator > pleroman_validator = std : : make_shared < AllPoliciesValidator > ( std : : list < std : : shared_ptr < Policy > > { need_tenshi_policy } ) ;
pleroman_cont - > setValidator ( pleroman_validator ) ;
2021-05-07 21:36:26 -04:00
// 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. " ;
2021-05-16 11:20:57 -04:00
Location : : Initializer pleromanloc_init = { pleroman_msg , { table_cont , couch_cont } } ;
2021-05-07 21:36:26 -04:00
std : : shared_ptr < Location > pleroman = std : : make_shared < Location > ( std : : move ( pleromanloc_init ) ) ;
2021-05-16 11:20:57 -04:00
// TENSHI POSTCARD ITEM
std : : shared_ptr < Item > tenshi = std : : make_shared < Item > ( " postcard of tenshi eating corndog " ) ;
need_tenshi_policy - > setRequiredReadyItem ( tenshi ) ;
2021-05-07 21:36:26 -04:00
2021-05-16 11:20:57 -04:00
// WHAT HAPPENS WHEN YOU PICK TENSHI
2021-05-15 19:44:19 -04:00
std : : shared_ptr < RemoveControllersModificator > remove_tenshi_modif = std : : make_shared < RemoveControllersModificator > ( ) ;
2021-05-16 11:20:57 -04:00
remove_tenshi_modif - > setDependentObjects ( table , { tenshi_cont } ) ;
std : : shared_ptr < ChangeInteractionMessageModificator > change_table_desc_modif = std : : make_shared < ChangeInteractionMessageModificator > ( ) ;
change_table_desc_modif - > setDependentObjects ( table , " Boring table. " ) ;
tenshi_cont - > setModificators ( { remove_tenshi_modif , change_table_desc_modif } ) ;
std : : shared_ptr < ChangeInteractionMessageModificator > change_pleroman_desc_modif = std : : make_shared < ChangeInteractionMessageModificator > ( ) ;
change_pleroman_desc_modif - > setDependentObjects ( pleroman , " He is happy. " ) ;
pleroman_cont - > setModificators ( { change_pleroman_desc_modif } ) ;
2021-05-15 19:44:19 -04:00
2021-05-07 21:36:26 -04:00
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 ;
}