#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <malloc.h>
#include <time.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
#include "define.h"
#include "gameIOManager.h"
#include "bestroute.h"

Go to the source code of this file.
Data Structures | |
| struct | stateOfGame |
| Data struct containing the game's state properties. More... | |
Typedefs | |
| typedef struct stateOfGame | currentGameState |
Functions | |
| currentGameState | initializeCurrentGameState () |
| Initialize the variables in the data struct currentGameState. | |
| double | newgame (char schemafilename[], unsigned int *bestrouteweight) |
| Start a new game, using loadCheckGame and bestroute functions. | |
| bool | checkRowColValues (unsigned short int *errnum, char *err) |
| Checks if the number of rows and columns in the schema are corrects. | |
| void | setSchemaDataStructures (char **schema_propr) |
| Set the values of the passed schema into the global variable schemaData.gameMap. | |
| void | checkDoorStartPoint (unsigned short int *errnum, char *err) |
| Checks if the number of doors and start point are corrects. | |
| unsigned short int | loadCheckGame (char *file_name) |
| Function that uses the function readfile to get a vector of strings, which represent the data of the schema. | |
| unsigned int | getdoors (unsigned int *doorsRow, unsigned int *doorsCol) |
| Function that find all the DOORs in the schema. | |
| bool | isDirectory (char const *path) |
| Check if a path is a directory. | |
| char * | get_schema_name (unsigned short int level) |
| Function that retrieval a schema name of specified level randomly. | |
| bool | isallowedchar (unsigned short int typeCharSel, char char2check) |
| Function that checks if the character in input is allowed Variable "selection" is used as bit mask. | |
| unsigned int | countDigits (unsigned int number) |
| Count number of digits of the variable "number". | |
| bool | check_if_text_is_number (const bool runme, const char *text, char *err_buff, const char *err_label) |
| Check if the passed text is composed by digits. | |
| unsigned int | calcSchemaResults (char *labeltxt, currentGameState gameState) |
| Calculate the schema results (correctness, bonus, time, points) and print them into labeltxt. | |
Variables | |
| static const unsigned short int | START_LEVEL = 1 |
| Number of the first level. | |
| static const unsigned short int | START_TOTAL_POINTS = 0 |
| Number of points before start a tournament. | |
| static const unsigned short int | START_ROUND_NUMBER = 1 |
| Number of round before start a tournament. | |
Definition in file schemaGameUtility.h.
| typedef struct stateOfGame currentGameState |
Definition at line 69 of file schemaGameUtility.h.
| unsigned int calcSchemaResults | ( | char * | labeltxt, | |
| currentGameState | gameState | |||
| ) |
Calculate the schema results (correctness, bonus, time, points) and print them into labeltxt.
| labeltxt | Schema results output | |
| gameState | State of game |
Definition at line 503 of file schemaGameUtility.c.
References stateOfGame::bestrouteweight, BONUS_POINTS, stateOfGame::currentlevel, D1, D2, GIVE_BONUS_PERC, stateOfGame::iters, NO_BONUS_POINTS, stateOfGame::numOfRound, SEC_PER_LEVEL, stateOfGame::starttime, and stateOfGame::totalpoints.
Referenced by win().

| bool check_if_text_is_number | ( | const bool | runme, | |
| const char * | text, | |||
| char * | err_buff, | |||
| const char * | err_label | |||
| ) | [inline] |
Check if the passed text is composed by digits.
If 'runme' is set to false the function skip the checks and return 'false'.
| runme | Execute the check | |
| text | Text to check | |
| err_buff | Error message | |
| err_label | Label to put into err_buff |
Definition at line 477 of file schemaGameUtility.c.
References DIGITS, and isallowedchar().
Referenced by checkResponseErrorGenerateParameters().


| void checkDoorStartPoint | ( | unsigned short int * | errnum, | |
| char * | err | |||
| ) |
Checks if the number of doors and start point are corrects.
| errnum | Number of errors | |
| err | Error string message |
Definition at line 207 of file schemaGameUtility.c.
References D1, DOOR, schemaProp::gameMap, schemaProp::numCol, schemaProp::numRow, schemaData, START, schemaProp::startCol, and schemaProp::startRow.
Referenced by loadCheckGame().

| bool checkRowColValues | ( | unsigned short int * | errnum, | |
| char * | err | |||
| ) |
Checks if the number of rows and columns in the schema are corrects.
| errnum | Number of errors | |
| err | Error string message |
Definition at line 138 of file schemaGameUtility.c.
References D1, MAXC, MAXR, MINC, MINR, schemaProp::numCol, schemaProp::numRow, and schemaData.
Referenced by loadCheckGame().

