PFC/Omweso/src/ow_game.h

00001 /***************************************************************************
00002  *   Copyright (C) 2007 by David Torres   *
00003  *   aiken669@gmail.com   *
00004  ***************************************************************************/
00005 #ifndef OW_GAME_H
00006 #define OW_GAME_H
00007 
00008 #include <readline/readline.h>
00009 #include <SDL/SDL_ttf.h>
00010 #include <string>
00011 #include <fstream>
00012 #include "omweso.h"
00013 #include "ow_player.h"
00014 
00015 using namespace std;
00016 
00017 typedef struct {
00018      string name;
00019      string param1;
00020      string param2;
00021 } parsed_command;
00022 
00023 typedef struct {
00024      int turn;
00025      ow_player *player;
00026      parsed_command stepcommand;
00027 } logm_step;
00028 
00029 typedef struct {
00030      string p1name;
00031      string p1aimode;
00032      string p1aidepth;
00033      string p1aieval;
00034      string p2name;
00035      string p2aimode;
00036      string p2aidepth;
00037      string p2aieval;
00038      int numcols;
00039      string fturn_player;
00040      int turn;
00041      string plays;
00042      string gfxboard;
00043 } game_configuration;
00044 
00048 class ow_game{
00049 private:
00050      game_configuration config;
00051      int status;
00052      int current_turn;
00053      int current_menu;
00054      int queue_pos; int queue_last;
00055      int gfxboard_hidden;
00056      int gfxboard_dataloaded;
00057      SDL_Surface *gfxboard_screen;
00058   SDL_Surface *gfxdata[2];
00059      TTF_Font *font;
00060      ow_player *p1;
00061      ow_player *p2;
00062      ow_board *owtab;
00063      ow_player *selected_player;
00064      rl_vcpfunc_t *commandline_handler;
00065      rl_vcpfunc_t *commandline_handler_null;
00066      rl_completion_func_t *commandline_completion_handler;
00067      rl_compentry_func_t *commandline_command_generator_handler;
00068      rl_compignore_func_t *commandline_savegames_filter_handler;
00069 
00070      logm_step logmoves[BRD_MAX_UNDO_MOVES];
00071      int logmovescurrent, logmovescount;
00072      void logmove(int turn, ow_player *player, int boardside, int cellx, int celly);
00073      void logrcapture(int turn, ow_player *player, int boardside, int cellx, int celly);
00074      int ow_commandline_showlogmoves(parsed_command *pcommand);
00075 
00076      string logresults;
00077      string logresultsfile;
00078      int loggameresults();
00079      int ow_commandline_setlogresults(parsed_command *pcommand);
00080 
00081      int undolastmove(int nummoves);
00082      int redolastundo(int nummoves);
00083 
00084      void commandline_parse_command(char *command, parsed_command *pcommand);
00085      void ow_commandline_getpromptstring(char *prompt);
00086      void ow_commandline_refreshprompt();
00087      int ow_commandline_newgame(parsed_command *pcommand);
00088      int ow_commandline_loadgame(parsed_command *pcommand);
00089      int ow_commandline_savegame(parsed_command *pcommand);
00090      int ow_commandline_setupboard(parsed_command *pcommand);
00091      int ow_commandline_setupboard_confirm(parsed_command *pcommand);
00092      int ow_commandline_setupboard_cancel(parsed_command *pcommand);
00093      int ow_commandline_endgame(parsed_command *pcommand);
00094      void ow_commandline_version(parsed_command *pcommand);
00095      int ow_commandline_quit(parsed_command *pcommand);
00096      void ow_commandline_help(parsed_command *pcommand);
00097      int ow_commandline_play(parsed_command *pcommand);
00098      int ow_commandline_batch(parsed_command *pcommand);
00099      int ow_commandline_setbatch(parsed_command *pcommand);
00100      void ow_commandline_showtxtboard(parsed_command *pcommand);
00101      int ow_commandline_setvalue(parsed_command *pcommand);
00102      int ow_commandline_setnextturn(string variablename, string playerIDstr);
00103      int ow_commandline_setnumcols(string numcols);
00104      int ow_commandline_setplayer_aimode(string player_ai, string aimode);
00105      int ow_commandline_setplayer_aidepth(string player_ai, string aidepth);
00106      int ow_commandline_setplayer_aieval(string player_ai, string aieval);
00107      int ow_commandline_setgfxboard_status(string gfxstatus);
00108      int ow_commandline_creategame(parsed_command *pcommand);
00109      void ow_commandline_setcommand_help(parsed_command *pcommand);
00110      int ow_commandline_move(parsed_command *pcommand);
00111      int ow_commandline_rcapture(parsed_command *pcommand);
00112      int ow_commandline_manageai(parsed_command *pcommand);
00113      int ow_commandline_mainmenu(parsed_command *pcommand);
00114      cellXY ow_commandline_translate_name2coord(string cellname);
00115      void createnewgame_useconfig();
00116      void set_default_gameconfig(game_configuration *config);
00117      int loadgame(string filename);
00118      int savegame(string filename);
00119      int setupboard_fromarray(int arraydata[BRD_MAX_COLS_PER_PLAYER][(BRD_MAX_ROWS_PER_PLAYER*BRD_NUM_SIDES)]);
00120      void setnewturn(ow_player *player);
00121      void setfirstturn(ow_player *player);
00122   int load_gfxdata();
00123      int gfxboard_showhidde();
00124      void draw();
00125      void endgame();
00126      void exitomweso();
00127      int ow_commandline_undolastmove(parsed_command *pcommand);
00128      int ow_commandline_redolastmove(parsed_command *pcommand);
00129      int ow_commandline_undolastturn(parsed_command *pcommand);
00130 
00131 
00132 public:
00133 
00134      ow_game();
00135      void ow_setcommandlinehandlers(rl_vcpfunc_t *commhandler,rl_vcpfunc_t *commhandler_null, rl_completion_func_t *commhandler_completion,rl_compentry_func_t *commhandler_command,rl_compignore_func_t *commhandler_savegames_filter);
00136      char **commandline_completion(const char *text, int start, int end);
00137      char *commandline_command_generator(const char *text, int state);
00138      int commandline_savegames_filter(char **matches);
00139      void commandline_read();
00140      void commandline_parse_execute(char *command);
00141      string ow_commandline_translate_coord2name(int boardside, int cellx, int celly);
00142      int ow_commandline_setupboard_put(parsed_command *pcommand);
00143      int ow_commandline_setupboard_take(parsed_command *pcommand);
00144      void ow_commandline_showgameconfig(parsed_command *pcommand);
00145 
00146      int getnewgame_fromqueue();
00147      int selplayer_getboardside();
00148      int selplayer_makemovement(int boardside, int cellx, int celly);
00149      int selplayer_rcapture(int boardside, int cellx, int celly);
00150      int selplayer_getaimode();
00151      int selplayer_aimove_found();
00152      ow_move selplayer_aimove();
00153      int selplayer_endofturn();
00154 
00155      int board_endofturn();
00156      void board_update_status();
00157      string board_translate_coord2name(int boardside, int cellx, int celly);
00158 
00159      void changeturn();
00160      int gamerunning();
00161      int gamecreated();
00162      int gameplaying();
00163      int gamesettingup();
00164      void rungame();
00165      int checkgamewon();
00166 
00167      void show_version();
00168      void draw_gfx();
00169      int MouseLeftButtonClicked(int *mouse_x, int *mouse_y);
00170      int MouseRightButtonClicked(int *mouse_x, int *mouse_y);
00171      ow_move seleccionarcelda_bycoord(int coordx, int coordy);
00172 
00173      ~ow_game();
00174 
00175 };
00176 
00177 #endif

Generated on Sun Jun 22 13:45:47 2008 for Omweso by  doxygen 1.5.3