00001 #ifndef HEADER_SCHEMAGAMEUTILITY 00002 #define HEADER_SCHEMAGAMEUTILITY 00003 00010 #include <sys/stat.h> 00011 #include <dirent.h> 00012 #include <stdio.h> 00013 #include <math.h> 00014 #include <string.h> 00015 #include <stdbool.h> 00016 #include <malloc.h> 00017 #include <time.h> 00018 #include <stdlib.h> 00019 #include <limits.h> 00020 #include <assert.h> 00021 #include "define.h" 00022 #include "gameIOManager.h" 00023 #include "bestroute.h" 00024 00025 00026 /* Start interface of schemaGameUtility module */ 00027 00029 static const unsigned short int START_LEVEL = 1; 00031 static const unsigned short int START_TOTAL_POINTS = 0; 00033 static const unsigned short int START_ROUND_NUMBER = 1; 00034 00035 00037 struct stateOfGame{ 00038 00040 unsigned int currentRow; 00041 00043 unsigned int currentCol; 00044 00046 unsigned int bestrouteweight; 00047 00049 unsigned int iters; 00050 00052 unsigned short int currentlevel; 00053 00055 unsigned int totalpoints; 00056 00058 unsigned long starttime; 00059 00061 bool playing; 00062 00064 unsigned short int numOfRound; 00065 }; 00066 00067 00068 /* Definition of the type currentGameState.*/ 00069 typedef struct stateOfGame currentGameState; 00070 00074 currentGameState initializeCurrentGameState(); 00075 00081 double newgame( char schemafilename[], 00082 unsigned int *bestrouteweight 00083 ); 00084 00090 bool checkRowColValues( unsigned short int *errnum, 00091 char *err 00092 ); 00093 00099 void setSchemaDataStructures( char **schema_propr 00100 ); 00101 00105 void checkDoorStartPoint( unsigned short int *errnum, 00106 char *err 00107 ); 00108 00115 unsigned short int loadCheckGame( char *file_name 00117 ); 00118 00119 00123 unsigned int getdoors( unsigned int *doorsRow, 00124 unsigned int *doorsCol 00126 ); 00127 00128 00133 bool isDirectory( char const *path 00134 ); 00135 00136 00141 char *get_schema_name( unsigned short int level 00142 ); 00143 00144 00160 bool isallowedchar(unsigned short int typeCharSel , 00161 char char2check 00162 ); 00163 00168 inline unsigned int countDigits( unsigned int number 00169 ); 00170 00171 00177 bool check_if_text_is_number( const bool runme, 00178 const char *text, 00179 char *err_buff, 00180 const char *err_label 00182 ); 00183 00188 unsigned int calcSchemaResults( char *labeltxt, 00189 currentGameState gameState 00190 ); 00191 00192 /* End interface of schemaGameUtility module */ 00193 00194 #endif