penguins  1.0.0
movement.h File Reference

Go to the source code of this file.

Detailed Description

Movement phase functions.

Definition in file movement.h.

Data Structures

struct  PossibleSteps
 Exists purely to wrap an array of the numbers of steps in every possible Direction. More...
 

Enumerations

enum  MovementError {
  MOVEMENT_VALID = 0 , MOVEMENT_OUT_OF_BOUNDS , MOVEMENT_CURRENT_LOCATION , MOVEMENT_DIAGONAL ,
  MOVEMENT_NOT_A_PENGUIN , MOVEMENT_NOT_YOUR_PENGUIN , MOVEMENT_ONTO_EMPTY_TILE , MOVEMENT_ONTO_PENGUIN ,
  MOVEMENT_OVER_EMPTY_TILE , MOVEMENT_OVER_PENGUIN , MOVEMENT_PENGUIN_BLOCKED
}
 

Functions

void movement_begin (Game *game)
 Enters the GAME_PHASE_MOVEMENT phase, can only be called in GAME_PHASE_SETUP_DONE. More...
 
void movement_end (Game *game)
 Exits the GAME_PHASE_MOVEMENT phase and switches to GAME_PHASE_SETUP_DONE. More...
 
int movement_switch_player (Game *game)
 Performs the player switching logic for the movement phase. More...
 
bool any_valid_player_move_exists (const Game *game, int player_idx)
 
MovementError validate_movement_start (const Game *game, Coords start)
 
MovementError validate_movement (const Game *game, Coords start, Coords target, Coords *fail)
 
void move_penguin (Game *game, Coords start, Coords target)
 Creates a GameLogMovement entry. The requested move must be valid. More...
 
void undo_move_penguin (Game *game)
 Removes a GameLogMovement entry from the log and undoes it. More...
 
int count_obstructed_directions (const Game *game, Coords penguin)
 
PossibleSteps calculate_penguin_possible_moves (const Game *game, Coords start)
 

Enumeration Type Documentation

◆ MovementError

Enumerator
MOVEMENT_VALID 
MOVEMENT_OUT_OF_BOUNDS 
MOVEMENT_CURRENT_LOCATION 
MOVEMENT_DIAGONAL 
MOVEMENT_NOT_A_PENGUIN 
MOVEMENT_NOT_YOUR_PENGUIN 
MOVEMENT_ONTO_EMPTY_TILE 
MOVEMENT_ONTO_PENGUIN 
MOVEMENT_OVER_EMPTY_TILE 
MOVEMENT_OVER_PENGUIN 
MOVEMENT_PENGUIN_BLOCKED 

Definition at line 16 of file movement.h.

Function Documentation

◆ movement_begin()

void movement_begin ( Game game)

Enters the GAME_PHASE_MOVEMENT phase, can only be called in GAME_PHASE_SETUP_DONE.

Definition at line 11 of file movement.c.

◆ movement_end()

void movement_end ( Game game)

Exits the GAME_PHASE_MOVEMENT phase and switches to GAME_PHASE_SETUP_DONE.

Definition at line 20 of file movement.c.

◆ movement_switch_player()

int movement_switch_player ( Game game)

Performs the player switching logic for the movement phase.

Finds the next player who can make a move, sets Game::current_player_index to that player and returns their index. If no players can make any moves returns a negative number.

Definition at line 31 of file movement.c.

◆ any_valid_player_move_exists()

bool any_valid_player_move_exists ( const Game game,
int  player_idx 
)

Definition at line 47 of file movement.c.

Referenced by PlayerInfoBox::update_data().

◆ validate_movement_start()

MovementError validate_movement_start ( const Game game,
Coords  start 
)

◆ validate_movement()

MovementError validate_movement ( const Game game,
Coords  start,
Coords  target,
Coords fail 
)

◆ move_penguin()

void move_penguin ( Game game,
Coords  start,
Coords  target 
)

Creates a GameLogMovement entry. The requested move must be valid.

Definition at line 118 of file movement.c.

Referenced by BotMovementThread::Entry(), and PlayerMovementController::on_mouse_up().

◆ undo_move_penguin()

void undo_move_penguin ( Game game)

Removes a GameLogMovement entry from the log and undoes it.

Definition at line 142 of file movement.c.

◆ count_obstructed_directions()

int count_obstructed_directions ( const Game game,
Coords  penguin 
)
inline

Definition at line 50 of file movement.h.

◆ calculate_penguin_possible_moves()

PossibleSteps calculate_penguin_possible_moves ( const Game game,
Coords  start 
)
inline

Definition at line 64 of file movement.h.

Referenced by PlayerMovementController::update_tile_attributes().