| unsigned int countDigits | ( | unsigned int | number | ) | [inline] |
Count number of digits of the variable "number".
| number | Number to analyze |
Definition at line 464 of file schemaGameUtility.c.
References maxValueOfNumericBase, and numericBase.
Referenced by get_schema_name(), and set_gtk_entry_text_from_num().

| char* get_schema_name | ( | unsigned short int | level | ) |
Function that retrieval a schema name of specified level randomly.
| level | Number of the level |
Definition at line 342 of file schemaGameUtility.c.
References countDigits(), D1, D2, GAMES_DIR, GAMES_LEVEL_DIR, isDirectory(), and NULLCHAR.
Referenced by new_tournament().


| unsigned int getdoors | ( | unsigned int * | doorsRow, | |
| unsigned int * | doorsCol | |||
| ) |
Function that find all the DOORs in the schema.
| doorsRow | Number of rows doors | |
| doorsCol | Number of column of the doors |
Definition at line 299 of file schemaGameUtility.c.
References D1, DOOR, schemaProp::gameMap, schemaProp::numCol, schemaProp::numRow, and schemaData.
Referenced by newgame().

| currentGameState initializeCurrentGameState | ( | ) |
Initialize the variables in the data struct currentGameState.
Definition at line 17 of file schemaGameUtility.c.
References stateOfGame::bestrouteweight, stateOfGame::currentCol, stateOfGame::currentlevel, stateOfGame::currentRow, D1, gameState, stateOfGame::iters, stateOfGame::numOfRound, stateOfGame::playing, stateOfGame::starttime, and stateOfGame::totalpoints.
Referenced by gui().

| bool isallowedchar | ( | unsigned short int | typeCharSel, | |
| char | char2check | |||
| ) |
Function that checks if the character in input is allowed Variable "selection" is used as bit mask.
Selection = 1 means characters from 'a' to 'z' Selection = 2 means characters from 'A' to 'Z' Selection = 4 means characters from '0' to '9' Some other possible combination :
| typeCharSel | Selection mask | |
| char2check | Character to check |
Definition at line 420 of file schemaGameUtility.c.
References D1, D4, D5, DIGITS, LOWERCASE, and UPPERCASE.
Referenced by check_if_text_is_number(), checkResponseNameError(), and setGameRecordStructValue().

| bool isDirectory | ( | char const * | path | ) |
Check if a path is a directory.
| path | Path to check |
Definition at line 323 of file schemaGameUtility.c.
References D5.
Referenced by get_schema_name().

| unsigned short int loadCheckGame | ( | char * | file_name | ) |
Function that uses the function readfile to get a vector of strings, which represent the data of the schema.
Store the read data in it's structure without memory loss.
| file_name | Name of file that contains the game |
Definition at line 238 of file schemaGameUtility.c.
References checkDoorStartPoint(), checkRowColValues(), D1, D6, schemaProp::gameMap, MAX_ERR_BUFFER_LEN, MAXC, MAXR, schemaProp::numCol, schemaProp::numRow, readfile(), schemaData, and setSchemaDataStructures().
Referenced by newgame().


| double newgame | ( | char | schemafilename[], | |
| unsigned int * | bestrouteweight | |||
| ) |
Start a new game, using loadCheckGame and bestroute functions.
If debug mode is turned on use printschema function to print the schema.
| schemafilename | Name of the schema to start | |
| bestrouteweight | Best route weight |
Definition at line 47 of file schemaGameUtility.c.
References bestroute(), D1, D2, D4, D5, getdoors(), loadCheckGame(), schemaProp::numCol, schemaProp::numRow, printschema(), schemaData, schemaProp::startCol, and schemaProp::startRow.
Referenced by generate_game(), new_tournament(), and open_game().


| void setSchemaDataStructures | ( | char ** | schema_propr | ) |
Set the values of the passed schema into the global variable schemaData.gameMap.
Initialize also the global variable schemaData.visitedCellInfo.
| schema_propr | Schema game map. |
Definition at line 177 of file schemaGameUtility.c.
References D1, schemaProp::gameMap, schemaProp::numCol, schemaProp::numRow, schemaData, UNVISITED, and schemaProp::visitedCellInfo.
Referenced by loadCheckGame().

const unsigned short int START_LEVEL = 1 [static] |
Number of the first level.
Definition at line 29 of file schemaGameUtility.h.
Referenced by generate_game(), new_tournament(), open_game(), and win().
const unsigned short int START_ROUND_NUMBER = 1 [static] |
Number of round before start a tournament.
Definition at line 33 of file schemaGameUtility.h.
Referenced by generate_game(), open_game(), and win().
const unsigned short int START_TOTAL_POINTS = 0 [static] |
Number of points before start a tournament.
Definition at line 31 of file schemaGameUtility.h.
Referenced by generate_game(), new_tournament(), open_game(), and win().
1.5.8