Main Page   Alphabetical List   Data Structures   File List   Globals  

battle_core.h

Go to the documentation of this file.
00001 
00008 #define BATTLEFIELD_DIMENSIONS 10
00009 
00010 /* 
00011 this is an array of pieces where all the details of all the pieces are placed
00012 each piece has a name and the associating rank
00013 */
00021 piece pieces_table[12] = 
00022 {
00023         { "Marshal" , 1},
00024         { "General" , 2},
00025         { "Colonel" , 3},
00026         { "Major" , 4},
00027         { "Captain" , 5},
00028         { "Lieutenant" , 6},
00029         { "Sergeant" , 7},
00030         { "Miner" , 8},
00031         { "Scout" , 9},
00032         { "Spy" , 0}, /* 0 is no rank but represents a spy */
00033         { "Bomb" , 0}, /* again 0 as above... */
00034         { "Flag" , 0}
00035 };
00036 
00037 
00038 /* 
00039 this is an array of board_pieces representing our stratego board.
00040 Each piece provides information on which player is on it and what the 
00041 rank and name of that piece is.
00042 */
00054 battlefield_piece battlefield[BATTLEFIELD_DIMENSIONS][BATTLEFIELD_DIMENSIONS];
00055 
00056 
00057 /* 
00058 function used to initialise board
00059 Initialisation must set all pieces on battlefield to no player 
00060 and rank and name to something that does not characterise a piece
00061 */
00062 /* this function should initialise the data in the battlefield array */
00074 void initialise_battlefield();
00075 
00076 /*
00077 function that returns true if a piece on the battlefield
00078 defined by x and y belongs to player
00079 */
00091 int belong_to_player( int player , int x , int y);
00092 
00093 /*
00094 function that returns true if an attack takes place 
00095 false if it is a move
00096 i.e.checks the pieces on the battlefield to see if the piece
00097 defined by  z and w is empty or not. If it is empty then 
00098 we have a move (FALSE) else an attack(TRUE)
00099 */
00112 int attack_or_move (int z , int w );
00113 
00114 /*
00115 returns TRUE if the piece x,y belongs to player, if z,w doesn't and if x,y is not a bomb or flag
00116 In detail it looks at:
00117 If x,y belongs to player, it is not a bomb or flag and z,w does not belong to player then return TRUE
00118 Otherwise return FALSE outputting the appropriate error message
00119 */
00120 
00136 int check_piece_clicked ( int player , int x , int y , int z , int w);
00137 
00138 /*
00139 returns TRUE if the piece being moved or attacked is performing a legal move
00140 A legal move would be:
00141 1.One square at a time, forward, backward or sideways
00142 2.Can not jump over another piece even if it is a scout
00143 */
00144 
00165 int legal_move (int x , int y , int z , int w);
00166 
00167 /*
00168 returns TRUE if scout move was legal.
00169 Checks if a scout moved in the correct direction and if he jumped over a piece
00170 Also checks the fact that the scout can not move and attack at the same move
00171 The difference variable checks to verify exactly that move
00172 */
00186 int check_scout_move (int x , int y , int z , int w , int difference);
00187 
00188 
00189 /* function which checks ranks and decides winner in case of attack*/
00209 int decide_winner( int x , int y , int z , int w);
00210 
00227 void perform_move( int player , int x1 , int y1 , int x2 , int y2 , int reveal);
00228 
00229 /* get bitmap no as agreed */
00238 int get_bitmapno( char* name);

Generated on Sat Mar 16 13:12:15 2002 for SLIP 2002 - Stratego2Go by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002