HoverRace  2.0
RulebookEnv.h
Go to the documentation of this file.
1 
2 // RulebookEnv.h
3 //
4 // Copyright (c) 2013, 2014, 2016 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "../../engine/Script/RegistryRef.h"
25 
26 #include "RuntimeEnv.h"
27 
28 namespace HoverRace {
29  namespace Client {
30  class Rulebook;
31  namespace HoverScript {
32  class GamePeer;
33  }
34  }
35  namespace Script {
36  class Core;
37  }
38 }
39 
40 namespace HoverRace {
41 namespace Client {
42 namespace HoverScript {
43 
48 class RulebookEnv : public RuntimeEnv {
49  using SUPER = RuntimeEnv;
50 
51 public:
52  RulebookEnv(Script::Core &scripting, const Util::OS::path_t &basePath,
53  Rulebook &rulebook);
54  virtual ~RulebookEnv();
55 
56 protected:
57  virtual void InitEnv();
58  void InitCFn(const char *name, lua_CFunction fn);
59 
60 public:
61  void DefineRulebook(const std::string &name, const luabind::object &defn);
62 private:
63  void DefineRules(const luabind::object &rulesObj);
64 public:
65  bool RunRulebookScript();
66 
67 private:
68  static int GenerateSubclass(lua_State *L, const std::string &base,
69  const std::string &name);
70 
71 public:
72  static int LPlayer(lua_State *L);
73  static int LRequire(lua_State *L);
74  static int LRulebookStage1(lua_State *L);
75  static int LRulebookStage2(lua_State *L);
76  static int LSession(lua_State *L);
77 
78 private:
82 };
83 
84 } // namespace HoverScript
85 } // namespace Client
86 } // namespace HoverRace
boost::filesystem::path path_t
Definition: OS.h:57
Script::RegistryRef requireCache
Definition: RulebookEnv.h:81
Basic restricted environment for potentially untrusted code.
Definition: RuntimeEnv.h:40
Encapsulates a ref to the registry.
Definition: RegistryRef.h:50
Limited environment for defining rulebooks.
Definition: RulebookEnv.h:48
Util::OS::path_t basePath
Definition: RulebookEnv.h:79
Rulebook & rulebook
Definition: RulebookEnv.h:80
Definition: Announcement.h:24
Defines the rules for a particular game session.
Definition: Rulebook.h:57
A script environment.
Definition: Core.h:66