00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef INPUT_HH_
00018 # define INPUT_HH_
00019
00020 class Api;
00021 class CmdLineInterface;
00022
00027 class Input
00028 {
00029 public:
00030 Input(CmdLineInterface* i, Api* gc, bool use_readline);
00031 ~Input();
00032
00036 bool process();
00037
00040 void processCommand(const std::string& s);
00041
00043 void wantExit();
00044
00046 void stopWaiting();
00047
00048 public:
00049
00050 struct InputCommand
00051 {
00052 const char* name;
00053 void (Input::*fun)(const std::string&, const std::string&);
00054 const char* doc;
00055 };
00056
00057 struct InputSubCommand
00058 {
00059 const char* name;
00060 void (Input::*fun)(const std::string&);
00061 const char* doc;
00062 };
00063
00064 static InputCommand main_cmd_[];
00065 static InputSubCommand print_cmd_[];
00066 static InputSubCommand move_cmd_[];
00067 static InputSubCommand choose_cmd_[];
00068 static InputSubCommand place_cmd_[];
00069 static InputSubCommand block_cmd_[];
00070 static InputSubCommand skill_cmd_[];
00071 static InputSubCommand declare_cmd_[];
00072
00073 private:
00074
00075
00076 void cmdQuit(const std::string& cmd, const std::string& args);
00077 void cmdHelp(const std::string& cmd, const std::string& args);
00078 void cmdPrint(const std::string& cmd, const std::string& args);
00079 void cmdSay(const std::string& cmd, const std::string& args);
00080 void cmdChoose(const std::string& cmd, const std::string& args);
00081 void cmdPlace(const std::string& cmd, const std::string& args);
00082 void cmdKickOff(const std::string& cmd, const std::string& args);
00083 void cmdIllegal(const std::string& cmd, const std::string& args);
00084 void cmdEnd(const std::string& cmd, const std::string& args);
00085 void cmdReroll(const std::string& cmd, const std::string& args);
00086 void cmdSkill(const std::string& cmd, const std::string& args);
00087 void cmdAccept(const std::string& cmd, const std::string& args);
00088 void cmdGiveBall(const std::string& cmd, const std::string& args);
00089 void cmdCheat(const std::string& cmd, const std::string& args);
00090 void cmdWait(const std::string& cmd, const std::string& args);
00091
00092
00093 void cmdDeclare(const std::string& cmd, const std::string& args);
00094 void cmdMove(const std::string& cmd, const std::string& args);
00095 void cmdStandUp(const std::string& cmd, const std::string& args);
00096 void cmdBlock(const std::string& cmd, const std::string& args);
00097 void cmdPass(const std::string& cmd, const std::string& args);
00098
00099
00100 void cmdPrintGlobal(const std::string& args);
00101 void cmdPrintField(const std::string& args);
00102 void cmdPrintPlayers(const std::string& args);
00103 void cmdPrintUs(const std::string& args);
00104 void cmdPrintThem(const std::string& args);
00105 void cmdPrintString(const std::string& args);
00106
00107
00108 void cmdChooseKickoff(const std::string& args);
00109 void cmdChooseReceive(const std::string& args);
00110
00111
00112 void cmdPlaceField(const std::string& args);
00113 void cmdPlaceReserve(const std::string& args);
00114 void cmdEndPlacement(const std::string& args);
00115
00116
00117 void cmdMoveTurnMarker(const std::string& args);
00118 void cmdMovePlayer(const std::string& args);
00119
00120
00121 void cmdBlockBlock(const std::string& args);
00122 void cmdBlockDice(const std::string& args);
00123 void cmdBlockStay(const std::string& args);
00124 void cmdBlockFollow(const std::string& args);
00125 void cmdBlockPush(const std::string& args);
00126
00127
00128 void cmdUseSkill(const std::string& args);
00129 void cmdIgnoreSkill(const std::string& args);
00130
00131 void applyCmdSkill(bool useIt, const std::string& args);
00132
00133
00134 void cmdDeclareMove(const std::string& args);
00135 void cmdDeclareBlock(const std::string& args);
00136 void cmdDeclareBlitz(const std::string& args);
00137 void cmdDeclarePass(const std::string& args);
00138
00139 Api* api_;
00140 CmdLineInterface* i_;
00141 bool want_exit_;
00142 bool cmd_processed_;
00143 int wait_;
00144 bool use_readline_;
00145
00146
00147 std::string cmd_;
00148 int read_size_;
00149 int read_index_;
00150 char buf_[1024];
00151 };
00152
00153 #endif