#ifndef GAMEBOARD_H #define GAMEBOARD_H #include "ai_loader.h" #include #include #include #include #include #include class GameBoard : public Fl_Widget { public: GameBoard(int X, int Y, int W, int H, const char *L = 0); Fl_Input *max_time_input, *max_depth_input; void draw() override; int handle(int event) override; void init(const std::vector> &pieces); enum Color { SILVER = 1, RED = 2 }; enum LaserDirection { NORTH = 1, EAST = 2, SOUTH = 3, WEST = 4 }; enum PieceType { ANUBIS, PYRAMID, SCARAB, PHARAOH, SPHINX }; enum PieceOrientation { ORIENT_NORTH, ORIENT_EAST, ORIENT_SOUTH, ORIENT_WEST }; enum ReflectionResult { RESULT_DEAD, RESULT_ABSORBED, RESULT_EAST, RESULT_WEST, RESULT_SOUTH, RESULT_NORTH }; enum MovePermission { S = 1, R = 2, B = 3 }; static std::string getPieceFilename(char piece, int direction); static std::pair getPieceTypeAndOrientation(const std::string &piece_str); static void laser_timer_cb(void *data); private: AILoader ai_loader; int rows = 8, cols = 10, clicked_row = -1, clicked_col = -1, square_selected_num = -1; int cell_width, cell_height; bool square_selected = false; bool laser_active = false; int laser_step = 5; LaserDirection laser_direction; float laser_y, laser_x; bool remove_piece = false; int laser_square_row, laser_square_col, remove_row, remove_col; int l_idx; std::vector> board_pieces; std::vector piece_images; std::vector> laser_path; std::vector> laser_path_squares; static std::unordered_map>> reflections_map; static std::unordered_map piece_map; static std::unordered_map rotate_left_map; static std::unordered_map rotate_right_map; static const MovePermission move_permissions[8][10]; void drawInnerSquares(); void rotateSelectedPiece(bool clockwise); void moveSelectedPiece(int end_square); void swapPieces(int swap_square); void deletePiece(); void resetPieces(); void fireLaser(Color color); void updateLaserPosition(); void calculateLaserPathSquares(); bool squareContainsPiece(int square_num); void rebuildReloadKhetAILib(); }; #endif