penguins  1.0.0
placement.h File Reference

Go to the source code of this file.

Detailed Description

Placement phase functions.

Definition in file placement.h.

Enumerations

enum  PlacementError {
  PLACEMENT_VALID = 0 , PLACEMENT_OUT_OF_BOUNDS , PLACEMENT_EMPTY_TILE , PLACEMENT_ENEMY_PENGUIN ,
  PLACEMENT_OWN_PENGUIN , PLACEMENT_MULTIPLE_FISH
}
 
enum  PlacementSwitchError { PLACEMENT_ALL_PENGUINS_PLACED = -1 , PLACEMENT_NO_MORE_FREE_TILES = -2 }
 Return values of placement_switch_player, must all be negative. More...
 

Functions

void placement_begin (Game *game)
 Enters the GAME_PHASE_PLACEMENT phase, can only be called in GAME_PHASE_SETUP_DONE. More...
 
void placement_end (Game *game)
 Exits the GAME_PHASE_PLACEMENT phase and switches to GAME_PHASE_SETUP_DONE. More...
 
int placement_switch_player (Game *game)
 Performs the player switching logic for the placement phase. More...
 
bool any_valid_placement_exists (const Game *game)
 
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. More...
 
void undo_place_penguin (Game *game)
 Removes a GameLogPlacement entry from the log and undoes it. More...
 

Enumeration Type Documentation

◆ PlacementError

Enumerator
PLACEMENT_VALID 
PLACEMENT_OUT_OF_BOUNDS 
PLACEMENT_EMPTY_TILE 
PLACEMENT_ENEMY_PENGUIN 
PLACEMENT_OWN_PENGUIN 
PLACEMENT_MULTIPLE_FISH 

Definition at line 14 of file placement.h.

◆ PlacementSwitchError

Return values of placement_switch_player, must all be negative.

Enumerator
PLACEMENT_ALL_PENGUINS_PLACED 
PLACEMENT_NO_MORE_FREE_TILES 

Definition at line 24 of file placement.h.

Function Documentation

◆ placement_begin()

void placement_begin ( Game game)

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

Definition at line 11 of file placement.c.

◆ placement_end()

void placement_end ( Game game)

Exits the GAME_PHASE_PLACEMENT phase and switches to GAME_PHASE_SETUP_DONE.

Definition at line 20 of file placement.c.

◆ placement_switch_player()

int placement_switch_player ( Game game)

Performs the player switching logic for the placement phase.

Finds the next player who can make a placement, switches Game::current_player_index to that player and returns their index. If there are no more valid placements, returns a PlacementError value, which are all negative numbers.

Definition at line 32 of file placement.c.

◆ any_valid_placement_exists()

bool any_valid_placement_exists ( const Game game)

Definition at line 51 of file placement.c.

◆ validate_placement_simple()

bool validate_placement_simple ( const Game game,
Coords  target 
)

Definition at line 64 of file placement.c.

Referenced by PlayerPlacementController::update_tile_attributes().

◆ validate_placement()

PlacementError validate_placement ( const Game game,
Coords  target 
)

◆ place_penguin()

void place_penguin ( Game game,
Coords  target 
)

Creates a GameLogPlacement entry. The requested placement must be valid.

Definition at line 93 of file placement.c.

Referenced by BotPlacementThread::Entry(), and PlayerPlacementController::on_mouse_up().

◆ undo_place_penguin()

void undo_place_penguin ( Game game)

Removes a GameLogPlacement entry from the log and undoes it.

Definition at line 115 of file placement.c.