LuaRules.hh

00001 /*
00002 ** TowBowlTactics, a turn-based strategy football game.
00003 **
00004 ** Copyright (C) 2009-2010 The TBT Team.
00005 **
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 **
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 **
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
00015 */
00016 
00017 #ifndef LUARULES_HH_
00018 # define LUARULES_HH_
00019 
00020 # include "rules/PacketSender.hh"
00021 # include "rules/BaseRules.hh"
00022 # include "rules/BaseCRules.hh"
00023 # include "rules/BaseSRules.hh"
00024 # include "Lua.hh"
00025 
00026 namespace lua {
00027 
00028 class BaseRules : protected PacketSender
00029 {
00030 public:
00031   BaseRules(lua_State* l);
00032   int SetPacketSender(lua_State* l);
00033   int HandlePacket(lua_State* l);
00034 
00035   // required by Luna
00036   static const char className[];
00037   static Luna<BaseRules>::RegType methods[];
00038 
00039 protected:
00040   void init(::BaseRules* r);
00041   lua_State* l_;
00042 
00043 private:
00044   ::BaseRules* r_;
00045   virtual void sendPacket(const Packet& p) {}
00046 };
00047 
00048 class BaseCRules : public BaseRules
00049 {
00050 public:
00051   BaseCRules(lua_State* l) : BaseRules(l) {}
00052   int GetCoachId(lua_State* l);
00053   int GetApi(lua_State* l);
00054 
00055   // required by Luna
00056   static const char className[];
00057   static Luna<BaseCRules>::RegType methods[];
00058 
00059 protected:
00060   void init(::BaseCRules* r);
00061 
00062 private:
00063   ::BaseCRules* r_;
00064   virtual void sendPacket(const Packet& p);
00065 };
00066 
00067 class BaseSRules : public BaseRules
00068 {
00069 public:
00070   BaseSRules(lua_State* l);
00071   int ServerStartup(lua_State* l);
00072   int ServerProcess(lua_State* l);
00073 
00074   // required by Luna
00075   static const char className[];
00076   static Luna<BaseSRules>::RegType methods[];
00077 
00078 protected:
00079   void init(::BaseSRules* r);
00080 
00081 private:
00082   ::BaseSRules* r_;
00083   void sendPacket(const Packet& p);
00084 };
00085 
00086 }
00087 
00088 #endif // LUARULES_HH_
Generated on Mon Apr 5 21:17:12 2010 for Stechec/TBT by  doxygen 1.6.3