penguins  1.0.0
placement.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #include "game.h"
7 #include "utils.h"
8 #include <stdbool.h>
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 typedef enum PlacementError {
22 
24 typedef enum PlacementSwitchError {
28 
29 void placement_begin(Game* game);
30 void placement_end(Game* game);
31 
32 int placement_switch_player(Game* game);
33 bool any_valid_placement_exists(const Game* game);
34 
35 bool validate_placement_simple(const Game* game, Coords target);
36 PlacementError validate_placement(const Game* game, Coords target);
37 void place_penguin(Game* game, Coords target);
38 void undo_place_penguin(Game* game);
39 
40 #ifdef __cplusplus
41 }
42 #endif
The core of the unified game logic library, contains the Game struct.
PlacementSwitchError
Return values of placement_switch_player, must all be negative.
Definition: placement.h:24
@ PLACEMENT_ALL_PENGUINS_PLACED
Definition: placement.h:25
@ PLACEMENT_NO_MORE_FREE_TILES
Definition: placement.h:26
PlacementError
Definition: placement.h:14
@ PLACEMENT_VALID
Definition: placement.h:15
@ PLACEMENT_OWN_PENGUIN
Definition: placement.h:19
@ PLACEMENT_MULTIPLE_FISH
Definition: placement.h:20
@ PLACEMENT_ENEMY_PENGUIN
Definition: placement.h:18
@ PLACEMENT_EMPTY_TILE
Definition: placement.h:17
@ PLACEMENT_OUT_OF_BOUNDS
Definition: placement.h:16
A pair of 2D coordinates, used for addressing the Game::board_grid.
Definition: utils.h:15
The central struct of the application, holds the game data and settings.
Definition: game.h:237
void undo_place_penguin(Game *game)
Removes a GameLogPlacement entry from the log and undoes it.
Definition: placement.c:115
bool validate_placement_simple(const Game *game, Coords target)
Definition: placement.c:64
bool any_valid_placement_exists(const Game *game)
Definition: placement.c:51
void placement_begin(Game *game)
Enters the GAME_PHASE_PLACEMENT phase, can only be called in GAME_PHASE_SETUP_DONE.
Definition: placement.c:11
PlacementError validate_placement(const Game *game, Coords target)
Definition: placement.c:70
int placement_switch_player(Game *game)
Performs the player switching logic for the placement phase.
Definition: placement.c:32
void place_penguin(Game *game, Coords target)
Creates a GameLogPlacement entry. The requested placement must be valid.
Definition: placement.c:93
void placement_end(Game *game)
Exits the GAME_PHASE_PLACEMENT phase and switches to GAME_PHASE_SETUP_DONE.
Definition: placement.c:20