Listing 1 This code performs a move operation based on the type of game piece.

#ifndef GAME_H
#define GAME_H

typedef enum { PAWN, BISHOP, ROOK, KING } GAME_PIECE;

typedef struct {
   int vertical;
} PAWN_MOVE_STRUCT;

typedef PAWN_MOVE_STRUCT   *PAWN_MOVE;

typedef struct {
   int diagonal;
} BISHOP_MOVE_STRUCT;

typedef BISHOP_MOVE_STRUCT   *BISHOP_MOVE;

typedef struct {
   int vertical;
   int horizontal;
} ROOK_MOVE_STRUCT;

typedef ROOK_MOVE_STRUCT   *ROOK_MOVE;

typedef struct {
   int vertical;
   int horizontal;
   int diagonal;
} KING_MOVE_STRUCT;

typedef KING_MOVE_STRUCT   *KING_MOVE;

typedef union {
   PAWN_MOVE      PawnM;
   BISHOP_MOVE    BishopM;
   ROOK_MOVE      BookM;
   KING_MOVE      KingM;
} MOVE_U;

typedef MOVE_U             *MOVE;

typedef struct {
   GAME_PIECE     piece_type;
   MOVE           moves;
   int            x_coord;
   int            y_coord;
} PIECE_STRUCT;

typedef PIECE_STRUCT    *PIECE;

#endif /* GAME_H */
/* End of File */