return new_coordinates;
}
-unsigned add_coordinates(coordinates_t new_coordinates, coordinates_t* coordinates_array) {
+/* the function do a lot of sanity checks before adding new board elements,
+ * hence the loop. moving the checks in the main loop is also possible */
+unsigned add_coordinates(coordinates_t new_coordinates, coordinates_t* coordinates_array, unsigned round) {
/* valid coordinates are in the [1-3] range */
if (new_coordinates.y < 1 || new_coordinates.y > 3 || new_coordinates.x < 1 || new_coordinates.x > 3) {
return 3; /* error value for invalid coordinates */
+ } else if (round == MAX_COORDINATES + 1) {
+ return 1; /* error value for full array */
}
+
for (unsigned i = 0; i < MAX_COORDINATES; i++) {
/* check if already entered */
if (new_coordinates.y == (coordinates_array + i)->y && new_coordinates.x == (coordinates_array + i)->x) {
return 0; /* error value when everything if fine */
}
}
- return 1; /* error value for full array */
+ return 4; /* error value for unknown error case - should never happen - */
+}
+
+bool chk_win_conditions(coordinates_t* coordinates_array) {
+ for (unsigned i = 0; i < MAX_COORDINATES; i++) {
+
+ }
+ return false;
}