HoverRace  2.0
Classes | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
HoverRace::Client::Rulebook Class Reference

Defines the rules for a particular game session. More...

#include <Rulebook.h>

Classes

struct  metas_t
 

Public Member Functions

 Rulebook (Script::Core &scripting, const Util::OS::path_t &basePath)
 
 Rulebook (const Rulebook &)=delete
 
 ~Rulebook ()
 
void AddRule (const std::string &name, const luabind::object &obj)
 
luabind::object CreateDefaultRules () const
 
const Util::OS::path_tGetBasePath () const
 
const std::string & GetDescription () const
 
int GetMaxPlayers () const
 
const metas_tGetMetas () const
 
const std::string & GetName () const
 
const std::string & GetTitle () const
 
void Load () const
 Ensure that the rulebook is fully-loaded. More...
 
bool LoadMetadata ()
 Load just enough of the rulebook to retrieve the metadata (title, etc.). More...
 
Rulebookoperator= (const Rulebook &)=delete
 
void SetMetadata (const std::string &name, const std::string &title, const std::string &description, int maxPlayers)
 
void SetOnLoad (const luabind::object &fn)
 

Protected Member Functions

void OnLoad () const
 

Private Attributes

Util::OS::path_t basePath
 
std::string defaultName
 
std::string description
 
std::shared_ptr< HoverScript::RulebookEnvenv
 
bool loaded
 
int maxPlayers
 
metas_t metas
 
std::string name
 
Script::RegistryRef onLoad
 
std::map< std::string, std::shared_ptr< Rule > > rules
 
Script::Corescripting
 
std::string title
 

Friends

bool operator< (const Rulebook &lhs, const Rulebook &rhs)
 
bool operator== (const Rulebook &lhs, const Rulebook &rhs)
 

Detailed Description

Defines the rules for a particular game session.

Author
Michael Imamura

Constructor & Destructor Documentation

HoverRace::Client::Rulebook::Rulebook ( Script::Core scripting,
const Util::OS::path_t basePath 
)
HoverRace::Client::Rulebook::Rulebook ( const Rulebook )
delete
HoverRace::Client::Rulebook::~Rulebook ( )
inline

Member Function Documentation

void HoverRace::Client::Rulebook::AddRule ( const std::string &  name,
const luabind::object &  obj 
)
luabind::object HoverRace::Client::Rulebook::CreateDefaultRules ( ) const
const Util::OS::path_t& HoverRace::Client::Rulebook::GetBasePath ( ) const
inline
const std::string& HoverRace::Client::Rulebook::GetDescription ( ) const
inline
int HoverRace::Client::Rulebook::GetMaxPlayers ( ) const
inline
const metas_t& HoverRace::Client::Rulebook::GetMetas ( ) const
inline
const std::string& HoverRace::Client::Rulebook::GetName ( ) const
inline
const std::string& HoverRace::Client::Rulebook::GetTitle ( ) const
inline
void HoverRace::Client::Rulebook::Load ( ) const

Ensure that the rulebook is fully-loaded.

Initially, the rulebook is only partially loaded for speed. This function must be called before a game session starts.

bool HoverRace::Client::Rulebook::LoadMetadata ( )

Load just enough of the rulebook to retrieve the metadata (title, etc.).

In practice, this just runs the "bootstrap" script in the rulebook directory. If an error occurred while running the script, then this rulebook's metadata will be reset to their default values.

Returns
true If the rulebook loaded successfully, false otherwise.
void HoverRace::Client::Rulebook::OnLoad ( ) const
protected
Rulebook& HoverRace::Client::Rulebook::operator= ( const Rulebook )
delete
void HoverRace::Client::Rulebook::SetMetadata ( const std::string &  name,
const std::string &  title,
const std::string &  description,
int  maxPlayers 
)
inline
void HoverRace::Client::Rulebook::SetOnLoad ( const luabind::object &  fn)

Friends And Related Function Documentation

bool operator< ( const Rulebook lhs,
const Rulebook rhs 
)
friend
bool operator== ( const Rulebook lhs,
const Rulebook rhs 
)
friend

Member Data Documentation

Util::OS::path_t HoverRace::Client::Rulebook::basePath
private
std::string HoverRace::Client::Rulebook::defaultName
private
std::string HoverRace::Client::Rulebook::description
private
std::shared_ptr<HoverScript::RulebookEnv> HoverRace::Client::Rulebook::env
private
bool HoverRace::Client::Rulebook::loaded
mutableprivate
int HoverRace::Client::Rulebook::maxPlayers
private
metas_t HoverRace::Client::Rulebook::metas
mutableprivate
std::string HoverRace::Client::Rulebook::name
private
Script::RegistryRef HoverRace::Client::Rulebook::onLoad
private
std::map<std::string, std::shared_ptr<Rule> > HoverRace::Client::Rulebook::rules
private
Script::Core& HoverRace::Client::Rulebook::scripting
private
std::string HoverRace::Client::Rulebook::title
private

The documentation for this class was generated from the following files: