20 : panel(panel), canvas(panel->canvas), game(panel->game.get()), bot_params(panel->bot_params) {}
119 std::shared_ptr<BotThreadShared> shared =
nullptr;
129 shared->wait_for_exit();
169 bool is_a_tile_selected =
200 bool any_steps =
false;
202 Coords coords = selected_penguin;
204 any_steps = any_steps || moves.
steps[dir] != 0;
205 for (
int steps = moves.
steps[dir]; steps > 0; steps--) {
206 coords.
x += d.
x, coords.
y += d.
y;
239 Coords move_fail = penguin;
284 return "Penguins cannot move diagonally, only horizontally or vertically.";
292 return "There are no possible moves for this penguin, it is blocked on all sides.";
310 frame->
SetStatusText(
"This is a valid move! Release the mouse to confirm it.", 0);
312 frame->
SetStatusText(
"This is a valid move! Click on the tile to confirm it.", 0);
316 "(%d, %d) -> (%d, %d)",
332 frame->
SetStatusText(
"Either drag or click on a penguin to make a move.", 0);
void set_all_tiles_attr(Game *game, short attr, bool value)
Sets the attribute attr on all tiles.
bool is_tile_in_bounds(const Game *game, Coords coords)
Checks if the given coords are within the bounds of the board.
short get_tile(const Game *game, Coords coords)
Returns the value of the tile at coords. Fails if coords are outside the bounds.
bool get_tile_attr(const Game *game, Coords coords, short attr)
Checks whether the attribute attr of the tile at coords is set.
void set_tile_attr(Game *game, Coords coords, short attr, bool value)
Sets (or resets) the attribute attr of the tile at coords.
Functions for working with the game board (and the specifics of its encoding)
#define is_penguin_tile(tile)
#define get_tile_player_id(tile)
virtual BotThread * create_bot_thread() override
virtual BotThread * create_bot_thread() override
std::shared_ptr< BotThreadShared > shared
virtual BotThread * create_bot_thread()=0
virtual ~BotTurnController()
virtual void on_mouse_up(wxMouseEvent &event) override
void unregister_bot_thread(BotThread *thread)
wxCriticalSection bot_thread_cs
virtual void update_status_bar() override
void on_bot_thread_done_work(bool cancelled)
virtual void on_activated() override
virtual void update_tile_attributes() override
virtual void configure_bot_turn_ui() override
virtual void on_deactivated(GameController *next_controller) override
void paint_selected_tile_outline(wxDC &dc, Coords coords, bool blocked=false)
void paint_move_arrow(wxDC &dc, Coords start, Coords end)
Coords tile_coords_at_point(wxPoint point) const
Coords get_selected_penguin_coords() const
virtual void on_mouse_move(wxMouseEvent &event)
GameController(GamePanel *panel)
virtual void on_mouse_up(wxMouseEvent &event)
virtual void on_deactivated(GameController *next_controller)
void update_game_state_and_indirectly_delete_this()
virtual void update_status_bar()
virtual void configure_log_viewer_ui()
virtual void on_activated()
virtual void on_mouse_down(wxMouseEvent &event)
virtual void on_mouse_enter_leave(wxMouseEvent &event)
virtual void paint_overlay(wxDC &dc)
virtual void configure_bot_turn_ui()
virtual void update_tile_attributes()
virtual void update_status_bar() override
virtual void on_activated() override
wxSizer * game_controls_box
wxButton * show_current_turn_btn
void start_bot_progress()
void update_player_info_boxes()
virtual void paint_overlay(wxDC &dc) override
virtual void configure_log_viewer_ui() override
virtual void update_status_bar() override
virtual void on_activated() override
virtual void update_status_bar() override
virtual void on_mouse_move(wxMouseEvent &event) override
virtual void on_mouse_down(wxMouseEvent &event) override
virtual void update_tile_attributes() override
virtual void paint_overlay(wxDC &dc) override
virtual void on_mouse_up(wxMouseEvent &event) override
virtual void on_mouse_up(wxMouseEvent &event) override
virtual void update_status_bar() override
virtual void update_tile_attributes() override
virtual void on_mouse_move(wxMouseEvent &event) override
virtual void paint_overlay(wxDC &dc) override
void CallAfter(void(T::*method)(T1,...), T1 x1,...)
virtual void SetStatusText(const wxString &text, int number=0)
static wxString Format(const wxString &format,...)
static wxThreadIdType GetCurrentId()
wxThreadIdType GetId() const
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
virtual bool Enable(bool enable=true)
virtual bool Show(bool show=true)
static wxString describe_placement_result(PlacementError result)
static wxString describe_movement_result(MovementError result)
Player * game_get_current_player(const Game *self)
A shorthand for calling game_get_player with Game::current_player_index.
const GameLogEntry * game_get_log_entry(const Game *self, size_t idx)
Returns a pointer to the entry at the given index. Note that the returned pointer is const because th...
void game_rewind_state_to_log_entry(Game *self, size_t target_entry)
Successively undoes or redoes log entries in order to reset the game state to the entry at the given ...
The core of the unified game logic library, contains the Game struct.
@ GAME_PHASE_END
Set by game_end.
@ GAME_LOG_ENTRY_PHASE_CHANGE
See GameLogPhaseChange.
@ GAME_LOG_ENTRY_PLACEMENT
See GameLogPlacement.
@ GAME_LOG_ENTRY_MOVEMENT
See GameLogMovement.
@ TILE_BLOCKED_FOR_CURSOR
#define wxASSERT(condition)
void move_penguin(Game *game, Coords start, Coords target)
Creates a GameLogMovement entry. The requested move must be valid.
PossibleSteps calculate_penguin_possible_moves(const Game *game, Coords start)
MovementError validate_movement(const Game *game, Coords start, Coords target, Coords *fail)
MovementError validate_movement_start(const Game *game, Coords start)
Movement phase functions.
@ MOVEMENT_OVER_EMPTY_TILE
@ MOVEMENT_PENGUIN_BLOCKED
@ MOVEMENT_NOT_YOUR_PENGUIN
@ MOVEMENT_CURRENT_LOCATION
@ MOVEMENT_ONTO_EMPTY_TILE
bool validate_placement_simple(const Game *game, Coords target)
PlacementError validate_placement(const Game *game, Coords target)
void place_penguin(Game *game, Coords target)
Creates a GameLogPlacement entry. The requested placement must be valid.
Placement phase functions.
@ PLACEMENT_MULTIPLE_FISH
@ PLACEMENT_ENEMY_PENGUIN
@ PLACEMENT_OUT_OF_BOUNDS
A pair of 2D coordinates, used for addressing the Game::board_grid.
An entry in the Game::log_buffer, implemented as a tagged union.
union GameLogEntry::GameLogEntryData data
int board_width
Use setup_board for setting this.
size_t log_length
The actual number of entries in log_buffer. game_push_log_entry and game_pop_log_entry affects this.
int board_height
Use setup_board for setting this.
short id
The unique ID, usually (but not necessarily) is just index + 1.
Exists purely to wrap an array of the numbers of steps in every possible Direction.
GameLogPlacement placement
GameLogPhaseChange phase_change
bool coords_same(Coords a, Coords b)
Checks if two Coords pairs are equal.
const Coords DIRECTION_TO_COORDS[DIRECTION_MAX]
A table that maps Direction variants to relative Coords.